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

解决方案 »

  1.   

    把div id=01换成div id="abc" 试试
      

  2.   

    发现ID名不能用纯数字,麻烦帮忙修正下这段代码行吗?
    改变背景颜色
    <!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 = getElementById("third");
    test03.style.backgrond-color = "red";
    }
    </script>
    </head><body>
    <div id="first">我是好人</div>
    <div id="second">我是坏人</div>
    <div id="third"><input type="button" value="改变" onclick="change()" /></div>
    </body>
    </html>
      

  3.   


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