为什么我的锚标签不显示悬停样式?
当我徘徊在列表项目上时,这些样式是我试图应用于LI元素的样式。但是这些样式到目前为止尚未出现。我在做什么错?
#menu-ul a:hover {
border-bottom: 2px solid black;
}
#menu-ul a:focus {
border-bottom: 2px solid black;
}
<ul id="menu-ul">
<span class="menu-item-selection">
<a href="#" id="brunch"><li>Brunch</li></a>
</span>
<span class="menu-item-selection">
<a href="#" id="bowls"><li>Bowls</li></a>
</span>
<span class="menu-item-selection">
<a href="#" id="beverages"> <li>Beverages</li></a>
</span>
<span class="menu-item-selection">
<a href="#" id="salads"> <li>Salads</li></a>
</span>
<span class="menu-item-selection">
<a href="#" id="desserts"> <li>Desserts</li></a>
</span>
</ul>
These are the styles I am trying to apply on the li elements when I hover over the list items. But these styles don't appear as of now. What am I doing wrong?
#menu-ul a:hover {
border-bottom: 2px solid black;
}
#menu-ul a:focus {
border-bottom: 2px solid black;
}
<ul id="menu-ul">
<span class="menu-item-selection">
<a href="#" id="brunch"><li>Brunch</li></a>
</span>
<span class="menu-item-selection">
<a href="#" id="bowls"><li>Bowls</li></a>
</span>
<span class="menu-item-selection">
<a href="#" id="beverages"> <li>Beverages</li></a>
</span>
<span class="menu-item-selection">
<a href="#" id="salads"> <li>Salads</li></a>
</span>
<span class="menu-item-selection">
<a href="#" id="desserts"> <li>Desserts</li></a>
</span>
</ul>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
所有修复您的结构的拳头:
&lt; span&gt;
不能成为&lt; ul&gt;
元素的孩子。这应该看起来像这样:
Fist of all fix your structure:
<span>
can't be a child of<ul>
element.This should look like this:
您应该针对LI元素,而不是A元素:
You should target the li element, and not the a element:
您可以将其修复,仅针对
li
A:Hover
,但我会更改HTML结构You can fix it with just targetting to
li
aftera:hover
but I would change html structure