關(guān)于寬度的問題
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>相對參照元素進(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{
? ? width:200px;
? ? height:200px;
? ? ? ? ? ?
}
#box4{
? ? width:99%;
?
? ??
}
</style>
</head>
<body>
<div id="box1">
<div id="box2">相對參照元素進(jìn)行定位</div>
</div>
<h1>下面是任務(wù)部分</h1>
<div id="box3">
? ? <img src="http://img1.sycdn.imooc.com//541a7d8a00018cf102000200.jpg">
? ? <div id="box4">當(dāng)我還是三年級的學(xué)生時是一個害羞的小女生。</div>
</div>
</body>
</html>
為什么box4設(shè)置了width=99%,寬度卻沒有屏幕的99%?為什么是box3的寬度的99%?
2016-04-02
因為box3是box4的父元素。
2016-04-02
因為box3是box4父元素