選項(xiàng)卡開發(fā)作業(yè)

作業(yè)標(biāo)題

選項(xiàng)卡開發(fā)

使用工具

VsCode

代碼如下

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>選項(xiàng)卡</title>
    <style>
        *{margin: 0;padding: 0;box-sizing: border-box;}
        html,body{
            height: 100%;width: 100%;
        }
        html{
            font-size: 10px;
        }
        .tab{
            width: 40rem;
            height: 30rem;
            border: solid 1px #000;
        }
        .tab-title{
            width: 100%;
            height: 5rem;
            background-color:antiquewhite;
            border-bottom: solid 2px orange;

            display: flex;
            justify-content: space-between;
            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: calc(100% - 5rem);
            background-color: aquamarine;
            position: relative;
        }

        .tc{
            width: 100%;
            height: 100%;
            font-size: 1.8rem;
            text-align: center;
            color: white;
            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">標(biāo)題1</div>
            <div class="tt">標(biāo)題2</div>
            <div class="tt">標(biāo)題3</div>
        </div>
        <div class="tab-content">
            <div class="tc active">內(nèi)容部分1</div>
            <div class="tc">內(nèi)容部分2</div>
            <div class="tc">內(nèi)容部分3</div>
        </div>
    </div>

    <script>
        let tts=document.getElementsByClassName("tt")
        for(let i=0;i<tts.length;i++){
            tts[i].onmouseenter=function(){
                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>

網(wǎng)頁(yè)效果如下


選項(xiàng)卡1.png

選項(xiàng)卡2.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容