Vzupo
Vzupo

Reputation: 1468

how can i increase bootstrap modal height

I am simply trying to make a bootstrap modal display extremely tall on a iphone 5/6 device.

I cannot get this to work for anything. I have tried increasing the height in the modal-content, as well as in modal-dialog, but it just wont work.

Any easy solutions out there?

.modal-dialog{
    height:90% !important;
}
<div class="container">
  <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
    Launch modal
  </button>
</div>

<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">My modal</h4>
      </div>
    </div>
  </div>
</div>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

Upvotes: 7

Views: 28544

Answers (3)

Devstorm
Devstorm

Reputation: 516

It does not work on Bootstrap5.

.modal-dialog {
  height: 90%; /* = 90% of the .modal-backdrop block = %90 of the screen */
}
.modal-content {
  height: 100%; /* = 100% of the .modal-dialog block */
}

The following works well.

.modal-dialog, .modal-content {
  height: 70%;
}

.modal-body {
  max-height: calc(100% - 120px);;
  overflow-y: scroll;
}

Upvotes: 0

Gleb Kemarsky
Gleb Kemarsky

Reputation: 10398

The .modal-content block is inside the .modal-dialog block. Hence, tell the child to be of the same height as the parent. Try:

.modal-dialog {
  height: 90%; /* = 90% of the .modal-backdrop block = %90 of the screen */
}
.modal-content {
  height: 100%; /* = 100% of the .modal-dialog block */
}

Check:

@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');

.modal-tall .modal-dialog {
  height: 90%;
}
.modal-tall .modal-content {
  height: 100%;
}

/* fix SO stick navigation ;) */
@media (min-width: 768px) { body { padding-top: 75px; } }
<div class="container">
  <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#modalDefault">
    Default modal
  </button>

  <button type="button" class="btn btn-warning btn-lg" data-toggle="modal" data-target="#modalTall">
    Tall modal
  </button>
</div>

<div id="modalDefault" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Default modal</h4>
      </div>
    </div>
  </div>
</div>

<div id="modalTall" class="modal modal-tall fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal has 90% height</h4>
      </div>
    </div>
  </div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

Upvotes: 13

That is because the model is inside the class modal-content and I dont know how is your code and if your content have some reference, for now you can specific in pixels:

.modal-content{
  height:500px;
}

Upvotes: 0

Related Questions