首页 > 其他分享 >导航栏下拉列表/vue/scss/html

导航栏下拉列表/vue/scss/html

时间:2022-11-03 14:25:07浏览次数:56  
标签:scss vue 栏下 name color 30px background height display

效果

 

 

 scss样式

 

html

 

源码

<!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>
    <script type="text/javascript" src="../js/vue.js"></script>
    <link rel="stylesheet" href="../css/index.css" type="text/css"/>
</head>
<body>
    <div id="root">
        <div style="height: 30px;">
            <div class="a">
                <div class="b">
                    下拉列表
                </div>
                <div class="c">
                    <a v-for="(item, index) in x" :key="index">{{item.name}}</a>
                </div>
            </div>
            <div class="a">
                <div class="b">
                    下拉列表
                </div>
                <div v-for="(item, index) in x" :key="index" class="c">
                    <a v-for="(item, index) in x" :key="index">{{item.name}}</a>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        const vm =new Vue({
            el:'#root',
            data() {
                return {
                    x:[
                        {
                            id:1,
                            name:"list1"
                        },
                        {
                            id:2,
                            name:"list2"
                        },
                        {
                            id:3,
                            name:"list3"
                        }
                    ]
                }
            },
        })
    </script>

</body>
</html>
.a{
    width: 100px;
    height: 30px;
    background-color: #fff;
    position: relative;
    display: inline-block;
    .b{
        width: 100px;
        height: 30px;
    }
    .c{
        display: none;
        position:absolute;
        a{  
            width: 100px;
            height: 30px;
            line-height: 30px;
            display: block;
            text-decoration: none;
            background-color: #fff;
        }
    }
}
.a:hover .c{
    display: block;
}
.a:hover .b{
    color: #fff;
    background-color: #000;
}
.c a:hover {
    color: aliceblue;
    background-color: #000;
}
body{
    background-color: #ddd;
}

 

标签:scss,vue,栏下,name,color,30px,background,height,display
From: https://www.cnblogs.com/meetlilanglang/p/16854281.html

相关文章