Reputation: 4142
I'm trying to set up a modal to slide up from bottom but there's no tutorial for Bootstrap 4 that actually works. Here's an attempt:
HTML
<button type="submit" class="btn btn-block btn-default footer__btn" data-toggle="modal" data-target="#myModal2"> Open Modal</button>
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
Body of the modal.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
CSS
.modal.fade .modal-dialog {
-webkit-transform: translate(0,100%);
-ms-transform: translate(0,100%);
-o-transform: translate(0,100%);
transform: translate(0,100%);
}
Upvotes: 4
Views: 20252
Reputation: 5074
.modal.fade .modal-dialog {
transform: translate3d(0, 100vh, 0);
}
.modal.show .modal-dialog {
transform: translate3d(0, 0, 0);
}
Upvotes: 1
Reputation: 882
Since you don't want to add another framework on top of Bootstrap 4, I just changed the CSS :
.animate-bottom {
position: relative;
animation: animatebottom 0.4s;
}
@keyframes animatebottom {
from {
bottom: -300px;
opacity: 0;
}
to {
bottom: 0;
opacity: 1;
}
}
Then just add the class animate-bottom
after the modal-content
in the <div>
<button type="submit" class="btn btn-block btn-default footer__btn" data-toggle="modal" data-target="#myModal2"> Open Modal</button>
<div class="modal fade animate" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content animate-bottom"> <!-- Here you have the juicy hahah -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel"> ABOUT </h4>
</div>
<div class="modal-body">
CONTEÚDO
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Here's the Fiddle :
Make sure you make it cross-browser, but this is just the base of the animation, hope it'll fit your request.
Upvotes: 6
Reputation: 882
I'd use a W3CSS Framework with modal animation, it'd look like this, hope it helps :
HTML :
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<button type="submit" class="btn btn-block btn-default footer__btn" data-toggle="modal" data-target="#myModal2"> Open Modal</button>
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content w3-animate-bottom">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel"> ABOUT </h4>
</div>
<div class="modal-body">
CONTEÚDO
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
CSS :
.modal.fade .modal-dialog {
-webkit-transform: translate(0,100%);
-ms-transform: translate(0,100%);
-o-transform: translate(0,100%);
transform: translate(0,100%);
}
Upvotes: 0