css绝对定位问题

 <!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
html,body,div{margin: 0; padding: 0; border:0; }
#out{height: 200px; width: 800px; background: #f00; margin-top: 20px;margin-left: 20px; position:relative;}//红
#mid{height: 100px; width: 600px;background: #0f0; margin-left: 20px; }//绿
#center{height: 60px; width: 300px; background: #00f; position: absolute; top:10px; left: 10px;}//蓝 </style>
</head>
<body>
<div id="out">
  <div id="mid">     <div id="center">
      绝对定位
    </div>
  </div>
</div> </body> </html>

css绝对定位问题

DIV使用绝对定位,其样式left,top等参照标准是从里向外找到第一个position不为static(DIV默认情况下都是static)的DIV为止。假如没有找到,则其参照标准就是BODY

上一篇:爱奇艺2017秋招笔试(C++智能设备方向)


下一篇:org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].Standard