转载过来的.没仔细找原始的地方.
在当前IE6 IE7 FifeFox三分天下的情况下,浏览器兼容性问题成为网页设计者需要考虑的问题.
区别不同浏览器的CSS hack写法:
区别IE6与FF:
background:orange;*background:blue;
区别IE6与IE7:
background:green !important;background:blue;
区别IE7与FF:
background:orange; *background:green;
区别FF,IE7,IE6:
background:orange;*background:green !important;*background:blue;
注:IE都能识别*;标准浏览器(如FF)不能识别*;
IE6能识别*,但不能识别 !important,
IE7能识别*,也能识别!important;
FF不能识别*,但能识别!important;
| |
IE6 |
IE7 |
FF |
| * |
√ |
√ |
× |
| !important |
× |
√ |
√ |
——————————————————
另外再补充一个,下划线”_”,
IE6支持下划线,IE7和firefox均不支持下划线。
于是大家还可以这样来区分IE6,IE7,firefox
: background:orange;*background:green;_background:blue; 更多……
Continue reading »
May 12
js代码如下:
<script language=”javascript”>
var obj;
function onover(target){
target.style.backgroundColor=”#FF0000″;
}
function onout(target){
target.style.backgroundColor=”#FFFFFF”;
}
function ondown(target){
if(obj!=null){
obj.style.backgroundColor=”#FFFFFF”;
obj.onmouseover=obj.over;
obj.onmouseout=obj.out;
obj.onclick=obj.down;
}
target.style.backgroundColor=”#0000FF”;
target.over=target.onmouseover;
target.out=target.onmouseout;
target.down=target.onclick;
target.onmouseover=null;
target.onmouseout=null;
target.onclick=null;
obj=target;
}
</script>
网页代码: 更多……
Continue reading »
May 11
IE6下默认的字体尺寸大致在 12 - 14px 之间,当试图定义一个高度小于这个默认值的 div 的时候, IE 会固执的认为这个层的高度不应该小于字体的行高。所以即使你用 height: 6px; 来定义了一个 div 的高度,实际在 IE 下显示的仍然是一个 12 px 左右高度的层。
要解决这个问题,可以强制定义该 div 的字体尺寸,或者定义 overflow 属性来限制 div 高度的自动调整。
比如 <div style=”height: 6px; font: 0px Arial;”></div>
或者 <div style=”height: 6px; overflow: hidden;”></div>
都可以阻止 IE 的自作聪明。
该问题在 IE7 / Firefox /Opera 下均不存在。