[英]I styled focus state for my webpage. But even after I'm done clicking button/link, the focus stays, unless I click whitespaces. How do I make it go?
I've styled the focus state for my webpage to my liking.我已经根据自己的喜好为我的网页设置了焦点状态。 But now it stays on the buttons/links even when I'm done clicking them.但是现在即使我完成了单击它们,它也会保留在按钮/链接上。 I have to click the blank spaces to make it go away.我必须单击空白处才能使其消失。 I only want the focus state to be visible when we use TAB key for shifting focus, and(optional) when the buttons are clicked.我只希望当我们使用 TAB 键移动焦点时焦点状态可见,并且(可选)单击按钮时可见。 How can I do that?我怎样才能做到这一点? Do I need to write some JavaScript for that?我需要为此编写一些 JavaScript 吗? Basically I want the focus state to behave in a default way, the way it did before I styled it.基本上我希望焦点状态以默认方式运行,就像我设置它之前所做的那样。
*:focus {
outline: none;
box-shadow: 0 0 0 0.5rem rgba(61, 112, 46, 0.5);
}
.cta *:focus {
box-shadow: 0 0 0 0.5rem rgba(255, 255, 255, 0.5);
}
try using this css selector instead of *:focus
尝试使用这个 css 选择器而不是*:focus
*:focus-visible{
outline: none;
box-shadow: 0 0 0 0.5rem rgba(61, 112, 46, 0.5);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.