Hello there, today I met a situation where I had to change the animation of a bootstrap 4 modal and figured out this solution. I added a zoom-in animation with a playtime of 1.5 seconds to the modal. Please have a look at it in the demo below.
DEMO
Open demo in a full window – https://demos.webdevpuneet.com/bootstrap4-modal/index.html
HTML
<html>
<head>
<meta charset="UTF-8" />
<title>Bootstrap 4 modal animation change</title>
<meta name="description" content="The following example creates a thin (10px wide) scrollbar, which has a grey track/bar color and a red handle." />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1 style="margin-bottom:20px;">Bootstrap 4 modal animation change</h1>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade zoom-in" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</body>
</html>
CSS
body{
padding:50px;
}
.modal.fade .modal-dialog{
-webkit-transform: translate(0,0);
transform: translate(0,0);
}
.zoom-in {
transform: scale(0)!important;
opacity: 0;
-webkit-transition: 1.5s all 0s;
-moz-transition: 1.5s all 0s;
-ms-transition: 1.5s all 0s;
-o-transition: 1.5s all 0s;
transition: 1.5s all 0s;
display: block !important;
}
.zoom-in.show {
opacity: 1;
transform: scale(1)!important;
transform:none;
}