<div id="content" style="background-color: red; height: 100%;">
<div id="object1" style="width: 100%; background-color: green; height: 100px; position:fixed;">
</div>
<div id="object2" style="width: 100%; background-color: blue;height: 100px;" >
</div></div>
我想修复div object1位置固定,object2应该与之分开。没有位置固定一切正常。如何在不使用css的margin和padding属性的情况下实现。
答案 0 :(得分:0)
如何在不使用
margin
和padding
属性的情况下实现这一目标 的CSS。
在position
,height:100%
width:100%
属性和body
,html
html,
body {
height: 100%;
width: 100%;
margin: 0
}
#content {
background-color: red;
height: 100%;
position: relative
}
#object1 {
width: 100%;
background-color: green;
height: 100px;
position: fixed;
}
#object2 {
width: 100%;
background-color: blue;
height: 100px;
position: absolute;
top: 120px;
}
&#13;
<div id="content">
<div id="object1">
</div>
<div id="object2">
</div>
</div>
&#13;