How to style a disabled checkbox?

后端 未结 9 630
旧巷少年郎
旧巷少年郎 2021-01-07 16:32

Do you know how I could style a checkbox when it is disabled?

E.g.:



        
相关标签:
9条回答
  • 2021-01-07 16:57

    You can select it using css like this:

    input[disabled] { /* css attributes */ }
    
    0 讨论(0)
  • 2021-01-07 17:01

    Checkboxes (radio buttons and <select>) are OS-level components, not browser-level. You cannot reliably style them in a manner that will be consistent across browsers and operating systems.

    Your best bet it to put an overlay on top and style that instead.

    0 讨论(0)
  • 2021-01-07 17:06

    Use CSS's :disabled selector (for CSS3):

    checkbox-style { }
    checkbox-style:disabled { }
    

    Or you need to use javascript to alter the style based on when you enable/disable it (Assuming it is being enabled/disabled based on your question).

    0 讨论(0)
提交回复
热议问题