尺码问题:< br>与保证金:1em [英] Sizing Question: <br> versus margin: 1em

查看:55
本文介绍了尺码问题:< br>与保证金:1em的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我一直认为1em等于一行高度。但如果我用

$替换


< br>< hr>< br>


b $ b< hr style =" margin:1em 0;"


< hr>上方和下方的表格在IE和FF中越来越近了。


这让我想到了一个问题:什么是< br>,用CSS表示?


*)其他地方没有边距和填充


Axel


PS:这是示例代码我''一直用来测试效果:


< html>

< body>

< table border = 1> ;< tr>< td> a< / td>< / tr>< / table>

< br>< hr>< br>

< table border = 1>< tr>< td> b< / td>< / tr>< / table>

< / body>

< / html>


------------------------------ ---------------


< html>

< body>

< table border = 1>< tr>< td> a< / td>< / tr>< / table>

< hr style =" margin:1em 0" ;>

< table border = 1>< tr>< td> b< / td>< / tr>< / table>

< / body>

< / html>

Hi,

I always thought that "1em" equals one line height. But if I replace

<br><hr><br>

by

<hr style="margin: 1em 0;">

tables above and below the <hr> get closer in IE as well as FF.

This brings me to the question: What''s a <br>, expressed in CSS*?

*) with no margins and padding defined elsewhere

Axel

PS: Here''s the sample code I''ve been using to test the effect:

<html>
<body>
<table border=1><tr><td>a</td></tr></table>
<br><hr><br>
<table border=1><tr><td>b</td></tr></table>
</body>
</html>

---------------------------------------------

<html>
<body>
<table border=1><tr><td>a</td></tr></table>
<hr style="margin: 1em 0">
<table border=1><tr><td>b</td></tr></table>
</body>
</html>

推荐答案

" Axel Dahmen" < NO ***** @ NoOneKnows.invalid>写道:
"Axel Dahmen" <NO*****@NoOneKnows.invalid> wrote:
我一直以为1em等于一行高度。


不,它等于字体的高度。行高通常是稍微大一点,通常大约1.15倍。

但如果我更换
< br>< hr>< ; br>
< hr style =" margin:1em 0;"

< hr>上方和下方的表格在IE和FF中越来越近了。


当然,由于< br> s

第一个例子没有任何文本行可以被某些浏览器删除将忽略< br> s

,因此第二个例子将创建更大的空格。对于< hr>还有不同的默认边距大小的可能性。在

不同的浏览器中。所以你真的不喜欢比较像。

这让我想到了一个问题:什么是< br>,用CSS *表示?
I always thought that "1em" equals one line height.
No, it equals the height of the font. The line-height is normally a
little bit larger, typically about 1.15 times larger.
But if I replace
<br><hr><br>
by
<hr style="margin: 1em 0;">

tables above and below the <hr> get closer in IE as well as FF.
Of course as there are no lines of text to be broken by the <br>s the
first example it''s possible that some browsers will ignore the <br>s
and hence the second example will create larger spaces. There''s also
the possibility of different default margin sizes for <hr> in
different browsers. So you''re not really comparing like with like.
This brings me to the question: What''s a <br>, expressed in CSS*?




没什么。 <峰; br>是一个换行符。有一个CSS可以控制元素

可以插入换行符的位置,但是根据定义,换行符没有大小或

其他可以设置样式的元素。


史蒂夫


-

我的理论给你起见,我的异端邪说你,

我从不回信,你也不喜欢我的领带。 - 医生


Steve Pugh< st *** @ pugh.net> < http://steve.pugh.net/>



Nothing. <br> is a line break. There''s CSS to control where an element
can insert line breaks but line breaks by definition have no size or
anything else that could be styled.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don''t like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>


2005年1月31日星期一00:18:15 +0100,Axel Dahmen

< NO ***** @ NoOneKnows.invalid>写道:
On Mon, 31 Jan 2005 00:18:15 +0100, "Axel Dahmen"
<NO*****@NoOneKnows.invalid> wrote:
我一直以为1em等于一行高度。


否;这是错的。

http://www.css.nu/articles/typograph1-en.html#Ch22
http://www.css.nu/articles/typograph1-en.html#Ch23

但如果我更换
< br>< hr>< br>

< hr style =" margin:1em 0;">
表格<<小时>在IE和FF中越来越近了。


是的;什么发生可能是正确的取决于各种价值

属性的分配。

这带给我一个问题:什么是< br>,用CSS *表示?


加价为例如


< p> Hello< span> World< / span>< / p>


样式规则...


p> span:before {content:" \A" }


建议将文字呈现为......


你好

世界

http://www.w3.org/ TR / CSS21 / generate .... ropdef-content


没有为空BR元素生成框,之后有

没有什么可以暗示的。一个BR元素只是打破了一条线,它在标记中的位置,与线条完全相同

如果已经足够长的话就被打破了不适合包含

元素。

PS:这是我用来测试效果的示例代码:
I always thought that "1em" equals one line height.
No; that''s wrong.

http://www.css.nu/articles/typograph1-en.html#Ch22
http://www.css.nu/articles/typograph1-en.html#Ch23
But if I replace
<br><hr><br>
by
<hr style="margin: 1em 0;">
tables above and below the <hr> get closer in IE as well as FF.
Yea; whatever "happens" is probably correct depending on various value
assignments to properties.
This brings me to the question: What''s a <br>, expressed in CSS*?
markup as e.g.

<p>Hello<span>World</span></p>

style rule...

p>span:before { content: "\A" }

suggestst rendering of the text as...

Hello
World

http://www.w3.org/TR/CSS21/generate....ropdef-content

There is no box generated for the empty BR element, following that there
is nothing to suggest a style for. A BR element merely breaks a line at
it''s location in markup, in exactly the same way as the line would have
been broken anyway had it been long enough not to fit in its containing
element.
PS: Here''s the sample code I''ve been using to test the effect:




你应该为我们提供你的测试用例的URL。


-

Rex



You are supposed to produce a URL for us where you have your test case.

--
Rex


Steve Pugh< st *** @ pugh.net>写道:
Steve Pugh <st***@pugh.net> wrote:
我一直以为1em等于一行高度。
不,它等于字体的高度。
I always thought that "1em" equals one line height.
No, it equals the height of the font.




的确如此。这里有什么困难是字体的高度意味着什么,但我们

可以在本次讨论中跳过它。

行高通常是
稍微大一点,通常大约1.15倍。



Indeed. What''s difficult here is what the height of the font means, but we
can hopefully skip that in this discussion.
The line-height is normally a
little bit larger, typically about 1.15 times larger.




我会说1.2更接近典型的浏览器默认值。 CSS 1在HTML的默认样式表中建议使用1.1

,CSS 2表示1.33,CSS 2.1草案用于

表示1.12em(与1.12不同,真的)但后来固定为

1.12。令人困惑,不是吗?对于大多数常用的字体,1.12太小了

小。


遗憾的是没有办法让行高取决于浏览器'' s

字体的实际选择(可以受到影响,但不受控制,由

作者样式表)。这让我觉得行高:1.25一般是

最少的邪恶。


但是当设置两个连续表之间的间距时,这样的

考虑因素不需要扮演任何角色。只需为第一个表设置合适的底部

保证金,或者为第二个表设置合适的顶部保证金。

如果你绝对必须尽力在之间创建_some_空格在非CSS浏览情况下,两个

表,放< p>& nbsp;< / p>最简单的方法可能是

。 (根据HTML规范,浏览器需要忽略

尝试 - 假设我们将构造解释为空段,

这有点值得商榷 - 但我们知道他们不知道什么都不做。

复杂。)


-

Yucca, http://www.cs.tut.fi/~jkorpela/


这篇关于尺码问题:&lt; br&gt;与保证金:1em的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆