Twitter Bootstrap modal: How to remove Slide down effect

前端 未结 16 2159
野趣味
野趣味 2020-12-07 11:38

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

相关标签:
16条回答
  • 2020-12-07 12:38

    If you like to have the modal fade in rather than slide in (why is it called .fade anyway?) you can overwrite the class in your CSS file or directly in bootstrap.css with this:

    .modal.fade{
        -webkit-transition: opacity .2s linear, none;
        -moz-transition: opacity .2s linear, none;
        -ms-transition: opacity .2s linear, none;
        -o-transition: opacity .2s linear, none;
        transition: opacity .2s linear, none;
        top: 50%;
    }
    

    If you don't want any effect just remove the fade class from the modal classes.

    0 讨论(0)
  • 2020-12-07 12:41

    I have found the best solution that removes the slide but leaves the fade is by adding the following css in a css file of your chosing which is invoked after the bootstrap.css

    .modal.fade .modal-dialog 
    {
        -moz-transition: none !important;
        -o-transition: none !important;
        -webkit-transition: none !important;
        transition: none !important;
    
        -moz-transform: none !important;
        -ms-transform: none !important;
        -o-transform: none !important;
        -webkit-transform: none !important;
        transform: none !important;
    }
    
    0 讨论(0)
  • 2020-12-07 12:41

    I didn't like the slide effect either. To fix this all you have to do is make the the top attribute the same for both .modal.fade and modal.fade.in. You can take off the top 0.3s ease-out in the transitions too, but it doesn't hurt to leave it in. I like this approach because the fade in/out works, it just kills the slide.

    .modal.fade {
      top: 20%;
      -webkit-transition: opacity 0.3s linear;
         -moz-transition: opacity 0.3s linear;
           -o-transition: opacity 0.3s linear;
              transition: opacity 0.3s linear;
    }
    
    .modal.fade.in {
      top: 20%;
    }
    

    If you're looking for a bootstrap 3 answer, look here

    0 讨论(0)
  • 2020-12-07 12:41

    Wanted to update this. Most of you have not completed this issue. I'm using Bootstrap 3. none of the fixes above worked.

    to remove the slide effect but keep the fade in. I went into bootstrap css and (noted out the following selectors) - this resolved the issue.

     .modal.fade .modal-dialog{/*-webkit-transform:translate(0,-25%);-ms-transform:translate(0,-25%);transform:translate(0,-25%);-webkit-transition:-webkit-transform .3s ease-out;-moz-transition:-moz-transform .3s ease-out;-o-transition:-o-transform .3s ease-out;transition:transform .3s ease-out*/}
    
     .modal.in .modal-dialog{/*-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)*/}
    
    0 讨论(0)
提交回复
热议问题