英文:
How to give focus-visible to all elements in TailwindCSS?
问题
我有以下的Tailwind项目:
:focus-visible {
outline: var(--primary-color) auto 2px;
}
今天我发现了 focus-visible
实用类。当我将这个类应用到一个元素上时,它确实具有正确的选择效果。但是,我必须将它应用到所有可选择的元素上。有没有一种方法可以将一个类应用到 body 上,所有子元素都继承这个属性?还是我必须使用自定义的 CSS 文件?
当我将 focus-visible 应用到 body 时,子元素不会继承这个属性。
英文:
I have the following my tailwind project:
:focus-visible {
outline: var(--primary-color) auto 2px;
}
Today I discovered the focus-visible
utility class. When I set this class to one element it does have the correct selection. However I have to set it to all selectable elements. Is there a way to set for example one class to the body and all children get this property? Or do I have to use the custom css file?
When I set the focus-visible to the body the children do not inherit this property.
答案1
得分: 2
你可以在 <body>
上使用任意变体类:
<body class="[&_:focus-visible]:class-name">
英文:
You could use an arbitrary variant class on the <body>
:
<body class="[&_:focus-visible]:class-name">
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论