Is there a way to change the Twitter Bootstrap Modal window animation from a slide down effect to a fadeIn or just display without the Slide? I read through the documentatio
The question was clear: remove only the slide: Here is how to change it in Bootstrap v3
In modals.less comment out the translate statement:
&.fade .modal-dialog {
// .translate(0, -25%);
Just remove the fade class and if you want more animations to be perform on the Modal just use animate.css classes in your Modal.
I'm working with bootstrap 3 and the Durandal JS 2 modal plugin. This question was on top of Google results and as none of the answers above is working for me I thought I'd share my solution for future visitors.
I override the default Bootstrap's Less code with this in my own less:
.modal {
&.fade .modal-dialog {
.translate(0, 0);
.transition-transform(~"none");
}
&.in .modal-dialog { .translate(0, 0)}
}
That way I am left with only the fade effect, and no slideDown.
Just take out the fade
class from the modal div.
Specifically, change:
<div class="modal fade hide">
to:
<div class="modal hide">
UPDATE: For bootstrap3, the hide
class is not needed.
I believe that most of these answers are for bootstrap 2. I ran into the same issue for bootstrap 3 and wanted to share my fix. Like my previous answer for bootstrap 2, this will still do an opacity fade, but will NOT do the slide transition.
You can either change the modals.less or the theme.css files, depending on your workflow. If you haven't spent any quality time with less, I'd highly recommend it.
for less, find the following code in MODALS.less
&.fade .modal-dialog {
.translate(0, -25%);
.transition-transform(~"0.3s ease-out");
}
&.in .modal-dialog { .translate(0, 0)}
then change the -25%
to 0%
Alternatively, if you're using just the css, find the following in theme.css
:
.modal.fade .modal-dialog {
-webkit-transform: translate(0, -25%);
-ms-transform: translate(0, -25%);
transform: translate(0, -25%);
-webkit-transition: -webkit-transform 0.3s ease-out;
-moz-transition: -moz-transform 0.3s ease-out;
-o-transition: -o-transform 0.3s ease-out;
transition: transform 0.3s ease-out;
}
and then change the -25%
to 0%
.
The modals used by the bootstrap use CSS3 to supply the effects and they can be removed by eliminating the appropriate classes from modals container div:
<div class="modal hide fade in" id="myModal">
....
</div>
As you can see this modal has a class of .fade
, meaning it is set to fade in and.in
, meaning it will slide in. So just remove the class related to the effect you wish to remove, which in your case is just the .in
class.
Edit: Just ran some tests and it appears that that is not the case, the .in
class is added by javascript, though you can modify he slideDown behavior with css like so:
.modal.fade {
-webkit-transition: none;
-moz-transition: none;
-ms-transition: none;
-o-transition: none;
transition: none;
}
Demo