Blogger Information
Blog 9
fans 0
comment 0
visits 7762
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
8月16日用绝对定位做一个十字架
Newf王永庆的博客
Original
730 people have browsed it

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title>绝对定位(其操作一定要人一个干爹,即定位父级),做一个十字架</title>
</head>
<style>
body{
       margin:0;
}

   .box{
       width:300px;
height:300px;
/*background-color:wheat*/
       /*定位父级必须设置他的定位属性,一般在绝对定位中定位父级的时候才会用到相对定位*/
position:relative;

}
   .box1 {
       width: 100px;
height: 100px;
background-color: lightblue;
position:absolute; /*本元素会脱离文档流(正常情况下元素会由左到右,由上到下自然排列)*/
       /* 第二个元素会自动顶替这个位置*/
       /*top:10px;!*相对与body偏离10PX*!
       left:50px;!*相对与body偏离50PX,而不是相对与自身原来位置偏离*!*/
top:0;
left:100px;

}

   .box2 {
       width: 100px;
height: 100px;
background-color: lightgreen;
position:absolute;
top:100px;
left:0;

}

   .box3 {
       width: 100px;
height: 100px;
background-color: lightcoral;
position:absolute;
top:100px;
left:200px;

}

   .box4 {
       width: 100px;
height: 100px;
background-color: lightgrey;
position:absolute;
top:200px;
left:100px;

}
   /*span{
       position:absolute;
       top:200px;
       left:300px;
   }*/


</style>
<body>
<div class="box">
   <div class="box1"></div>
   <div class="box2"></div>
   <div class="box3"></div>
   <div class="box4"></div>
</div>

<span>www.php.cn</span> <!--行内元素-->
</body>
</html>

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post