掉到坑里

<< 下雪了 | 首页 | 纪念点金堂 >> 读书笔记之CSS hack - [ Development ] 2007-12-14 版权声明 :转载时请以超链接形式标明文章原始出处和作者信息及 本声明 http://fallenlord.blogbus.com/logs/12021597.html 最近又在翻《CSS网站布局实录》,虽然是第二版了,但错别字多的。。。。让人以为是盗版书。。 以下是它的CSS hack的内容以及我平时的一些总结 (1)@import @import url( " somestyle.css " ); 带引号的地址不能被IE4及以下浏览器识别 @import url("somestyle.css") screen ; 由于加上了screen,这条语句不能被IE识别 (2)注释 #someid /**/ { background: red; } 这段代码无法被IE5及以下版本IE识别,注意注释之间不能有空格 (3)属性选择符 input [type=radio] {margin:10px;} 属性选择符是CSS2的标准,IE6及以下版本IE无法识别。这条语句的意思是选择所有type=radio的input元素 提示:如果在html中设定一个属性,则可以利用选择符来进行全局的浏览器hack。例如 <html xmlns=" http://www.w3.org/1999/xhtml " > 然后使用选择符[xmlns]作为顶级元素来进行全局性区别,代码如下: [xmlns] #someid {background:red} 这段代码在IE6及以下版本IE下不会起作用 (4)子对象选择符 div > p {background:red;} /*Mozilla, Firefox, IE7可执行*/ 等同于 div p {background:red;} 但IE6及其以下版本无法解析子对象选择符 (5)voice-family voice-family是CSS针对残疾人使用设备进行特别设置的一个方法,可以指定网页中的内容使用哪种声音进行朗读。有两种用法 #someid { background: red; /* IE6, Mozilla, Firefox可见*/ voice-family: ""}""; voice-family: inherit; background:blue; /*IE5.5及以下IE版本可见*/ } #someid { background: red; /*IE5.5及以下IE版本可见*/ voice-family: "\"}\""; voice-family: inherit; background: blue; /*IE6,Mozilla,Firefox可见*/ } (6)+ hack #someid { background:red; + background:blue; /*IE可执行*/ } (7)_hack #someid { background:red; +background:blue; /*IE6,IE7可执行*/ _ background:black; /*IE6可执行*/ } (8)IE条件注释 <!--[if IE]-->此内容仅IE可见<![endif]--> <!--[if IE 6.0]-->此内容仅IE 6.0可见<![endif]--> <!--[if IE 7.0]-->此内容仅IE 7.0可见<![endif]--> <!--[if IE 5.1000 ]-->此内容仅IE 5.1可见<![endif]--> <!--[if ! IE 5.0]-->此内容除了IE5.0以外的IE都可见<![endif]--> <!--[if gt IE 5]-->此内容IE 5.0以上版本IE可见<![endif]--> 中间带的东西意义如下: gt 大于 gte 大于等于 lte 小于等于 注意这个不是写在CSS代码块里面的,而是写在HTML代码中的,正确的写法应该是 <!--[if IE 7.0]--> <style type="text/css"> #someid {...} </style> <![endif]--> (9)!important 很多地方都说!important对IE是无效的,这是一个半错误的认识,!important对IE7和Firefox有效,对IE6写在同一个CSS块中无效,例如 #div1 {background:red !important ; background:blue;} 以上代码在IE6下显示为blue #div1 {background:red !important ;} #div1 {background:blue;} 以上代码在IE6下显示为red (10)filter hack + !important 这个。。夜深了,懒得写了。。大家自己看看原文吧 http://www.ibloomstudios.com/articles/the_ie7_css_hack/ Tag: CSS hack ie firefox ff 引用地址: fallenlord 发表于 00:35 | 编辑 | 继续话题 | 转发 | 推荐 发表评论

原始快照:web.archive.org