Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.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 背景图像高度100%_Html_Css - Fatal编程技术网

Html 背景图像高度100%

Html 背景图像高度100%,html,css,Html,Css,我试图将背景图像放在一个div的中心,我把它放在另一个div中,然后从那里将其居中,但因为我希望高度为100%,所以无法显示。我尝试添加float:left;但是,即使我将左右边距设置为“自动”,div也不会居中 我怎样才能使背景图像达到100%?我刚刚发现了这个,它似乎工作得很好 margin:0px auto 0 auto; position:relative; min-height: 100%; /* min. height for modern browser */ height:aut

我试图将背景图像放在一个div的中心,我把它放在另一个div中,然后从那里将其居中,但因为我希望高度为100%,所以无法显示。我尝试添加float:left;但是,即使我将左右边距设置为“自动”,div也不会居中


我怎样才能使背景图像达到100%?

我刚刚发现了这个,它似乎工作得很好

margin:0px auto 0 auto; position:relative;
min-height: 100%; /* min. height for modern browser */
height:auto !important; /* important rule for modern Browser */
height:100%; /* min. height for IE */
overflow: hidden !important; /* FF scroll-bar */
background:url(../images/con-background.gif) 0 0 repeat-y; }

对于现代浏览器,您只需使用:

background-size: cover; 

要定位背景图像<代码>背景位置:居中。为了确保背景覆盖容器的整个高度<代码>背景大小:自动100%你的问题不具体。我看到你找到了一个让你满意的解决方案,但是如果你想帮助别人解决你的问题,你应该更好地指定它。