JS基础效果图

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

    <style>

        .box {

            width: 600px;

            height: 500px;

            border: 2px solid black;

            position: relative;

        }

        .box1 {

            width: 200px;

            height: 140px;

            border: 1px solid #ccc;

        }

        .btn {

            position: absolute;

            top: 20px;

            right: 50px;

        }

        p{

            font-size: 20px;

            font-weight: bold;

        }

        .box2{

            width: 240px;

            height: 380px;

            position: absolute;

            top:20px;

            right: 30px;

            display: none;

            background-color: #fff;

            padding: 10px;

        }

        .box3{

            display: flex;

            flex-wrap: wrap;

            justify-content: space-between;

        }

        span{

            width: 80px;

            height: 30px;

            border: 2px solid #ccc;

            line-height: 30px;

            margin-bottom: 10px;

            text-align: center;

        }

    </style>

</head>

<body>

    <div class="box">

        <div class="box1"></div>

        <button class="btn">点击显示div样式</button>

        <div class="box2">

            <p>大小</p>

            <div class="box3">

                <span>300*300</span>

                <span>200*300</span>

                <span>300*200</span>

                <span>100*300</span>

            </div>

            <p>颜色</p>

            <div class="box3">

                <span>red</span>

                <span>yellow</span>

                <span>blue</span>

                <span>pink</span>

            </div>

            <button>确定</button>

            <button>取消</button>

           

        </div>

    </div>

    <script>

         var box=document.getElementsByTagName("div");

         var btn=document.getElementsByTagName("button");

         var ospan=document.getElementsByTagName("span");

         console.log(ospan[0]);

          btn[0].οnclick= function(){

            box[0].style.backgroundColor = '#999999';

            box[2].style.display = "block";

          }

          ospan[0].onmouseover = function(){

            box[1].style.width = '300px'

            box[1].style.height = "300px"

          }

          ospan[1].onmouseover = function(){

            box[1].style.width = '200px'

            box[1].style.height = "300px"

          }

          ospan[2].onmouseover = function(){

            box[1].style.width = '300px'

            box[1].style.height = "200px"

          }

          ospan[3].onmouseover = function(){

            box[1].style.width = '100px'

            box[1].style.height = "300px"

          }

          ospan[4].onmouseover = function(){

            box[1].style.backgroundColor= ospan[4].innerHTML

           

          }

          ospan[5].onmouseover = function(){

            box[1].style.backgroundColor= ospan[5].innerHTML

          }

          ospan[6].onmouseover = function(){

            box[1].style.backgroundColor= ospan[6].innerHTML

          }

          ospan[7].onmouseover = function(){

            box[1].style.backgroundColor= ospan[7].innerHTML

          }

          btn[1].onclick = function(){

            box[0].style.backgroundColor = ""

            box[2].style.display = 'none'

          }

          btn[2].onclick = function(){

            box[0].style.backgroundColor = ""

            box[2].style.display = 'none'

            box[1].style = ""

           

          }

    </script>

</body>

</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值