2025-03-29

<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        html,
        body {
            width: 100%;
            height: 100%;

        }

        html {
            font-size: 10px;
        }

        .tab {
            width: 40rem;
            height: 30rem;
            border: soild 1px #000;
        }

        .tab-title {
            width: 100%;
            height: 5rem;
            background-color: antiquewhite;
            border-bottom: solid 2px orange;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .tt {
            flex: 1;
            height: 5rem;
            background-color: #fff;
            font-size: 1.8rem;
            text-align: center;
            line-height: 5rem;
        }

        .tt.active,
        .tt:hover {
            background-color: orange;
            color: white;
            ;
        }

        .tab-content {
            width: 100%;
            height: 25rem;
            background-color: aquamarine;
            position: relative;
        }

        .tc {
            width: 100%;
            height: 100%;
            font-size: 1.8rem;
            text-align: center;
            color: black;
            position: absolute;
            display: none;
        }

        .tc.active {
            display: block;
        }

        .tc:nth-of-type(1) {
            background-color: blue;
        }

        .tc:nth-of-type(2) {
            background-color: green;
        }

        .tc:nth-of-type(3) {
            background-color: red;
        }
    </style>
</head>

<body>
    <div class="tab">
        <div class="tab-title">
            <div class="tt active">标题1</div>
            <div class="tt">标题2</div>
            <div class="tt">标题3</div>


        </div>
        <div class="tab-content">
            <div class="tc active">笨蛋唐钰婷1号</div>
            <div class="tc">笨蛋唐钰婷2号</div>
            <div class="tc">笨蛋唐钰婷3号</div>
        </div>
    </div>
    <script>
        let tts = document.getElementsByClassName("tt")
        console.log(tts)
        for (let i = 0; i < tts.length; i++) {
            console.log(tts[i])
            tts[i].onmouseenter = function () {
                console.log("鼠标进入了编号为", i, "的标题")

                for (let j = 0; j < tts.length; j++) {
                    tts[j].classList = "tt"
                }
                tts[i].classList = "tt active"
                let tcs = document.getElementsByClassName("tc")
                for (let x = 0; x < tcs.length; x++) {
                    tcs[x].classList = "tc"
                }
                tcs[i].classList = "tc active"
            }
        }
    </script>

</body>

</html>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 《春日游,杏花吹满头》 “春日游,杏花吹满头。”在这个风软花香的季节里,我踏入了那片杏花林,赴一场与春天的约会。 ...
    珍妮317阅读 48评论 0 2
  • 回家:永不褪色的温暖 钥匙在锁孔里转动时,门“吱呀”一声开了,一股陈旧又熟悉的气息扑面而来。这是爸妈的房子,我已经...
    桃语兮阅读 20评论 0 1
  • 稻盛和夫: 一个人的做人做事 遇事: 从自己身上找问题,一想就通; 从别人身上找原因,一想就疯; 高度不一样,胸怀...
    邑小轶阅读 59评论 0 1
  • 投射我儿读书明理,修身做人,每天情绪平和稳定,阳光快乐,越来越会调节自己的情绪和压力。 投射我儿成为更好的自己,多...
    花开生两面阅读 30评论 0 0
  • 这段时间的感受确实是不同,每天晚上都得计划第二天的事情,我也因此感受到了小小的成就感 对于贾老师,他开始对我不讲情...
    而立2687阅读 21评论 0 1