日期:2014-05-16  浏览次数:20360 次

求帮忙改下代码,为什么层的位置重叠
<!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=gb2312" />
<title>练习0829</title>
<style>
#01 {
position:absolute;
left: 305px;
top: 17px;
}
#Layer1 {
position:absolute;
width:200px;
height:115px;
}
#Layer2 {
position:absolute;
width:200px;
height:115px;
left: 11px;
top: 165px;
background:#00FF00;
}
</style>
</head>

<body>
<div id="Layer2"></div>
<div id="Layer1">我是坏人</div>
<div id="01">我是好人</div>
</body>
</html>

------解决方案--------------------
把div id=01换成div id="abc" 试试
------解决方案--------------------

<!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=gb2312" />
<title>练习0829</title>
<style>
#first {
position:absolute;
width:200px;
height:115px;
top: 15px;
margin:0px auto;
padding:
}
#second {
position:absolute;
left: 300px;
top: 15px;
}
#third {
position:absolute;
width:200px;
height:115px;
left: 11px;
top: 165px;
background:#00FF00;
}
</style>
<script type="text/javascript">
function change(){
var test03 = document.getElementById("third");
test03.style.backgroundColor = "red";
}
</script>
</head>

<body>
<div id="first">我是好人</div>
<div id="second">我是坏人</div>
<div id="third"><input type="button" value="改变" onclick="change()" /></div>