margin-bottom
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
Summary
语法
css
/* values */
margin-bottom: 10px; /* 一个绝对的长度值 */
margin-bottom: 1em; /* A length relative to the text size */
margin-bottom: 5%; /* A margin relative to the nearest block container's width */
/* Keyword values */
margin-bottom: auto;
/* Global values */
margin-bottom: inherit;
margin-bottom: initial;
margin-bottom: unset;
值
形式语法
示例
HTML
html
Box 0
Box 1
Box one's negative margin pulls me up
CSS
用于设置 div
的 margin-bottom
和 height
的 CSS 代码
css
.box0 {
margin-bottom: 1em;
height: 3em;
}
.box1 {
margin-bottom: -1.5em;
height: 4em;
}
.box2 {
border: 1px dashed black;
border-width: 1px 0;
margin-bottom: 2em;
}
为了使 margin
产生的影响更明显,添加了一些 container
和 div
的样式定义
css
.container {
background-color: orange;
width: 320px;
border: 1px solid black;
}
div {
width: 320px;
background-color: gold;
}
规范
Specification |
---|
CSS Box Model Module Level 3 # margin-physical |