relative與absolute的運(yùn)用
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>相對(duì)參照元素進(jìn)行定位</title>
<style type="text/css">
div{border:2px red solid;}
#box1{
? ? width:200px;
? ? height:200px;
? ? position:relative;
? ? ? ? ??
}
#box2{
? position:absolute;
top:20px;
left:30px;
? ? ? ? ??
}
/*下面是任務(wù)部分*/
#box3{
? ? height:200px;
? ? width:200px;
? ? position:relative;
? ??
? ??
}
?#box4{
? ? ?width:99%;
? ? ?position:absolute;
? ? ?bottom:0;
? ? ?left:0px;
?} ??
?
</style>
</head>
<body>
<div id="box1">
<div id="box2">相對(duì)參照元素進(jìn)行定位</div>
</div>
<h1>下面是任務(wù)部分</h1>
<div id="box3">
? ? <img src="http://img1.sycdn.imooc.com//541a7d8a00018cf102000200.jpg">
? ? <div id="box4">當(dāng)我還是三年級(jí)的學(xué)生時(shí)是一個(gè)害羞的小女生。</div>
</div>
</body>
</html>
為什么bottom是0啊,不是向上移動(dòng)嗎
2018-04-17
是把”當(dāng)我還是按年級(jí)的....“移到圖片的低位,也就是說box4相對(duì)于box3來說,是接觸到底部,所以bottom為0
2018-04-22