我觉得此题的意思是,给已知div设置fixed. D答案才对。
html:
<body>
<div class="div1">已知div元素</div>
<div class="x">X元素</div>
</body>
css:
<style>
div{width:200px;margin: 0;padding: 0;}
div.div1{height:35px;background: pink;position: fixed; }
div.x{background: green;margin: 15px 0 0;height: 40px;}
</style>
html:
<body>
<div class="div1">已知div元素</div>
<div class="x">X元素</div>
</body>
css:
<style>
div{width:200px;margin: 0;padding: 0;}
div.div1{height:35px;background: pink;position: fixed; }
div.x{background: green;margin: 15px 0 0;height: 40px;}
</style>
1:margin:0 auto;top:0;
2.position:fixed;top:0;
3.margin-top:62px;
OK
2.position:fixed;top:0;
3.margin-top:62px;
OK