英文:
Add button inside the label but without changing any styles
问题
我在我的网站上有这段代码,其中包含一个标题:<h3 class="label" type="button">
。
这是一个手风琴效果,所以我想通过以下方式增加可访问性:<h3 class="label"><button aria-expanded="true">
。
但它会在按钮上添加一些样式,我不想要这个,我想保留当前的样式。是否有一种高效的方法来实现这一点,而不仅仅是为按钮的特殊类添加样式?
英文:
I have the code on my website with a header: <h3 class="label" type="button">
It is an accordion so I'd like to make it more accessible by changing it to:
<h3 class="label"><button aria-expanded="true">
. But it adds some styling on top for the button. I don't want this, I would like to keep the styling that is now. Is there any efficient way to do this, other than just styling the special class of the button?
答案1
得分: 1
它需要 all: inherit
样式,可以内联添加。
英文:
It needs all: inherit
style, can be added inline.
答案2
得分: 0
你可以对按钮元素应用一个全局继承:
button.aria-button {
all: inherit;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
以及HTML:
<h3 class="label">
<button class="aria-button" aria-expanded="true">
{你的文本}
</button>
</h3>
英文:
You can apply a global inherit to the button element:
button.aria-button {
all: inherit;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
and html:
<h3 class="label">
<button class="aria-button" aria-expanded="true">
{yourText}
</button>
</h3>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论