这是字体:速记属性语法有效? (我的规格说是肯定的,但是我安装的一半浏览器不同意。) [英] Is this font: shorthand property syntax valid? (My reading of the spec says yes, but half of my installed browsers disagree.)

查看:112
本文介绍了这是字体:速记属性语法有效? (我的规格说是肯定的,但是我安装的一半浏览器不同意。)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这有效吗? font:bold 10px / 13px inherit;



根据我的阅读

它似乎在Internet Explorer 8(8.0.6001.18702)中正常工作。



在Windows的Safari 5.0.4(7533.20.27)中,它可以正常工作。

Opera 11.01 1190)和Firefox 3.6.16都记录有关它的错误。



我还没有尝试过Chrome或Firefox 4。



如果确实应该这样做的话,这个解析错误是一个已知的问题吗?



一些额外的分数:


  • W3验证器也报告这是无效的。

  • 没有任何'font:bold 10px inherit;','font:bold 10px / 13px;'或'font:bold 10px;'在firefox中正常工作。 >


更新

正如Adam Wagner所指出的他的答案我的企图值实际上是无效的(尽管我的天真阅读规范建议),由于CSS2.1规范§C.3.1。

解决方案

我认为这个问题是与继承的价值增加。
$ b

根据规格:

[[<'font-style'> || <'font-variant'> || <'font-weight'>]? <'font-size'> [/<'line-height'>]? <'font-family'>]
|标题
|图标
|菜单
|消息框
|继承



我认为上面列出的粗体部分是一个选项,caption,icon,menu,message-box和inherit

总之,尝试:font:bold 10px / 13px

更新:



看来webkit在这个问题上有一个突出的bug报告。不知道关于Firefox。 ( https://bugs.webkit.org/show_bug.cgi?id=20181

另外,在票中有人提到,2.1规范解决了这个问题:

速记属性取一个子属性值的列表或值继承,不能将继承与其他子属性值混合在一起,因为不可能指定应用继承的子属性,一些简写属性的定义没有强制执行这个规则:border-top,border-right,border-bottom,border-left,border,background,font,list-style,cue,和大纲。



http://www.w3.org/TR/CSS21/changes.html#q142


Is this valid? font: bold 10px/13px inherit;

According to my reading of the specs that should mean a font-weight of 'bold', a font-family of 'inherit', a font-size of '10px', and a line-height of '13px'.

It appears to work correctly in Internet Explorer 8 (8.0.6001.18702).

It works correctly in Safari 5.0.4 (7533.20.27) on Windows.

Opera 11.01 (build 1190) and Firefox 3.6.16 both log errors about it.

I haven't tried Chrome or Firefox 4 yet.

If this is indeed supposed to be valied is this parsing bug a known issue?

A couple extra points:

  • The W3 validator also reports this as being invalid.
  • None of 'font: bold 10px inherit;', 'font: bold 10px/13px;', or 'font: bold 10px;' work correctly in firefox here either.

Update

As pointed out by Adam Wagner in his answer my attempted value is in fact not valid (despite what my naive reading of the spec suggested) due to § C.3.1 of the CSS2.1 spec.

解决方案

I think the issue is with the "inherit" addition to your value.

Per the specs:

[ [ <'font-style'> || <'font-variant'> || <'font-weight'> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'> ] | caption | icon | menu | message-box | inherit

I think the bold section I listed above is one option, and "caption", "icon", "menu", "message-box", and "inherit" are the remaining options.

In short, try: font: bold 10px/13px

Update:

It appears webkit has an outstanding bug report on this very problem. Not sure about firefox. (https://bugs.webkit.org/show_bug.cgi?id=20181)

Also, as someone in the ticket mentions, the 2.1 spec addresses this:

"Shorthand properties take a list of subproperty values or the value 'inherit'. One cannot mix 'inherit' with other subproperty values as it would not be possible to specify the subproperty to which 'inherit' applied. The definitions of a number of shorthand properties did not enforce this rule: 'border-top', 'border-right', 'border-bottom', 'border-left', 'border', 'background', 'font', 'list-style', 'cue', and 'outline'."

http://www.w3.org/TR/CSS21/changes.html#q142

这篇关于这是字体:速记属性语法有效? (我的规格说是肯定的,但是我安装的一半浏览器不同意。)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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