触控设备在第一次点击时同时使用:hover
或href="/products.php"
。是否有用于管理菜单导航链接及其子菜单的 CSS 解决方案?
html, body {
font-family: Arial, Helvetica, sans-serif;
background-color: tomato;
height: 100vh;
}
.navigation {
width: 300px;
}
.mainmenu, .submenu {
list-style: none;
padding: 0;
margin: 0;
}
.mainmenu a {
display: block;
background-color: #CCC;
text-decoration: none;
padding: 10px;
color: #000;
}
.mainmenu a:focus, .mainmenu a:hover {
background-color: #C5C5C5;
}
.mainmenu li:focus .submenu, .mainmenu li:hover .submenu {
display: block;
max-height: 200px;
}
.submenu a {
background-color: #999;
}
.submenu a:focus, .submenu a:hover {
background-color: #666;
}
.submenu {
overflow: hidden;
max-height: 0;
-webkit-transition: all 0.5s ease-out;
}

<nav class="navigation">
<ul class="mainmenu">
<li><a href="">Home</a></li>
<li><a href="">About</a></li>
<li><a href="/products.php">Products</a>
<ul class="submenu">
<li><a href="/Tops">Tops</a></li>
<li><a href="/Bottoms">Bottoms</a></li>
<li><a href="/Footwear">Footwear</a></li>
</ul>
</li>
<li><a href="">Contact us</a></li>
</ul>
</nav>
&#13;