Styling checkboxes, radio buttons and dropdowns

前端 未结 11 1918
栀梦
栀梦 2020-12-05 10:58

How can I style HTML checkboxes, radio buttons and dropdowns? Or can I?

I\'d like to use an image for checkboxes or radiobuttons, and the same for lists - the dropdo

11条回答
  •  萌比男神i
    2020-12-05 12:03

    You might find my post useful: http://kunal-b.in/2011/07/css-for-attractive-checkboxes-and-radio-buttons/.

    The basic idea is to hide the form ele­ment (checkbox/radio but­ton) and style the label instead using CSS. Thanks to the :checked selec­tor, it’s pos­si­ble to dis­tin­guish between the two label states by assign­ing styles to label and input:checked + label assum­ing that the label fol­lows the checkbox/radio but­ton in your html code. Using a for attribute in the code makes the com­plete label click-able, mod­i­fy­ing the state of the asso­ci­ated element.

提交回复
热议问题