div#ipsko 改变宽度和高度以满足绝对定位。为什么 img#utas 没有?
JSFiddle:http: //jsfiddle.net/pejh7/1/
HTML 代码:
<div id="upsko">
<img id="utas" src="http://kharg.czystybeton.pl/108.png" />
<div id="ipsko"></div>
</div>
CSS 代码:
div#upsko {
position: relative;
top: 200px; left: 200px; width: 100px; height: 100px;
background: rgba(255,0,0,0.5);
}
img#utas {
position: absolute;
top: 10px; left: 10px; right: 10px; bottom: 10px;
}
div#ipsko {
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
background: rgba(0,255,0,0.5);
}