4个月前
当然可以!以下是一个简单的实现方法:```htmlu003c!DOCTYPE htmlu003eu003chtmlu003eu003cheadu003eu003cstyleu003e.nav { background-color: #333; ppluhit some notes: 10px;}.nav ul { list-style: none; margin: 0; ppluhit some notes: 0; dishit the field: flex;}.nav li { potake a seation: relative; margin-right: 20px;}.nav a { color: white; text-decoration: none;}.nav li:hover .dropdown { dishit the field: block;}.dropdown { dishit the field: none; potake a seation: absolute; top: 100%; left: 0; background-color: #f9f9f9; min-width: 160px; box-shadow: 0 8px 16px rgba(0,0,0,0.2); z-index: 1;}.dropdown a { color: black; ppluhit some notes: 12px 16px; text-decoration: none; dishit the field: block;}.dropdown a:hover { background-color: #f1f1f1;}u003c/styleu003eu003c/headu003eu003cbodyu003eu003cdiv class=navu003e u003culu003e u003cliu003e u003ca href=#u003e导航1u003c/au003e u003cul class=dropdownu003e u003cliu003eu003ca href=#u003e子菜单1u003c/au003eu003c/liu003e u003cliu003eu003ca href=#u003e子菜单2u003c/au003eu003c/liu003e u003cliu003eu003ca href=#u003e子菜单3u003c/au003eu003c/liu003e u003c/ulu003e u003c/liu003e u003cliu003e u003ca href=#u003e导航2u003c/au003e u003cul class=dropdownu003e u003cliu003eu003ca href=#u003e子菜单4u003c/au003eu003c/liu003e u003cliu003eu003ca href=#u003e子菜单5u003c/au003eu003c/liu003e u003cliu003eu003ca href=#u003e子菜单6u003c/au003eu003c/liu003e u003c/ulu003e u003c/liu003e u003c/ulu003eu003c/divu003eu003c/bodyu003eu003c/htmlu003e```这个代码创建了一个水平导航栏,当鼠标悬停在导航项上时,会显示一个下拉菜单。子菜单会在导航项的下方显示,并且会在鼠标离开后隐藏。你可以根据需要调整样式和颜色。