Create CSS to enlarge checkboxes

后端 未结 9 1005
萌比男神i
萌比男神i 2020-12-29 22:12

I am trying to double the size of my checkboxes on a few pages. How do I make that happen in CSS? I don\'t want to style the hover.

Ideas?

9条回答
  •  生来不讨喜
    2020-12-29 22:29

    You could always use the checkbox hack to make your own checkbox. This allows for a much more cross browser compatible solution.

    I made a quick demo here, obviously you would have to get a transparent .png of a tick, not the one I got.

    input[type=checkbox]:checked ~ div label{
        background: url(http://ramyasspace.files.wordpress.com/2011/06/tick.jpg);
        background-size: 100%;
    }
    

    input {
      display: none;
    }
    
    label input[type=checkbox] ~ span {
      display: inline-block;
      vertical-align: middle;
      cursor: pointer;
      background: #fff;
      border: 1px solid #888;
      padding: 1px;
      height: 20px;
      width: 20px;
    }
    
    label input[type=checkbox]:checked ~ span {
      /* image: Picol.org, cc-by 3.0, https://commons.wikimedia.org/wiki/File:Accept_Picol_icon.svg */
      background: url('data:image/svg+xml;utf8,');
      background-size: 100%;
    }

提交回复
热议问题