首页 文章

Bootstrap模态:如何淡入,但在关闭时立即消失

提问于
浏览
0

参考Bootstrap 3模态:http://getbootstrap.com/javascript/#modals

我在外部模态div上使用 class="modal fade" 来创建Bootstrap模态的默认淡入/淡出效果 . 但我真正想做的就是淡入淡出,但不会淡出 . 我希望模式在按下关闭按钮时立即完全消失,没有任何延迟的CSS转换 .

How can I remove the CSS transition when the modal gets closed, but keep it when the modal gets opened?

2 回答

  • 1

    为"shown.bs.modal"事件添加处理程序,并在该处理程序中删除 fade 类 .

    $('#myModal').on('shown.bs.modal', function (e) {
      $('#myModal').removeClass('fade');
    });
    

    然后不会发生由 fade 类定义的转换 .

  • 0

    您可以删除 .fade 类并找到另一种实现淡入的方法,例如使用jQuery转换,这样就可以避免强行覆盖Bootstrap .

相关问题