首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

求帮忙改下代码,为啥层的位置重叠

2013-09-05 
求帮忙改下代码,为什么层的位置重叠!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN ht

求帮忙改下代码,为什么层的位置重叠

<!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>


</body>
</html>

热点排行