简体   繁体   English

将保证金底部设置为em值可以吗?

[英]Is it OK to set margin-bottom to em value?

I want to set a margin-bottom:1em so that it's relative to whatever the font size is. 我想将margin-bottom:1em设置为相对于任何字体大小而言的。

W3C just says it can be px, but this site shows em as well. W3C只是说它可以是px,但此网站也显示了em。

This will be in an email newsletter so I want it to have broad rendering support. 这将在一封电子邮件通讯中,因此我希望它具有广泛的渲染支持。

I don't know where you've read that W3C says you can only use px , because that's not true. 我不知道您在哪里读到W3C说您只能使用px ,因为那不是事实。 W3C clearly states in the newest CSS Snapshot from 2010 : W3C在2010年的最新CSS快照中明确指出:

The properties defined in this section refer to the value > type, which may take one of the following values: 本节中定义的属性引用value> type,它可以采用以下值之一:

<length> Specifies a fixed width. <length>指定固定宽度。
<percentage> The percentage is calculated with respect to the width of the generated box's containing block. <percentage>相对于生成的盒子的包含块的宽度计算百分比。 Note that this is true for 'margin-top' and 'margin-bottom' as well. 请注意,“ margin-top”和“ margin-bottom”也是如此。 If the containing block's width depends on this element, then the resulting layout is undefined in CSS 2.1. 如果包含块的宽度取决于此元素,则结果布局在CSS 2.1中未定义。
auto See the section on calculating widths and margins for behavior. auto请参见有关计算行为的宽度和边距的部分。

This means you can use anything of the <length> type, meaning em, ex, in, cm, mm, pt, pc or px, or you can use a percentage. 这意味着您可以使用<length>类型的任何内容,即em,ex,in,cm,mm,pt,pc或px,也可以使用百分比。

CSS Values and Units Module Level 3 introduces even more units. CSS值和单位模块3级引入了更多单位。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM