Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 全宽背景图像限制高度_Html_Css - Fatal编程技术网

Html 全宽背景图像限制高度

Html 全宽背景图像限制高度,html,css,Html,Css,我想得到一个全屏背景图像,但只有宽度,而不是高度,就像 我一直在玩背景尺寸:封面但是它覆盖了整个页面-我只希望覆盖一定的高度。您提到的站点只是在一个div上使用一个标准的背景图像,该div具有固定的高度和宽度:100% 例如,您提到的网站使用: header { height: 460px; margin-top: -69px; overflow: hidden; padding: 0px; width: 100%; } 请注意代码块中的高度,背景图像:cover

我想得到一个全屏背景图像,但只有宽度,而不是高度,就像


我一直在玩
背景尺寸:封面
但是它覆盖了整个页面-我只希望覆盖一定的高度。

您提到的站点只是在一个div上使用一个标准的背景图像,该div具有固定的
高度和
宽度:100%

例如,您提到的网站使用:

header {
   height: 460px;
   margin-top: -69px;
   overflow: hidden;
   padding: 0px;
   width: 100%;
}

请注意代码块中的高度,
背景图像:cover
仅表示缩放背景图像以适应空间。

因此我找到了我想要的:

CSS:

HTML:



谢谢你的帮助

背景尺寸:100%80%
(例如)怎么样 可以更改第二个值,即高度


这是一个。

谢谢,但当我尝试时,图像1。不覆盖屏幕的宽度和2。在左侧留下一个白色条……更好的是,这也可以:
#header-wrapper{
   top: 0;
   left: 0;
   height: auto;
   position: absolute;
   width: 100%;
}
<div id="header-wrapper">
    <img src="image.jpg" width="100%" style="border-bottom:1px solid black;">
</div>