Why declare the same CSS parameter twice, but second one with a asterisk? [duplicate]

折月煮酒 提交于 2019-12-24 10:45:17

问题


Possible Duplicate:
CSS reset - purpose of asterik within a style

I was reading through the CSS styles for HTML5BoilerPlate, and I came across this unfamiliar line:

button, input, select, textarea { 
  font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle; 
}

In particular, the second ****vertical-align***, why call twice and put an asterisk in front of it.

If anyone knows the name of the technique or why it's used, it would be a great help

Thanks!

-Adrian


回答1:


It's a nasty hack that can be used to target older versions of IE (other browsers ignore the invalid asterisk-prefixed value). Definitely not a good idea, far better to use IE conditional stylesheets or similar techniques.




回答2:


It's a CSS hack for Internet Explorer browsers:


*property: value

If you add a non-alphanumeric character such as an asterisk (*) immediately before a property name, the property will be applied in IE and not in other browsers. Unlike with the hyphen and underscore method, the CSS specification makes no reservations for the asterisk as a prefix, so use of this hack could result in unexpected behavior as the CSS specifications evolve.

property: value applies the property value in IE 7 and below. It may or may not work in future versions. Warning: this uses invalid CSS.

from here




回答3:


This is a css hack and used to target IE7 browser.

For more reference see How to Target IE6, IE7, and IE8 Uniquely with 4 Characters




回答4:


It's an IE6 hack. If you put the * in front of a CSS attribute, it will only be read by IE6. Since IE6 usage is now down to 1% of the world, we can forget about this hack (unless you live in China)



来源:https://stackoverflow.com/questions/12196390/why-declare-the-same-css-parameter-twice-but-second-one-with-a-asterisk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!