margin外边距问题
2015-08-01 15:41
423 查看
1 、上下边距会叠加
2、父级包含子级的时候,子级的margin-top会传递给父级,可以使用父级的padding替代自己的margin。
3、margin左右
margin-lefta:uto 偏右
margin-right:auto 偏左
margin:auto 水平居中
!DOCTYPE html> <html> <head> <m<etacharset="UTF-8"> <title></title> <style> .box1{ width:500px; height:300px; background: blue; margin-bottom:30px; } .box2{ width:300px; height:100px; background:#ffff00; margin-top:30px; } </style> </head> <body> <divclass="box1"></div> <divclass="box2"></div> </body> </html>
2、父级包含子级的时候,子级的margin-top会传递给父级,可以使用父级的padding替代自己的margin。
<!DOCTYPE html> <html> <head> <metacharset="UTF-8"> <title></title> <style> .box1{ width:500px; height:300px; background: blue; } .box2{ width:300px; height:100px; background:#ffff00; margin-top:30px; } </style> </head> <body> <divclass="box1"> <divclass="box2"></div> </div> </body> </html>
3、margin左右
margin-lefta:uto 偏右
margin-right:auto 偏左
margin:auto 水平居中
相关文章推荐
- Swing 中各种提示框的工具类
- webstrom 安装教程 配置js调试
- 【练习笔记】剑指offer-面试题7 :用两个栈实现队列
- JS 解析JSON
- Single Number(找出只出现了一次的数,其它数都出现两次)
- c# ConcurrentQueue
- [odroid-pc] ubuntu12.04 安装jdk-6u45-linux-x64.bin
- HDU5313——DP+vector——Bipartite Graph
- qt学习第四课:子类化窗口
- java之ArrayList的toArray方法
- centos6.5下postgres-XC集群安装与配置
- zookeeper无法正常启动问题
- 编程修养(二)
- MongoDB使用java代码实现增删改查
- hdu 5120 Intersection
- android异步线程
- MySQL 存储过程游标错误
- HDU5317——素数筛——RGCDQ
- eclipse 导入 v7包
- 虚拟化