From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/css/margin-bottom/index.html | 187 +++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 files/zh-cn/web/css/margin-bottom/index.html (limited to 'files/zh-cn/web/css/margin-bottom') diff --git a/files/zh-cn/web/css/margin-bottom/index.html b/files/zh-cn/web/css/margin-bottom/index.html new file mode 100644 index 0000000000..5705d9d2dc --- /dev/null +++ b/files/zh-cn/web/css/margin-bottom/index.html @@ -0,0 +1,187 @@ +--- +title: margin-bottom +slug: Web/CSS/margin-bottom +tags: + - CSS + - CSS属性 + - 参考 +translation_of: Web/CSS/margin-bottom +--- +
{{CSSRef}}
+ +

Summary

+ +

The effect of the CSS margin-bottom property on the element box

+ +

CSS的 margin-bottom 属性用于设置元素的底部外边距,允许设置负数值。一个正数值将让它相对于正常流与邻近块更远,而负数值将使得更近。

+ +

该属性对于不可替代(non-replaced 元素在规范中有概念,请自行搜索)的行级元素没有效果,比如: {{HTMLElement("tt")}} 或者 {{HTMLElement("span")}}.

+ +

{{cssinfo}}

+ +

语法

+ +
/* <length> 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;
+
+ +

+ +
+
<length>
+
定义了一个确定的宽度值,参见 {{cssxref("<length>")}} 以了解更多可能的值。
+
<percentage>
+
{{cssxref("<percentage>")}} 始终与包含该元素的容器宽度有关。
+
auto
+
由浏览器自己选择一个合适的值。参见 {{cssxref("margin")}}。
+
+ +

正式语法

+ +
{{csssyntax}}
+ +

样例

+ +

HTML

+ +
<div class="container">
+<div class="box0">Box 0</div>
+<div class="box1">Box 1</div>
+<div class="box2">Box one's negative margin pulls me up</div>
+</div>
+ +

CSS

+ +

用于设置 div margin-bottom height 的 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 的样式定义

+ +
.container {
+    background-color:orange;
+    width:320px;
+    border:1px solid black;
+}
+div {
+    width:320px;
+    background-color:gold;
+}
+ +

{{ EmbedLiveSample('Example',350,200) }}

+ +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
规范状态注释
{{SpecName('CSS3 Box', '#margin-bottom', 'margin-bottom')}}{{Spec2('CSS3 Box')}}无明显变化
{{SpecName('CSS3 Transitions', '#animatable-css', 'margin-bottom')}}{{Spec2('CSS3 Transitions')}}margin-bottom 定义为可动画化
{{SpecName('CSS2.1', 'box.html#margin-properties', 'margin-bottom')}}{{Spec2('CSS2.1')}}移除了对内联元素的影响
{{SpecName('CSS1', '#margin-bottom', 'margin-bottom')}}{{Spec2('CSS1')}}初始定义
+ +

浏览器兼容性

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support1.0{{CompatGeckoDesktop("1")}}3.03.51.0 (85)
auto value1.0{{CompatGeckoDesktop("1")}}6.0 (strict mode)3.51.0 (85)
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support1.0{{CompatGeckoMobile("1")}}6.06.01.0
+
-- cgit v1.2.3-54-g00ecf