我有这个下拉菜单,我正在使用 CSS 来“突出显示”我悬停的项目。我的问题是我只想在具有下拉类别的项目上显示这个向下箭头,下面是我如何在 HTML 中调用它。我给了它“子项”标签。所以我创建了以下 CSS 来显示箭头。问题是 .subitem 属性覆盖了一般的悬停属性,所以当我将鼠标悬停在它上面时我只看到箭头,有没有办法可以同时看到两者?
#cssmenu > ul > li.subitem
{
padding-right:5px;
background: url(images/arrow2.png) no-repeat;
background-position-y: 10%;
}
#cssmenu > ul li.subitem:hover
{
background: url(images/arrow2.png) no-repeat;
}
<div id='cssmenu'>
<ul>
<li><a href='index.html'><span>Home</span></a></li>
<li class='subitem'><a href='#'><span>Products</span></a>
<ul>
<li><a href='#'><span>Product 1</span></a></li>
<li><a href='#'><span>Product 2</span></a></li>
</ul>
</li>
#cssmenu > ul li:hover{
padding : 3 px, 1 px;
background: #828a91; /* Old browsers */
background: -moz-linear-gradient(top, #828a91 0%, #636363 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#828a91), color-stop(100%,#636363)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #828a91 0%,#636363 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #828a91 0%,#636363 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #828a91 0%,#636363 100%); /* IE10+ */
background: linear-gradient(to bottom, #828a91 0%,#636363 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#828a91', endColorstr='#636363',GradientType=0 ); /* IE6-9 */
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.5), inset 0 -2px 0 rgba(0,0,0,.25), inset 0 -3px 0 rgba(255,255,255,.2), 0 1px 0 rgba(0,0,0,.1);
-moz-box-shadow: inset 0 1px 0 rgba(255,255,255,.5), inset 0 -2px 0 rgba(0,0,0,.25), inset 0 -3px 0 rgba(255,255,255,.2), 0 1px 0 rgba(0,0,0,.1);
box-shadow: inset 0 1px 0 rgba(255,255,255,.5), inset 0 -2px 0 rgba(0,0,0,.25), inset 0 -3px 0 rgba(255,255,255,.2), 0 1px 0 rgba(0,0,0,.1);
}