以三川 2021-04-30 14:44 采纳率: 0%
浏览 26

今天的练习我只把页面写出来了,剩下的三点我实在是想不出来了,救救我救救我救救我[face]emoji

今天的练习我只把页面写出来了,剩下的三点我实在是想不出来了,救救我救救我救救我[face]emoji:010.png[/face][face]emoji:010.png[/face][face]emoji:010.png[/face]
  • 写回答

1条回答 默认 最新

  • xiaxingfeng 2021-04-30 16:42
    关注
    <!DOCTYPE html>
    <html>
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <link rel="stylesheet" href="">
        <script src=""></script>
    </head>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        li {
            list-style: none;
        }
        
        .box {
            width: 300px;
        }
        
        .box li {
            width: 25%;
            height: 30px;
            text-align: center;
            line-height: 30px;
            float: left;
            background-color: #6A8E24;
            color: #fff;
        }
        
        .box li:hover {
            background-color: #7F7F02;
        }
        
        div {
            width: 300px;
            height: 300px;
            color: #fff;
            line-height: 300px;
            font-size: 30px;
            display: none;
            text-align: center;
            background-color: #7F7F02;
        }
        
        .div1 {
            display: block;
        }
    </style>
    
    <body>
        <ul class="box">
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
        </ul>
        <div>内容1</div>
        <div>内容2</div>
        <div>内容3</div>
        <div>内容4</div>
    </body>
    <script>
        var lis = document.querySelectorAll('li');
        var divs = document.querySelectorAll('div')
        for (let i = 0; i < 4; i++) {
            lis[i].onmouseover = function() {
                for (m = 0; m < 4; m++) {
                    divs[m].className = '';
                }
                divs[i].className = 'div1'
            }
        }
    </script>
    
    </html>
    评论

报告相同问题?