下面来介绍一下关于css hack来解决一些多浏览器中不兼容的问题介绍。
IE6 | IE7 | Firefox2+ | Firefox3+ | Opera9.5+ | Safari3.1+ | |
---|---|---|---|---|---|---|
选择符{ *属性:值; }[1] |
√ | √ | × | × | × | × |
选择符{ _属性:值; } |
√ | ×[2] | × | × | × | × |
选择符,x:-moz-any-link{ 属性:值; } |
× | √ | √ | √ | × | × |
选择符,x:-moz-any-link,x:default{ 属性:值; } |
× | √ | × | √ | × | × |
@media all and (min-width:0){ 选择符{属性:值;} }[3] |
× | × | × | × | √ | √ |
@media all and (-webkit-min-device-pixel-ratio:0){ 选择符{属性:值;} }[4] |
1] 此处的*号其实也可以是.号、>号、+号和#号。但它们都不属于CSS2.1规范合法属性名的一部分,所以不能通过验证。
[2] 当IE7为quriks mode时和IE6为quriks mode解析相同,所以此时这个表达式在IE7中也能生效。这个hack已经应用了很久了,下划线_作为属性名的前缀是符合CSS2.1规范语法的,但不存在于其属性名列表中,所以依旧不能通过标准语法验证。对于多个IE的CSS Hacks,条件注释是一个很值得考虑的解决方案。另外对于IE8可以关注其新功能和变化,但现在考虑其CSS Hacks问题有点过早,真的有需求可以通过增加来解决。
[3] 如果把表达式中的and和(中间的空白去掉变成@media all and(min-width:0){选择符{属性:值;}},那么Safari3+将无法识别,Opera9.5+则可以。
[4] 这个表达式Opera9.0是支持的。
上面这些CSS Hacks仅仅是沧海一粟,是一些简单的通用的CSS Hacks。这个世界上还存在很多很知名很经典的CSS Hacks
在这里我就不介绍了。
国外网站参考
The syntax for conditional comments is as follows:
Positive
代码如下 | 复制代码 |
Negative HTML |
condition is one of the following:
IE
Any version of IE
lt IE version
Versions less than version
lte IE version
Versions less than or equal to version
IE version
Only version version
gte IE version
Versions greater than or equal to version
gt IE version
Versions greater than version
version is the version of Internet Explorer, typically 5, 5.5, 6, or 7
HTML is the HTML to be included if the condition does or doesn't match, depending on the type of conditional comment. When included, the HTML is placed right where the conditional comment is in the source.
For negative conditions,
代码如下 | 复制代码 |
can be replaced with --> |
if the condition is simply IE. The longer version is only needed when Internet Explorer might parse the contents.
The directive is not available in XML, so it is illegal to use it in XHTML. A solution would be to split it up into two special conditional comments: XHTML where XHTML is the same both places. Note that Internet Explorer 7 and below don't yet recognize XHTML as a form of XML, so this is merely forward-looking.
Conditional comments as a CSS hack
Up
Conditional comments can be used as a CSS hack by including links to stylesheets based on the layout engine. Here is an example of how stylesheets can be separated in this way:
代码如下 | 复制代码 |
Test |
参考地址:http://www.webdevout.net/css-hacks
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔