[英]How to add a focus ring to a menu item in html
Is this even possible if I have a menu item such as below?如果我有如下菜单项,这甚至可能吗?
<li class="dropdown"><a <">data-</c:if>href="url"?
class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"><fmt:message
It sounds like you want to use tabindex
:听起来您想使用tabindex
:
<ol> <li tabindex="-1">Item 1</li> <li tabindex="-1">Item 2</li> <li tabindex="-1">Item 3</li> <li tabindex="-1">Item 4</li> <li tabindex="-1">Item 5</li> <ol>
Note that this isn't the most accessible way of doing things, so if what you really want is to outline an <li>
when a link inside it has focus, you can use this CSS (try tabbing through the example below):请注意,这不是最易于访问的处理方式,因此如果您真正想要的是在<li>
的链接具有焦点时对其进行勾勒,则可以使用此 CSS(尝试使用 Tab 键浏览下面的示例):
li:focus-within { outline: 1px solid blue; } li a { outline: none; }
<ol> <li><a href="#">Item 1</a></li> <li><a href="#">Item 2</a></li> <li><a href="#">Item 3</a></li> <li><a href="#">Item 4</a></li> <li><a href="#">Item 5</a></li> <ol>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.