组合使用自动外边距和文本对齐
这始终是个hack(为兼容地域IE6的浏览器),无论如何也算不上完美。
body {
text-align: center;
}
#container {
margin-left: auto;
margin-right: auto;
width:200px;
text-align:left;
}
负外边距解决方案
Entomology用到的代码:
#container{
background: #ffc;
position: absolute;
left: 50%;
width: 760px;
margin-left: -380px;
}
没任何hack!适用性极广——Netscape 4.x中都没问题,不是首选,但是想得到广泛浏览器支持,这是最好的选择。
“CSS hack和破碎的页面的灭绝”——Internet Explorer条件注释
… …
我们请求你更新页面,让它们不再使用CSS hack。如果你仍然想锁定IE或者忽略IE,请使用条件注释。
——Markus Mielke(http://blogs.msdn.com/ie/archive/2005/10/12/480242.aspx)
制备Windows版本的Internet Explorer支持的条件注释,提供了一个简洁的途径去锁定或者忽略Internet Explorer,只需将注释放在XHTML文档的<head>部分。
例如,要为所有的浏览器提供一系列通用的规则,而仅为所有版本的Internet Explorer提供一系列特殊的规则,可以用这个:
<link rel=”stylesheet” type=”text/css” href=”standa-rds.css” />
<!–[if IE]>
<link rel=”stylesheet” type=”text/css” href=”ie.css” />
<![endif]–>
锁定IE5或者IE6
<!–[if IE 5]>
<link rel=”stylesheet” type=”text/css” href=”ie5.css” />
<![endif]–>
<!–[if lte IE 6]>
<link rel=”stylesheet” type=”text/css” href=”ie6.css” />
<![endif]–>
当许多漏洞和错误在Internet Explorer 7中被修正,同时条件注释在XHTML中成为可行的时候,条件注释开始很快地流行起来。
转的PJhome.的。这个东东的网上版本N多,可是Pj大叔给上色了,这样才有用,要不看不明白。转的目的是我自己需要时看啦。嘿嘿。
区别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;
注:不管是什么方法,书写的顺序都是firefox的写在前面,IE7的写在中间,IE6的写在最后面。
Recent Comments