相對定位問題
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>absolute樣式</title>
<style type="text/css">
#div1{
? ? width:200px;
? ? height:200px;
border:2px red solid;
??
? ??
}
#div2{
? ? ? ? width:400px;
? ? ? ? height:300px;
? ? ? ? border:1px blue solid;
? ? ? ? position:relative;
? ? ? ? top:200px;left:100px;
? ? }
</style>
</head>
<body>
<div id="div2">
<div id="div1">div1</div>
</div>
</body>
</html>
這是代碼,我給div2設(shè)置定位,嵌套里面的div1也跟隨移動,為什么
2015-07-23
肯定移動啊,因為你div1是嵌套在div2中的,就相當(dāng)于他們是一個整體,而你div2設(shè)置相對定位后,就有一定的偏移,div1會跟著移動的
2015-09-27
你這個沒嵌套吧