今天写了一个目录树的js,编写css的时候发现,父标签包含相对定位、padding并且没有浮动时的情况下,子标签的绝对定位位置,在IE下有别于其他浏览器,所以我得写一个针对所有IE的hack,以下是我搜索到的所有关于判断个版本IE的范例。
HTML部分
IE6及其以下版本可见
IE7及其以下版本可见
只有IE6版本可见
非IE版本可见
IE8以下版本可见
IE7及其以上版本可见
CSS部分(hack)
.all IE {
property:value\9;
}
.gte IE 8 {
property:value\0;
}
.lte IE 7{
*property:value;
}
.IE 8/9 {
property:value\0;
}
.IE 9 {
property:value\9\0;
}
.IE 7 {
+property:value;
}
.IE 6 {
_property:value;
}
.not IE {
property//:value;
}
lte:就是Less than or equal to的简写,也就是小于或等于的意思。
lt :就是Less than的简写,也就是小于的意思。
gte:就是Greater than or equal to的简写,也就是大于或等于的意思。
gt :就是Greater than的简写,也就是大于的意思。
! :就是不等于的意思,跟javascript里的不等于判断符相同
其他浏览器的Hack
[syntaxHighLighter brush="css"]/* hack Webkit: Chrome / Safari */
@media screen and (-webkit-min-device-pixel-ratio:0) { ... }
/* hack Opera */
media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) { ... }
/* hack Firefox */
@-moz-document url-prefix() { ... }[/syntaxHighLighter]