AgainMe
AgainMe

Reputation: 780

Cannot keep footer at bottom in bootstrap modal fullscreen

I'm trying to keep the footer of bootstrap modal to bottom but I can't, this is my html structure:

<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

Essentially I want display the modal at fullscreen mode, this working good, but the footer doesn't go to bottom.

Css:

.modal-dialog {
 width: 100%;
  height: 100%;
  padding: 0;
}

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

I create a jsfiddle that explain the situation:

http://jsfiddle.net/8XdVt/?utm_source=website&utm_medium=embed&utm_campaign=8XdVt

and

http://jsfiddle.net/8XdVt/show/

Upvotes: 3

Views: 18206

Answers (4)

kewur
kewur

Reputation: 491

if you're using angular and ngbootstrap library and launching your modal with

ngbModal.open(MyComponent);

you can put this inside your component

@HostBinding('class') class = 'd-flex flex-column h-100';

and set either modal-body or another element under flex to flex-grow-1

Upvotes: 1

Baezid Mostafa
Baezid Mostafa

Reputation: 2728

Add this lines into modal footer Fiddle By default modal content has position relative. I used !important for css overrule on class modal-dialog. If you have separet css file then you don't need to use !important.

  
   .modal-dialog {

  width:100% !important;
  height: 100%;
  margin: 0 auto !important;
  padding:20px 20px;
}

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

.modal-footer{
position:absolute;
bottom:0;
width:100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script
  src="https://code.jquery.com/jquery-3.1.1.min.js"
  integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
  crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

Upvotes: 0

user7391345
user7391345

Reputation:

Everything works fine, my friend.

Jsfiddle

.modal-dialog {
  width: 100%;
  height: 100%;
  padding: 0;
}

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

.modal-footer {
  position: absolute;
  bottom: 0;
  width: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

Upvotes: 1

Deep
Deep

Reputation: 9794

You can give the model-content a relative position and modal-footer position absolute with bottom 0px;

Try with

.modal-content {
  height: 100%;
  border-radius: 0;
  position:relative;
}

.modal-footer {
  border-radius: 0;
  bottom:0px;
  position:absolute;
  width:100%;
}

fiddle :http://jsfiddle.net/1fh2n5y3/

Upvotes: 9

Related Questions