gpt4 book ai didi

html - 背景图像不显示

转载 作者:太空宇宙 更新时间:2023-11-04 05:57:38 26 4
gpt4 key购买 nike

我尝试使用 CSS 显示背景图像,但图像不显示。我正在做与 w3schools.com 完全相同的事情, 但它不起作用。

如何显示整个页面的背景图片?

codepen

div {
background-image: url('https://imgur.com/a/Fql6rTU');
background-repeat: no-repeat;
}
<div>
</div>

最佳答案

1.当您在分区中显示图像时使用background-size: cover所以thaat图像完全覆盖了这个部门然后试着提到heightwidth部门的。

2.您为图片提供了错误的 URL 并更正它,它就会起作用。希望这就是您要找的东西

div {
height: 100vh;
width: 100vw;
background-image: url('https://i.imgur.com/kkQFh8p.jpg');
background-size: cover;
background-repeat: no-repeat;
}
<div>
</div>

关于html - 背景图像不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57638270/

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