【发布时间】:2016-07-31 09:01:33
【问题描述】:
当我在页面上添加 <!DOCTYPE HTML> 时,我发现我必须将 position: fixed; 添加到 CSS 中才能使图像显示为“div”的背景,否则我会得到一个空白的白色背景。为什么在这种情况下需要 position = fixed?
.background_image{
position: fixed; <-----Why is this needed & Why doesn't static work?
background: #000 url(../Images/Image.jpg) center center;
width: 100%;
height: 100%;
min-height:100%;
background-size: cover;
overflow: hidden;
}
这里是示例 html。 div 中显然还有其他元素,我正在通过标题中的链接导入 css。
<body>
<div class="background_image">
</div>
</body>
【问题讨论】:
标签: html background position