gpt4 book ai didi

javascript - Bootstrap 4 : modal rendering issue with zoomed in body

转载 作者:太空宇宙 更新时间:2023-11-04 06:15:37 27 4
gpt4 key购买 nike

我正在尝试使用主体放大 90% 的 Bootstrap html 页面。Bootstrap 模式显示右侧和底部的空格。为了显示这个问题,我在 body 90% 缩放时放置了一个带有模态的基本 html 页面。

当您单击打开的模态框时,您将看到模态框右侧和底部的空格。我们如何渲染模态框而不使用额外的空格,主体缩放 90%。所需的输出是模态模糊背景应覆盖整个屏幕。 . 模态主体应该位于 x 轴的中心,就好像缩放 90% 和 100% 一样,只是缩放 90% 是小字体

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body style="zoom:90%;">

<div class="container">
<!-- Button to Open the Modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Open modal
</button>
<!-- The Modal -->
<div class="modal fade" id="myModal">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<!-- Modal body -->
<div class="modal-body">
Modal body..
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

最佳答案

类 .modal-backdrop 使用 100vh 和 100vw,因为我们应用了 90% 缩放,100vh 对应于屏幕高度的 90%; 100vw对应屏幕宽度的90%;

解决方案:用width: 100%覆盖这个类;高度:100%;

.modal-backdrop {
width: 100% !important;
height: 100% !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<body style="zoom:90%;">

<div class="container">
<h1> with zoom 90%
</h1>
<!-- Button to Open the Modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Open modal
</button>
<!-- The Modal -->
<div class="modal fade" id="myModal">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<!-- Modal body -->
<div class="modal-body">
Modal body..
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>

关于javascript - Bootstrap 4 : modal rendering issue with zoomed in body,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55988523/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com