is it possible put image in input type=“check box”?

前端 未结 3 1318
轻奢々
轻奢々 2020-12-01 19:02

i want to put an image on the background of check box & radio box in my html code but it\'s not work but it\'s work on other form property.

3条回答
  •  被撕碎了的回忆
    2020-12-01 19:22

    I write my own code to fix this issue. This will work like this. I didn't have this code now but I write same way here on SO.

    In css we will hide this checkbox by make it's Z-index less then the image that I put inside this wrapper code. Eventwise when someone click on image it's look like checkbox and in real checkbox will be clicked. instead of display:none using opacity:0 will be better. This will break in IE6 but we didn't care about that because I am not supporting IE6 anymore.

    In Javascript You can write event if you want a different (but similar to mine) implementation. You can replace native Html Checkbox,Radio and select (select2 is better if you stick with Twitter bootstrap) with your own themes based controls.

提交回复
热议问题