【发布时间】:2018-04-28 16:34:05
【问题描述】:
当关注链接时,我需要更改 SVG 图标的背景 URL。
这是 HTML:
<a class="foo" href="google.com">
<span>Help</span>
</a>
这是我迄今为止所做的无济于事的SASS:
.foo {
&:before {
background: url("#{$active}") center center no-repeat;
}
[data-whatintent='keyboard'] &:focus {
background-color: transparent; // Currently purple, make it transparent
color: purple; // Currently white, make it purple
&:before {
background: url("#{$focus}") center center no-repeat;
}
span {
background-color: purple;
color: white;
}
}
}
我怎样才能让 onFocus 我将span 的背景颜色更改为紫色,span 的文本为白色,并更改 &:before 上的背景 url?我到底做错了什么?
【问题讨论】:
-
[data-whatintent=‘keyboard’]的作用是什么?它在你的 html 中应用在哪里? -
它是一个名为 what-input @muecas 的库
-
该数据属性应用于哪个元素?给
a.foo? -
是的,对于可操作的项目,例如
a.foo@muecas -
好的,我提出了一个解决方案,请测试一下,以便我进一步协助您获得所需的结果。