abstract:<style> #qq { text-align:center; } .bb { background-color: #4CAF50; color: white; padding:
<style> #qq { text-align:center; } .bb { background-color: #4CAF50; color: white; padding: 16px; font-size: 16px; border: none; cursor: pointer; } .aa { position:absolute; display: inline-block; float:left; } .cc { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); } .cc a { color: black; padding: 12px 16px; text-decoration: none; display: block; } .cc a:hover {background-color: #f1f1f1} .aa:hover .cc { display: block; } .aa:hover .bb { background-color: #3e8e41; } </style> </head> <body id="qq"> <div class="aa" align="center"> <button class="bb">下拉菜单</button> <div class="cc"> <a href="#">下拉菜单 1</a> <a href="#">下拉菜单 2</a> <a href="#">下拉菜单 3</a> </div> </div>
Correcting teacher:天蓬老师Correction time:2019-04-13 16:40:18
Teacher's summary:.cc a:hover {background-color: #f1f1f1}
.aa:hover .cc {
display: block;
}
.aa:hover .bb {
background-color: #3e8e41;
}
这几个hover是实现效果的关键代码 , 实现这种下拉效果, 有很多方式, 其实用的最多最通用的还是用js方式