gpt4 book ai didi

css - 将 "max-width"设置为较大设备的背景图像

转载 作者:太空宇宙 更新时间:2023-11-04 03:35:11 24 4
gpt4 key购买 nike

我已将背景图片设置为 div,但我不希望它的宽度超过 1600 像素。例如,如果它在宽度超过 1600px 的设备上显示,我不希望背景图像覆盖整个宽度。有什么办法可以实现吗?

这是我目前拥有的。无论设备有多宽,图像都会覆盖整个宽度。我需要它的宽度停在 1600 像素处。

div {
background: url("img/bg.jpg") no-repeat center top #067AB4;
background-size: cover;
}

最佳答案

在您的 CSS 文件中使用以下代码:

@media (min-width: 1600px) {
div {
background: url("img/bg.jpg") no-repeat center top #067AB4;
background-size: 1600px 100%;
}
}

关于css - 将 "max-width"设置为较大设备的背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25664446/

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