CSS margin合并
2024-10-19 03:25:38
外边距合并
块的顶部外边距和底部外边距有时被组合(折叠)为单个外边距,其大小是组合到其中的最大外边距
发生外边距合并的三种基本情况
1. 相邻的兄弟姐妹元素
<div id="margin_parent"> CSS #margin_parent{ |
2. 块级父元素与其第一个/最后一个子元素
margin-top:块级父元素和其第一个子元素会发生上外边距合并
margin-bottom:块级父元素与它的最后一个子元素会发生下边距合并,要求:父元素没有border、padding、inline content、height、min-height、max-height等
<div id="margin_parent"> CSS #margin_parent{ |
3. 空块元素
如果存在一个空的块级元素,其border、padding、inline content、height、min-height都不存在。那么此时它的上下边距中间将没有任何阻隔,此时它的上下外边距将会合并
<p style="margin-bottom: 0px;background-color:green;">这个段落的和下面段落的距离将为50px</p> |
参考
https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing
最新文章
- app使用微信支付成功后,点击返回到该app却跳到另外一个app去了
- CodeForces Round#313
- Linux启用和配置Java
- [ 转 ] scrapy 中解决 xpath 中的中文编码问题
- [Android Pro] Test win
- ember.js:使用笔记2-数据删除与存储
- ajax教程完整版
- sql compact 使用EF无法更新的问题?
- Linux内存点滴:用户进程内存空间
- 奇妙的算法之LCS妙解
- Java基础----Java---集合框架---泛型、泛型方法、静态方法泛型、泛型接口、泛型限定、泛型类
- python3+selenium入门06-浏览器操作
- day 27 Python中进程的操作
- 适用于 Windows 的自定义脚本扩展
- 洛谷P3302 森林
- 丑女贝蒂第一至四季/全集Ugly Betty迅雷下载
- 7个华丽的基于Canvas的HTML5动画
- 安装Android模拟器
- #leetcode刷题之路31-下一个排列
- 初探C#
热门文章
- datatable转换为list<;model>; 映射
- Git配置信息相关命令
- Codeforces 1043F(容斥+dp)
- steps/train_sat.sh
- 网易云课堂《JS原创视频教程-知识点类》
- tmux 简单介绍
- sonar排除实体类配置
- Python os.removedirs() 和shutil.rmtree() 用于删除文件夹
- centos6.9安装crontab
- (转!)利用Keras实现图像分类与颜色分类