Internet Explorer CSS hacks
测试环境:IE6 , IE7, IE8, FF3.0
表达方式:表达方式:
body { `background:red }
body { ~background:red }
body { !background:red }
body { @background:red }
body { #background:red }
body { $background:red }
body { %background:red }
body { ^background:red }
body { &background:red }
body { *background:red }
body { (background:red }
body { )background:red }
body { =background:red }
body { +background:red }
body { [background:red }
body { ]background:red }
body { {background:red }
body { |background:red }
body { ,background:red }
body { <background:red }
body { .background:red }
body { >background:red }
body { /background:red }
body { ?background:red }
结论:IE识别所有CSS Hack 结论:IE识别所有CSS Hack
比如我们要实现在IE 中480px 的宽度,而在其他浏览器500px 的宽度,就可以通过Hack 来完成,如下:比如我们要实现在IE中480px的宽度,而在其他浏览器500px的宽度,就可以通过Hack来完成,如下:
#hack {
width : 500px;
+width : 480px; /*only IE*/
}
相关文档:
1、IE分不清继承关系和父子关系的差别,全部都是继承关系。
2、在给你的标签疯狂加选择符的时候,别忘了在CSS里给选择符加上注释。等你以后修改你的CSS的时候就知道为什么要这么做了。另外提醒您,不要太疯狂了。
3、如果你给一个标签设置了一个深色调的背景图片和亮色调的文字效果。建议这个时候给你的标签再设置一个深 ......
IE6实现方法:
HTML部分:
<imgsrc="..."alt="..."onload="resizeImage(this)"/>
JS部分:
<mce:scripttype="text/javascript"><!--
functionresizeImage(obj){
obj.width=obj.width>50&&obj.width>obj.height?50:auto;
obj.height=obj.height>50?50:auto;
}
// -->&l ......
搜索引擎优化(seo)有很多工作要做,其中对代码的优化是一个很关键的步骤。
为了更加符合SEO的规范,下面是目前流行的CSS+DIV的命名规则:
页头:header
登录条:loginBar
标志:logo
侧栏:sideBar
广告:banner
导航:nav
子导航:subNav
菜单:menu
子菜单:subMenu
搜索:search
滚动:scroll
页面主体:main
内容:con ......
IE都能识别*;标准浏览器(如Firefox,Opera,Netscape)不能识别*;
IE6能识别*,但不能识别 !important,
IE7能识别*,也能识别!important;
FF不能识别*,但能识别!important;
写两句代码来控制一个属性,区别Firefox与IE6:
background:orange;*background:blue; //
这一句代码写出来时,你用firefox或其它非IE浏览时 ......