您好,欢迎来到百万美食网。
搜索
您的当前位置:首页详解CSS常用操作对齐方法

详解CSS常用操作对齐方法

来源:百万美食网


这篇文章主要为大家详解CSS常用操作对齐方法,感兴趣的小伙伴们可以参考一下

一、使用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;
}

Copyright © 2019- bwgh.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务