css在IE6,IE7里显示不同

来源:百度知道 编辑:UC知道 时间:2024/05/12 11:16:06
初学CSS,DIV,写了一个网站,在不同的浏览器里,位置不一样,IE6正常,IE7错位,FF里也不对。请教高手应该怎么改。

网站网址:
http://www.vop1.cn

部分CSS代码,网站不让写太多
@charset "utf-8";
#box {
width: 916px;
margin-right: auto;
margin-left: auto;
margin-top: 0px;
margin-bottom: 0px;
height: auto;
}
#top2right {
float: right;
}
#top2zuo {
float: left;
}
#top2 {
background-image: url(img/top2d.jpg);
background-repeat: repeat-x;
height: 25px;
}
#main {
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
height: auto;
}
#maintop {
text-align: center;
background-image: url(img/maintopd.jpg);
background-repeat: no-repeat;
height: 44px;
width: 871px;
background-position: 23px;
}
#main-m-right {
float: right;
height:

你在样式里加上div{overflow:hidden}样式那三个浏览器就一样了

对应Firefox的话,相应属性前什么都不加,如:
height: 37px;

对应IE7的话,相应属性前加上“*”,如:
*height: 37px;

对应IE6的话,相应属性前加上“_”,如:
_height: 37px;

需要注意的是,书写的顺序一定要是firefox的写在前面,IE7的写在中间,IE6的写在最后面。

例如:
background:orange;*background:green;_background:blue;
就是在Firefox下背景橘黄色,IE7下绿色,IE6下蓝色。

另外也有一些别的方法(如!important),不过这个方法已经很通用并且足够用了。
想学的话Google查“Firefox IE 6 7”,相关文章一大堆。