gpt4 book ai didi

html - 背景图像作为固定背景

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

我不知道为什么我的背景图片没有显示。我在开发工具中看不到图像,我很困惑。它在文件夹中并指向正确的文件夹。任何帮助表示赞赏!这是我的代码:

html:

 <body>
<div class="l-head-backImage"></div>

<div class="container">
<header>
<h1>This is the Header</h1>
</header>
</div><!-- container -->

CSS:

  .l-head-backImage {
background: url(../images/Seattle.svg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

最佳答案

您是在告诉它覆盖 div;但是,div 没有实际大小,因为它没有内容。因此,您需要指定 div 的宽度和高度,这样图像才能真正覆盖一些东西。

带有您的代码和随机狗图片的示例:JS Fiddle

CSS

 .l-head-backImage {
background: url(../images/Seattle.svg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 300px;
width: 300px;
}

关于html - 背景图像作为固定背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22678021/

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