有没有办法防止缩放页面时调整背景图像的大小?

发布于 2024-11-24 16:57:58 字数 66 浏览 8 评论 0原文

背景图像只是一个简单的图案,在 100% 的情况下看起来效果最好。 有没有办法防止在缩放页面时调整此类背景图像的大小?

The background-image is just a simple pattern that looks best at 100%.
Is there a way to prevent such a background-image from being resized when zooming the page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦醒灬来后我 2024-12-01 16:57:58

缩放是浏览器功能,它只是放大您在浏览器中看到的所有内容,因此您无法保持图像大小固定

zoom is browser feature and it's just enlarge everything you see in your browser so there is nothing you can do to keep the size of the images fixed

久而酒知 2024-12-01 16:57:58

您可能可以尝试将图像拉入 HTML 文档:

<div id="bg-img">
    <img src="images/bg-img.jpg">
</div>

然后继续使用 CSS,您可以将以下样式应用于保存图像的 div:

#bg-img{
    min-height: 100%;
    min-width: 1024px;
    width: 100%;
    height: auto;
    position: fixed;
    top: 0;
    left: 0;
    z-index:-4;
 }

上面的样式集将设置您的图像以很好地适应任何浏览器并防止背景图像的大小或扩大到大约 3 倍的缩放。请务必填写适当的最小宽度值,以便在调整浏览器大小时,图像将通过调整大小或裁剪来保持正确的比例。

you could probably try pulling in an image into your HTML document instead:

<div id="bg-img">
    <img src="images/bg-img.jpg">
</div>

then going on to your CSS, you could apply the following style to that div holding the image:

#bg-img{
    min-height: 100%;
    min-width: 1024px;
    width: 100%;
    height: auto;
    position: fixed;
    top: 0;
    left: 0;
    z-index:-4;
 }

the above style set will set your image to fit nicely into any browsers and prevent the background-image from resizing or expanding up to about 3 times of the zoom. be sure to fill in the appropriate value for the min-width so that in the event that the browser is resized, the image will maintain the correct proportion by resizing or cropping off.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文