如何编写针对未禁用按钮的选择器的较少的选择器?
index.html :
<div>
<span>
<button disabled>
Button 1
</button>
<button>
Button 2
</button>
</span>
</div>
index.less :
:not(&[disabled]) button {
background-color: red;
}
这给出了以下输出。这两个按钮均为红色,但我试图仅针对未禁用的按钮。
有没有办法做到这一点?我专门寻找未禁用的目标按钮。
这是jsfiddle: https://jsfiddle.net/6gqqb19e3/36/36/36/
index.html:
<div>
<span>
<button disabled>
Button 1
</button>
<button>
Button 2
</button>
</span>
</div>
index.less:
:not(&[disabled]) button {
background-color: red;
}
This gives the below output. Both buttons are colored red but I am trying to target only button that is not disabled.
Is there a way to do this? I am specifically looking to target buttons that are not disabled.
Here is the jsfiddle : https://jsfiddle.net/6gqb19e3/36/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
我是不熟悉的,我的语法是错误的。经过一点点反复试验,我提出了这一点:
它给出了此输出:
这是: https:/ /
I am new to LESS and my syntax was wrong. After bit of trial and error, I came up with this:
and it gives this output:
Here is the jsfiddle with: https://jsfiddle.net/6gqb19e3/81/