首页 > Web开发 > 详细

CSS常用操作——————对齐

时间:2016-05-14 01:13:32      阅读:248      评论:0      收藏:0      [点我收藏+]

一、使用margin属性进行水平对齐   

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

margin:值1 值2

值1代表上下 值2代表左右

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


二、使用position属性进行左右对齐

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


三、使用float属性进行左右对齐

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


CSS常用操作——————对齐

原文:http://11317783.blog.51cto.com/11307783/1773177

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!