day7-作业

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            *{
                position: relative;
                margin: 0;
                padding: 0;
            }
            #top{
                width: 600px;
                height: 200px;
                /*background-color: blue;*/
                margin-left: auto;
                margin-right: auto;
                margin-bottom: 10px;
            }
            #top #left{
                float: left;
                width: 250px;
                height: 200px;
                background-color: red;
            }
            #top #left img{
                width: 250px;
                height: 200px;
            }
            #top #right{
                float: right;
                width: 250px;
                height: 200px;
                background-color: gold;
            }
            #top #right img{
                width: 250px;
                height: 200px;
            }
            #bottom{
                width: 600px;
                height: 600px;
                background-color: green;
                margin-left: auto;
                margin-right: auto;
            }
            #bottom img{
                width: 600px;
                height: 600px;
            }
        </style>
    </head>
    <body>
        <div id="top">
            <div id="left"></div>
            <div id="right"></div>

        </div>
        <div id="bottom"></div>
    </body>
</html>
<script type="text/javascript">
    var imgArray = ["img/01.jpg","img/03.jpg"]
    var leftNode = document.getElementById('left')
    var rightNode = document.getElementById('right')
    var imgNode = document.createElement('img')
    imgNode.src = imgArray[0]
    var imgNode1 = document.createElement('img')
    imgNode1.src = imgArray[1]
    leftNode.appendChild(imgNode)
    rightNode.appendChild(imgNode1)
    
    var bottomNode = document.getElementById('bottom')
    leftNode.onclick = function(){
        var imgNode = document.createElement('img')
        imgNode.src = imgArray[0]
        bottomNode.innerHTML = null
        bottomNode.appendChild(imgNode)
    }
    rightNode.onclick = function(){
        var imgNode = document.createElement('img')
        imgNode.src = imgArray[1]
        bottomNode.innerHTML = null
        bottomNode.appendChild(imgNode)
    }   
</script>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1.编写一个函数,求1+2+3+...+N 结果 2.编写一个函数,求多个数中的最大值 结果 3.编写一一个函数,...
    旧时初_2e8d阅读 201评论 0 4
  • 1.写一个程序 a.用一个变量来保存一个班级的学生信息,学生信息:姓名、学号、成绩(英语、体育、美术、数学)、年龄...
    HavenYoung阅读 298评论 0 2
  • 给出一个列表:numbers = [23, 45, 78, 32, 90, 89, 123, 155, 121] ...
    魅影_0d2e阅读 213评论 0 0
  • 学生管理系统 代码如下:
    C0mpass阅读 214评论 0 0
  • 相信每一个使用微信的你都收到过甚至自己也发过这样的消息吧。 我从使用微信到现在陆陆续续的类似于这样的消息已经收到上...
    植草人阅读 793评论 0 3