Modal width (increase)

Bootstrap 4Bootstrap Modal

Bootstrap 4 Problem Overview


I want a modal to be 80% or so of a screen width. modal-lg isn't large enough. This:

.modal .modal-dialog {
  width: 80%;
}

Doesn't work with Bootstrap 4.

Bootstrap 4 Solutions


Solution 1 - Bootstrap 4

Bootstrap 3

You can create or just override default bootstrap modal-lgby doing below:

.modal-lg {
    max-width: 80%;
}

If not working just add !important so it would look like below

.modal-lg {
    max-width: 80% !important;
}

Now call the modal-lg.

<div class="modal-dialog modal-lg" role="document">
 <!-- some modal content --->
</div

> For Bootstrap 4 refer to @kitsu.eb answer. Also note that using bootstrap 4 utilities might break the responsiveness.

Solution 2 - Bootstrap 4

Bootstrap 4 includes sizing utilities. You can change the size to 25/50/75/100% of the page width (I wish there were even more increments).

To use these we will replace the modal-lg class. Both the default width and modal-lg use css max-width to control the modal's width, so first add the mw-100 class to effectively disable max-width. Then just add the width class you want, e.g. w-75.

Note that you should place the mw-100 and w-75 classes in the div with the modal-dialog class, not the modal div e.g.,

<div class='modal-dialog mw-100 w-75'>
    ...
</div>

Also, we can even use the well known container class (instead of specifying the size), like:

<div class="modal-dialog mw-100">
    <div class="modal-content container">
        <div class="modal-body">
            ...
        </div>
    </div>
</div>

Solution 3 - Bootstrap 4

For responsive answer.

@media (min-width: 992px) {
  .modal-dialog {
    max-width: 80%;
  }
}

Solution 4 - Bootstrap 4

In Bootstrap 4 you have to use 'max-width' attribute and then it works perfectly.

<div id="modal_dialog" class="modal fade" tabindex="-1" role="dialog" style="display: none;">
<div class="modal-dialog" style="max-width: 1350px!important;" role="document">
	<div class="modal-content">
		<div class="modal-body">
			Sample text
		</div>
	</div>
</div>

Solution 5 - Bootstrap 4

Simply Use !important after giving width of that class that is override your class.

For Example

.modal .modal-dialog {
  width: 850px !important;
}

Hopefully this will works for you.

Solution 6 - Bootstrap 4

This was the solution that worked for me:

.modal{
 padding: 0 !important;
}
.modal-dialog {
  max-width: 80% !important;
  height: 100%;
  padding: 0;
  margin: 0;
}

.modal-content {
  border-radius: 0 !important;
  height: 100%;
}

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<a href="#" class="menu-toggler" data-toggle="modal" data-target=".bd-example-modal-lg">Menu</a>

<div class="modal mobile-nav-modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <a href="#" class="" data-dismiss="modal">Close Menu</a>

      <nav class="modal-nav">
        <ul>
          <li><a data-toggle="collapse" href="#collapseExample" role="button">Shop</a>
            <div class="collapse" id="collapseExample">
              <ul>
                <li><a href="#">List 1</a></li>
                <li><a href="#">List 2</a></li>
                <li><a href="#">List 3</a></li>
              </ul>
              <ul>
                <li><a href="#">List 1</a></li>
                <li><a href="#">List 2</a></li>
                <li><a href="#">List 3</a></li>
              </ul>
            </div>
          </li>
          <li><a href="#">Made To Order</a></li>
          <li><a href="#">Heritage</a></li>
          <li><a href="#">Style & Fit</a></li>
          <li><a href="#">Sign In</a></li>
        </ul>
      </nav>
    </div>
  </div>
</div>

Solution 7 - Bootstrap 4

Make sure your modal is not placed in a container, try to add the !important annotation if it's not changing the width from the original one.

Solution 8 - Bootstrap 4

try to use px

.modal .modal-dialog {
  width: 850px;
}

just change the size.

Solution 9 - Bootstrap 4

If you use Sass,

according to the documentation you can customize your default values.

In your case, you can easily override the variable named $modal-lg in your _custom.scss file.

Solution 10 - Bootstrap 4

The following solution will work for Bootstrap 4.

.modal .modal-dialog {
  max-width: 850px;
}

Solution 11 - Bootstrap 4

Try this, This was the solution that worked for me:

<div class="modal-dialog" style="min-width: 1500px" role="document">

Solution 12 - Bootstrap 4

So i have been struggling too on the same issue. The quick and easiest way to solve the problem is by just adding

  1. modal-lg on your modal Div

Example <div class="modal-dialog modal-lg">

Solution 13 - Bootstrap 4

Set max-width:80%; as an inline stylesheet

<div class="modal-dialog modal-lg" role="document" style="max-width: 80%;">

Solution 14 - Bootstrap 4

You can use a combination of absolute and relative units

.modal-dialog-xw {
  margin-left: auto;
  margin-right: auto;
  min-width: 330px;    /* To prevent shrinking of very small screens (Galaxy S9 for example) */
  max-width: 75%;      /* To use 75% of the width available. Or set in pixels if need. */
}

In html code add after .modal-dialog

<div class="modal-dialog modal-dialog-xw" role="document">...</div>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionOleg AntonyanView Question on Stackoverflow
Solution 1 - Bootstrap 4claudiosView Answer on Stackoverflow
Solution 2 - Bootstrap 4kitsu.ebView Answer on Stackoverflow
Solution 3 - Bootstrap 4Joel Enanod JrView Answer on Stackoverflow
Solution 4 - Bootstrap 4CeezSView Answer on Stackoverflow
Solution 5 - Bootstrap 4Unknown_CoderView Answer on Stackoverflow
Solution 6 - Bootstrap 4NemusView Answer on Stackoverflow
Solution 7 - Bootstrap 4Elie NassifView Answer on Stackoverflow
Solution 8 - Bootstrap 4mjishighView Answer on Stackoverflow
Solution 9 - Bootstrap 4s.a.filkoView Answer on Stackoverflow
Solution 10 - Bootstrap 4AsrafView Answer on Stackoverflow
Solution 11 - Bootstrap 4repsajgView Answer on Stackoverflow
Solution 12 - Bootstrap 4John Elias KwandikwaView Answer on Stackoverflow
Solution 13 - Bootstrap 4Sathish KumarView Answer on Stackoverflow
Solution 14 - Bootstrap 4Plamen S.View Answer on Stackoverflow