Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 353
Vzupo Avatar asked Jun 07 '17 01:06

Vzupo


People also ask

How do I change the height of a bootstrap modal?

modal max-height is 100vh . Then for . modal-body use calc() function to calculate desired height. In above case we want to occupy 80vh of the viewport, reduced by the size of header + footer in pixels.

How do you increase width and height of modals?

Answer: Set width for . modal-dialog element Similarly, you can override the width property of . modal-sm , . modal-lg and . modal-xl class to resize the small, large and extra-large modal dialog box respectively.

How can I make my modal height responsive?

Making your Modal Responsive The most obvious way is to write a bunch of media queries like a chump. I instead suggest using max-width and max-height. When combined with calc() this allows you to have a consistent padding between the modal and the edge of the screen on smaller devices.

How do you increase modal size in Reactstrap?

The docs reactstrap really bad to explained. Don't forget everyone, you can also do size="xl" . To achieve greater sizes than this, you have to use a stylesheet imported and on the Modal component itself, specifically a property called contentClassName . By writing to a separate file like styles.


1 Answers

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>
like image 146
Gleb Kemarsky Avatar answered Sep 17 '22 12:09

Gleb Kemarsky