简体   繁体   English

如何防止背景中的图像在模态模式下放大?

[英]How do I prevent the image in the background from zooming in modal mode?

I have 4 pictures and a background image and I wrote a modal for each of them.我有 4 张图片和一张背景图片,我为每张图片都写了一个模态。 When I click on the image and it opens in modal mode, the background image also zooms in a bit.当我单击图像并以模态模式打开时,背景图像也会放大一点。 In chrome dev tools, I see that a new class is added to body called .modal-open and properties and values are added in the css.在 chrome 开发工具中,我看到一个名为 .modal-open 的新类被添加到主体中,并且属性和值被添加到 css 中。

body.modal-open {
padding-right: 16px;
display: block; }


.modal-open .modal {
overflow-x: hidden;
overflow-y: auto; }

Link to Js fiddle链接到 Js 小提琴

How do I prevent the image in the background of the body element from zooming in?如何防止主体元素背景中的图像放大?

CSS CSS

.bg-image {
    background-image: url("Pictures/English-lang-background.jpg");
    background-size: cover;
    overflow: auto;
}

HTML HTML

<body>
<div class="bg-image">

</div>
</body>

Correct, @iamwhitebox.正确,@iamwhitebox。 It solves the problem.它解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何由于背景尺寸(封面)而停止放大背景图像? - How do I stop background-image from zooming in because of background-size: cover? CSS - 防止背景图像在缩小时移动 - CSS - Prevent background image from moving when zooming out 如何在垂直添加元素时防止背景图像在移动浏览器上放大? - How to prevent background-image from zooming on mobile browser when adding elements vertically? 如何防止PHP删除背景图片CSS语句的斜线? - How do I prevent PHP from stripping my Slashes of my background-image CSS statement? CSS:如何防止div的背景色位于其上方的图像后面? - CSS: How do I prevent the background color of div from going behind the image it is sitting above? 如何防止背景色/图像出现在上一行(引导程序) - How do I prevent my background colour/image from appearing in the previous row (bootstrap) 当按ctrl和+时,如何防止Firefox放大? - How do you prevent firefox from zooming in when pressing ctrl and +? 如何在缩小时停止移动背景? - How can I stop background from moving when zooming out? 当背景图像显示为页面背景时,如何防止背景图像放大? - How do you prevent a background image from being zoomed in when it displays as the background for your page? 如何使模式背景可点击? - How do I make the background of a modal clickable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM