CSS常用操作-对齐

 

 

index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>对齐</title>
     <link href="style8.css" type="text/css" rel="stylesheet">
</head>
<body>
     <div class="div">
         
     </div>
</body>
</html>

 

利用margin属性

css:

*{
    margin:0px;
}
.div{
    width:70%;
    height:1000px;
    background-color: red;
    margin-left:auto;
    margin-right:auto;
}

 

利用position属性

css:

 1 *{
 2     margin:0px;
 3 }
 4 .div{
 5     width:70%;
 6     height:1000px;
 7     background-color: red;
 8     position:absolute;
 9     right:0px;/*居右操作*/
10 }

 

利用float属性

css

*{
    margin:0px;
}
.div{
    width:70%;
    height:1000px;
    background-color: red;
    float:left;/*向左浮动,对齐*/
}

 

posted @ 2016-08-10 14:14  UniqueColor  阅读(292)  评论(0编辑  收藏  举报