效果
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