CSS checkboxes & radio buttons when input is inside label?

后端 未结 4 1036
清歌不尽
清歌不尽 2021-02-01 14:52

I\'ve searched extensively on here for an answer to this but haven\'t quite come across what I\'m looking for. Found this CSS - How to Style a Selected Radio Buttons Label? but

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 15:39

    Very interesting question. Truth be told, I'm pretty sure that's just not possible with CSS alone.

    If there's some sort of pattern to the label's for attribute (ctrl_enable_rte), there's hope for you. For example, if all checkbox labels end with rte, you could use

    label[for$=rte] { ... }
    

    If there is no such pattern, and the checkbox IDs are chosen arbitrarily, you'll have to resort to JavaScript.

提交回复
热议问题