WEB 教程
实践 示例
HTML 参考手册
CSS 参考手册
PHP 参考手册

如何从 Bootstrap 模态窗口中移除滑动效果

主题:Bootstrap / Sass上一页|下一页

答案:从模态窗口中移除 fade

默认情况下,在激活时,Bootstrap 模态窗口会在短暂的向下滑动过渡后显示。 但是,如果您不喜欢这样并想删除动画,只需从 .modal 元素中取出 fade 类。 让我们尝试一个例子来看看它是如何工作的:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Remove Slide Animation from Bootstrap Modals</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
    <!-- 按钮 HTML (触发模态) -->
    <a href="#myModal" class="btn btn-primary btn-lg" data-toggle="modal">Launch Demo Modal</a>
    
    <!-- 模态 HTML -->
    <div id="myModal" class="modal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Confirmation</h5>
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body">
                    <p>Do you want to save changes you made to document before closing?</p>
                    <p class="text-warning"><small>If you don't save, your changes will be lost.</small></p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save changes</button>
                </div>
            </div>
        </div>
    </div>    
</body>
</html>

FAQ 相关问题解答

以下是与此主题相关的更多常见问题解答:

Advertisements