最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Change md-checkbox color - Stack Overflow

programmeradmin1浏览0评论

So it looks I can change the background-color of an empty md-checkbox by doing :

md-checkbox .md-icon {
background: red;
}

But I can't manage to change the background of a checked md-checkbox. I tried to play with :checked, ::before, ::after... But didn't succeed.

How should I proceed ?

So it looks I can change the background-color of an empty md-checkbox by doing :

md-checkbox .md-icon {
background: red;
}

But I can't manage to change the background of a checked md-checkbox. I tried to play with :checked, ::before, ::after... But didn't succeed.

How should I proceed ?

Share Improve this question edited Feb 1, 2019 at 22:32 G. Tranter 17.9k3 gold badges52 silver badges71 bronze badges asked Sep 3, 2015 at 13:39 ElloneEllone 3,89812 gold badges47 silver badges77 bronze badges 0
Add a comment  | 

2 Answers 2

Reset to default 10

You need to use theme class as well as md-checked class combination in order to define selector with higher specificity. For example:

md-checkbox .md-icon {
    background: red;
}
md-checkbox.md-default-theme.md-checked .md-icon {
    background: orange;
}

And of course, avoid using !important, this is a sign that something is wrong with your styles.

in new version added underscore ._md-icon:

md-checkbox.md-checked ._md-icon {
         background-color: white;
}
发布评论

评论列表(0)

  1. 暂无评论