使用纯css完成选项卡切换

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            h3{
                color: transparent;
                font-size: 60px;
                -webkit-text-stroke: 1px red;
            }
            .tab{
                position: relative;
            }
            .tab>div{
                width: 80px;
                height: 40px;
                line-height: 40px;
                text-align: center;
                float:left;
                /*border: #7CFC00 1px solid;*/
                /*cursor: pointer;*/
                
            }
            
            .tab>div>div{
                width: 320px;
                height: 50px;
                /*border: salmon 1px solid;*/
                position: absolute;
                top: 40px;
                left: 0px;
                display: none;
                
                border-radius: 0px 0px 8px 8px;
            }
            .tab>div:nth-child(1){
                border-radius: 8px 0px 0px 0px;
                background-color: saddlebrown;
            }
            .tab>div:nth-child(2){
                
                background-color: red;
            }
            .tab>div:nth-child(3){
                
                background-color: chartreuse;
            }
            .tab>div:nth-child(4){
                border-radius: 0px 8px 0px 0px;
                background-color: darksalmon;
            }
            
            .tab>div:nth-child(1)>div{
                display: block;
                background-color: saddlebrown;
            }
            .tab>div:nth-child(2)>div{
                display: none;
                background-color: red;
            }
            .tab>div:nth-child(3)>div{
                display: none;
                background-color: chartreuse;
            }
            .tab>div:nth-child(4)>div{
                display: none;
                background-color: darksalmon;
            }
            .tab>div:hover>div{
                display: block;            
            }
            
        </style>
    </head>
    <body>
        <h3>hello world</h3>
        
        
        <div class="tab">
            <div>
                选项卡1
                <div>
                    <span>
                        选项卡1文本...
                    </span>
                </div>
            </div>
            <div>
                选项卡2
                <div>
                    <span>
                        选项卡2文本...
                    </span>
                </div>
            </div>
            <div>
                选项卡3
                <div>
                    <span>
                        选项卡3文本...
                    </span>
                </div>
            </div>
            <div>
                选项卡4
                <div>
                    <span>
                        选项卡4文本...
                    </span>
                </div>
            </div>
            
            
            
        </div>
        
        
        
    </body>
</html>

猜你喜欢

转载自www.cnblogs.com/shangrao/p/12945927.html
今日推荐