gpt4 book ai didi

css - 背景图片不适合浏览器的整个宽度?

转载 作者:行者123 更新时间:2023-11-28 05:33:44 25 4
gpt4 key购买 nike

这是我的代码:

#content{
background-image: url('../images/hero.jpg');
background-size: cover;
background-repeat: no-repeat;
width:100%;
height: 550px;
}

为什么它不适合100%宽度和覆盖的屏幕?

最佳答案

您在#content 上设置了 100% 的宽度,而不是在背景上。试试这个:

#content {
background: url('/images/bg.png') no-repeat center center fixed;

-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

关于css - 背景图片不适合浏览器的整个宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38354078/

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