简体   繁体   中英

How to change AngularJS Material md-checkbox background-image when indeterminate?

When the md-checkbox is in indeterminate state in Chrome, it appears as a dash. I want it to instead appear as a smaller opaque blue square inside of the checkbox for all browsers.

I have figured out how to specify the background image of the md-checkbox like so to draw the square:

style="background-image: linear-gradient(white, white 25%, rgba(0,0,0,0) 25%, rgba(0,0,0,0) 75%, white 75%), linear-gradient(to right, white, white 25%, blue 25%, blue 75%, white 75%);"

Now how do I make that style apply only when the md-checkbox is indeterminate?

I figured it out. I put this CSS in my.styles.less file:

  md-checkbox.md-indeterminate .md-icon {
    color: rgba(0,0,0,0);
    background-image: linear-gradient(white, white 25%, rgba(0,0,0,0) 25%, rgba(0,0,0,0) 75%, white 75%), 
      linear-gradient(to right, white, white 25%, rgb(61,163,244) 25%, rgb(61,163,244) 75%, white 75%);
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM