css选项卡

这是一个使用HTML、CSS和JavaScript创建的交互式页面,用户可以通过点击问题列表来显示不同的选择题板块,如水果、蔬菜和肉类的选择。页面布局使用了浮动元素和颜色样式进行美化,同时通过JavaScript监听点击事件来切换显示的内容区块。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!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>
        *{
            margin:0;
            padding: 0;
            list-style-type: none;
        }
        #all{
            width: 600px;
            height:600px;
            margin:0 auto;
            background-color: pink;
        }
        ul>li{
            width: 198px;
            height:100px;
            float:left;
            background-color: rgb(62, 194, 220);
            border: 1px yellow solid ;
            font-size: 30px;
            color:pink;
            text-align: center;
            padding-top:25px;
        
        }
        #box1{
            float:left;
            width: 600px;
            height: 473px;
            background-color: rgb(150, 232, 203);
            display: none;
            font-size: 30px;
            color: white;
            text-align: center;
            padding-top: 30px;
            line-height:80px;
        }
        #box2{
            float:left;
            width: 600px;
            height: 473px;
            background-color: rgb(168, 233, 94);
            display: none;
            font-size: 30px;
            color: white;
            text-align: center;
            padding-top: 30px;
            line-height:80px;
        }
        #box3{
            float:left;
            width: 600px;
            height: 473px;
            background-color: rgb(223, 135, 231);
            display: block;
            font-size: 30px;
            color: white;
            text-align: center;
            padding-top: 50px;
            line-height:80px;
            
        }
        #all>ul>li.active{
            background-color: yellow;}


    </style>z
</head>
<body>
    <div id = 'all'>
        <ul>
            <li id="list1">问题一</li>
            <li id="list2">问题二</li>
            <li id="list3">问题三</li>
        </ul>
        <div id = 'next'>
            <div id = "box1" >
                你最喜欢的水果:
                <li> 西瓜:<input id = 'list1' type='checkbox'></li>
                <li> 香蕉:<input id = 'list2' type='checkbox'></li>
                <li> 苹果:<input id = 'list3' type='checkbox'></li>
                <li> 荔枝:<input id = 'list4' type='checkbox'></li>
            </div>

        
            <div id = "box2">
                你最喜欢的蔬菜:
                <li> 青菜:<input id = 'list1' type='checkbox'></li>
                <li> 花菜:<input id = 'list2' type='checkbox'></li>
                <li> 豆芽:<input id = 'list3' type='checkbox'></li>
                <li> 黄瓜:<input id = 'list4' type='checkbox'></li>
            </div>

        
            <div id = 'box3'>
                你最喜欢的肉:
                <li> 鸡肉:<input id = 'list1' type='checkbox'></li>
                <li> 牛肉:<input id = 'list2' type='checkbox'></li>
                <li> 羊肉:<input id = 'list3' type='checkbox'></li>
                <li> 猪肉:<input id = 'list4' type='checkbox'></li>
            </div>

        </div>


    </div>

<script>
    //绑定对象
    var ques1 = document.getElementById('list1')
    var ques2 = document.getElementById('list2')
    var ques3 = document.getElementById('list3')
    var  b1 = document.getElementById('box1')
    var  b2 = document.getElementById('box2')
    var  b3 = document.getElementById('box3')
    //绑定点击事件
    ques1.onclick = function(){
        b1.style.display = 'block';
        b2.style.display = 'none';
        b3.style.display =' none';
    }
    ques2.onclick = function(){
        b2.style.display = 'block';
        b1.style.display = 'none';
        b3.style.display = 'none';
    }
    ques3.onclick = function(){
        b3.style.display = 'block';
        b2.style.display = 'none';
        b1.style.display = 'none';
    }








</script>




</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值