定位的基本思想:定义元素框相对于其正常位置应该出现的位置,或者相对于父元素、另一个元素或浏览器窗口本身的位置。
position属性值:static、relative、absolute、fixed。
以下所有测试在Firefox40.0下进行。
所用到基本代码:
1 2 body{ 3 margin: 30px 0 0 30px; 4 padding: 0; 5 } 6 .div1{ 7 width: 200px; 8 height: 200px; 9 padding: 50px;10 background: red;11 }12 .div2{13 width: 50px;14 height: 50px;15 background-color: blue;16 }17 .div3{18 background-color: pink;19 width: 80px;20 height: 50px;21 }22 .div4{23 background-color: gray;24 width: 80px;25 height: 50px;26 }27
1 2div2
查看更多关于CSS相对定位、绝对定位_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did109217