div 水平居中的一种方法
2016-06-04 21:58
375 查看
<span style="font-size:24px;">水平居中的方法:</span>
<span style="font-size:24px;">1、parent float to left;</span>
<span style="font-size:24px;">2、parent position 相对页面 右移50%,则父类div的做边界为page的中心轴;</span>
<span style="font-size:24px;">3、child relative相对父类标签;</span>
<span style="font-size:24px;">4、child margin padding 0 则child的边界与parent重合,即可以理解为一个</span>
<span style="font-size:24px;">5、child left -50%右边界向左缩进50%,则child和parent就居中了; </span>
.parent{float:left;position:relative;left:50%;}.parent .child{position:relative;margin:0;padding:0;left:-50%;}
<div class="parent"><div class="child">水平居中</div></div>
相关文章推荐
- bool operator==(const Array&)const; 这最后一个const 是做什么用的
- unity android设备上查看log输出
- collectionView(xib)
- 面试题1:类的赋值运算符函数
- 设计模式学习(4)
- 学习笔记之一:学习中好的试题
- Lowest Common Ancestor of a Binary Search Tree
- 游戏编程中的人工智能-遗传算法入门(五)
- Android Studio1.5使用和学习记录
- html列表相关属性
- LeetCode 76. Minimum Window Substring
- Apriori算法的python实现
- Log4j2与JNDI结合
- C++ string类型变量
- JAVA-WEB开发第五讲[2016-06-04]SPRING-MVC环境搭建
- collectionView(手写)
- collectionView(手写)
- 人月神话阅读笔记2
- 赢在职场-WEB全栈开发-1-9 文本样式概览
- 在mac osx 下使用 Jenkins对Android 进行持续集成