适合行高的值 [英] appropriate values for line-height

查看:74
本文介绍了适合行高的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个列表样式:


dl {line-height:1; margin-bottom:1em; }


但是W3C CSS验证器说:


行:124上下文:dl


无效的数字:行高分析错误 - [空字符串]


为什么是1无效?什么是空字符串?


-


Haines Brown,KB1GRM


我有一个列表样式:


dl {line-height:1; margin-bottom:1em; }


但是W3C CSS验证器说:


行:124上下文:dl


无效的数字:行高分析错误 - [空字符串]


为什么是1无效?什么是空字符串?



这是验证器中的错误 - 它认为需要一个单位。如果你将
设为1em而不是1,它将停止抱怨。根据

规格,不需要该装置:
http://www.w3.org/TR/CSS21/visudet.h...ef-line-height

-

Els http://locusmeus.com/

无障碍网页设计: http://locusoptimus.com/


Haines Brown< br **** @ teufel.hartford-hwp.comwrote:


> ;我有一个列表样式:


dl {line-height:1; margin-bottom:1em; }



很难改变线高,不管它。


-

Spartanicus


Scripsit Els:


这是验证器中的错误 - 它认为需要一个单位。如果你将
设为1em而不是1,它将停止抱怨。



但这是一个错误的举动,因为意思不同。原因

是1em的,计算值是继承的,所以如果你改变了元素内部的字体大小,你会遇到问题

。对于纯数字,

数字是继承的,这很好。


设置行高:1不好。这意味着行之间没有间距

,即行的高度是字体的大小(高度),

这通常意味着上行可能触及下行以前的

行。线高的合理值通常从1.2到1.3或者稍高一点,取决于x高度。


-

Jukka K. Korpela(Yucca)
http://www.cs.tut.fi/~jkorpela/



I have a style for a list:

dl { line-height: 1; margin-bottom: 1em; }

But the W3C CSS validator says:

Line: 124 Context : dl

Invalid number : line-height Parse Error - [empty string]

Why is "1" invalid? What "empty string"?

--

Haines Brown, KB1GRM

解决方案

Haines Brown wrote:

I have a style for a list:

dl { line-height: 1; margin-bottom: 1em; }

But the W3C CSS validator says:

Line: 124 Context : dl

Invalid number : line-height Parse Error - [empty string]

Why is "1" invalid? What "empty string"?

It''s an error in the validator - it thinks a unit is needed. If you
make it 1em instead of 1, it will stop complaining. According to the
specs, there is no need for the unit though:
http://www.w3.org/TR/CSS21/visudet.h...ef-line-height
--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/


Haines Brown <br****@teufel.hartford-hwp.comwrote:

>I have a style for a list:

dl { line-height: 1; margin-bottom: 1em; }

Rarely is it smart to alter the line-height, leave it alone.

--
Spartanicus


Scripsit Els:

It''s an error in the validator - it thinks a unit is needed. If you
make it 1em instead of 1, it will stop complaining.

But that would be a wrong move, since the meaning is different. The reason
is that for 1em, the computed value is inherited, so you run into problems
if you ever change font size inside the element. For a pure number, that
number is inherited, which is fine.

Setting line-height: 1 isn''t fine, though. It means that there is no spacing
between lines, i.e. the height of line is the size (height) of the font,
which generally means that ascenders may touch descenders of the previous
line. Reasonable values for line-height are typically from 1.2 to 1.3 or a
little higher, depending on the x-height.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


这篇关于适合行高的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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