html css二级导航栏
二级导航栏制作:
1.将一级导航栏去除列表样式(list-style:none),并给予浮动,使其横向排列(float:left)
2.给每个li中添加一个<a></a>标签,给a设置样式,使其成为块级元素( display:block),这样只需要点击当前 li 范围区域即可触发a的跳转
3.给需要添加二级导航栏的li里面添加 ul>li ,给个类名,设置其样式为(display:none),使其在普通情况下隐藏
4.设置一级导航栏划过效果,当滑到有二级导航栏的 li 时,设置二级导航栏状态为(display:block),即为显示状态
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <!-- <link rel="stylesheet" href="./../common/common.css"> --> <title>Document</title> <style> *{ margin: 0; padding: 0; } ul,li{ list-style: none; } .one{ width: 600px; background-color: coral; height: 30px; margin: 0 auto; } .one li{ float: left; width: 100px; text-align: center; line-height: 30px; } .one li:hover{ background-color: #fff; color: coral; } .one .two{ display: none; } .one li:hover .two{ display: block; } .one .two li{ background-color: cadetblue; } .one .two li:hover{ background-color: honeydew; } a{ display: block; text-decoration: none; } </style> </head> <body> <ul class="one"> <li><a href="">一级</a> </li> <li><a href="">一级</a> </li> <li><a href="">一级</a> <ul class="two"> <li><a href="">二级</a> </li> <li><a href="">二级</a> </li> <li><a href="">二级</a> </li> </ul> </li> <li><a href="">一级</a> </li> <li><a href="">一级</a> </li> <li><a href="">一级</a> </li> </ul> </body> </html>
相关推荐
jiedinghui 2020-10-25
Ladyseven 2020-10-22
zuncle 2020-09-28
xiaohuli 2020-09-02
葉無聞 2020-09-01
nicepainkiller 2020-08-20
AlisaClass 2020-08-09
myloveqiqi 2020-08-09
buttonChan 2020-08-02
drdrsky 2020-07-29
Ladyseven 2020-07-25
nicepainkiller 2020-07-24
AlisaClass 2020-07-19
hellowzm 2020-07-19
background-color: blue;background-color: yellow;<input type="button" value="变蓝" @click="changeColorT
昔人已老 2020-07-19
骆驼的自白 2020-07-18
lanzhusiyu 2020-07-19
hellowzm 2020-07-19
CSSEIKOCS 2020-07-18