IE和Firefox下Div背景颜色的问题

来源:互联网 发布:php 聊天室 设计思路 编辑:程序博客网 时间:2024/05/02 04:42
 

网站重构时,在遨游浏览器下调试,所以没有感觉有什么问题。使用IE7和Firefox打开却发现最外层Div的背景颜色不起作用.

由于最外div的高度是根据内层div的高度自动伸展,所以不能在css中定义它的高度,这样看起很不美观。分析了一下,在最外层div的css中加了一个overflow:hidden;,再刷新页面,竟然正常了

================index.html========================================================

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="index.css" rel="stylesheet" type="text/css" />


</head>

<body>
<div id="" style="width:700px;">
<div class="left1" style="width:14%;float:left;text-align:center;">Facility Name</div>
<div class="left1" style="width:14%; float:left;text-align:center;">Abreviation</div>
<div class="left1" style="width:10%; float:left;text-align:center;">First</div>
<div class="left1" style="width:10%; float:left;text-align:center;">Last</div>
<div class="left1" style="width:20%; float:left;text-align:center;">Phone Number</div>
<div class="left1" style="width:10%; float:left;text-align:center;">Active</div>
<div class="all1" style="width:10%; float:left;text-align:center;">EMail</div>
<div class="right1" style="width:10%; float:left;text-align:center;">Edit</div>



<div style="width:700px;overflow:hidden; float:left;" onmouseout="this.style.backgroundColor='#FFFFFF';" onmouseover="this.style.backgroundColor='#FFFF55';">
<div class="left2"   style="width:14%;float:left;text-align:left;">g</div>
<div class="left2" style="width:14%; float:left;text-align:left;">gsd</div>
<div class="left2" style="width:10%; float:left;text-align:left;">g</div>
<div class="left2" style="width:10%; float:left;text-align:left;">g</div>
<div class="left2" style="width:20%; float:left;text-align:left;">g</div>
<div class="left2" style="width:10%; float:left;text-align:center;">g</div>
<div class="all2" style="width:10%; float:left;text-align:center;">g</div>
<div class="right2" style="width:10%; float:left;text-align:center;">g</div>
</div>


<!--onmouseout="this.style.backgroundColor='#FFFFFF';" onmouseover="this.style.backgroundColor='#FFFF55';"-->
<div class="background" style="width:700px; overflow:hidden; float:left;" onmouseout="this.style.backgroundColor='#ECFFEC';" onmouseover="this.style.backgroundColor='#FFFF55';">
<div class="left2 " style="width:14%;float:left;text-align:left;">g</div>
<div class="left2 " style="width:14%; float:left;text-align:left;">g</div>
<div class="left2 " style="width:10%; float:left;text-align:left;">g</div>
<div class="left2 " style="width:10%; float:left;text-align:left;">g</div>
<div class="left2 " style="width:20%; float:left;text-align:left;">g</div>
<div class="left2 " style="width:10%; float:left;text-align:center;">g</div>
<div class="all2 " style="width:10%; float:left;text-align:center;">gsadf</div>
<div class="right2 " style="width:10%; float:left;text-align:center;">gd</div>
</div>



</div>

</body>
</html>

=========================================index.css===============================

@charset "utf-8";
* {
}
.right1{
    border-top:1px solid #a1a1a1;
    border-right:1px solid #a1a1a1;
    border-bottom:1px solid #a1a1a1;
    background-image: url(Img/header_bg.gif);
    background-repeat: repeat-x;
    color: #FFF;
    font:15px/20px Arial;

}
.left1{border-top:1px solid #a1a1a1;border-left:1px solid #a1a1a1;border-bottom:1px solid #a1a1a1;color: #FFF;
background-image: url(Img/header_bg.gif);background-repeat: repeat-x;font:15px/20px Arial;}
.all1{border:1px solid #a1a1a1;background-image: url(Img/header_bg.gif);background-repeat: repeat-x;color: #FFF;
font:15px/20px Arial;}

.right2{border-right:1px solid #a1a1a1;border-bottom:1px solid #a1a1a1; }
.left2{border-left:1px solid #a1a1a1;border-bottom:1px solid #a1a1a1;}
.all2{border-right:1px solid #a1a1a1; border-left:1px solid #a1a1a1;border-bottom:1px solid #a1a1a1;}

.background{background:#ECFFEC;}
tr{/*background:#FFFF55;*/
event:expression(onmouseover = function(){this.style.backgroundColor='#FFFF55'},onmouseout = function(){this.style.backgroundColor='#ECFFEC'});

}

====================================================================


原创粉丝点击