【发布时间】:2015-04-04 09:27:56
【问题描述】:
我有以下 html 和 css。如果我将位置属性从绝对更改为相对,div.raw 似乎在 html 布局中流动,并且背景图像不会覆盖所有内容。如果我不这样做,那么它会这样做。这是为什么呢?
HTML:
<h1 class="push">Hello World</h1>
<div class="container">
Some text
<div class="raw"></div>
</div>
CSS:
.push {
margin-bottom: 50px;
margin-top: 50px;
}
.container {
margin-top: 50px;
width: 500px;
height: 500px;
margin-bottom: 50px;
}
.raw {
border: 1px solid black;
position: absolute;
top: 0;
left: 0;
background-size: auto;
background-image: url("http://st-im.kinopoisk.ru/im/wallpaper/2/3/0/kinopoisk.ru-True-Detective-2300505--w--1280.jpg");
//background-repeat: no-repeat;
overflow: hidden;
width: 50%;
height: 100%;}
【问题讨论】: