Checkboxes in web pages – how to make them bigger?

前端 未结 7 1137
南笙
南笙 2021-01-30 01:57

The standard checkboxes rendered in most browsers are quite small and don’t increase in size even when a larger font is used. What is the best, browser-independent way to displ

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-30 02:30

    Pure modern 2020 CSS only decision, without blurry scaling or non-handy transforming. And with tick! =)

    Works nice in Firefox and Chromium-based browsers.

    So, you can rule your checkboxes purely ADAPTIVE, just by setting parent block's font-height and it will grow with text!

    input[type='checkbox'] {
      -moz-appearance: none;
      -webkit-appearance: none;
      appearance: none;
      vertical-align: middle;
      outline: none;
      font-size: inherit;
      cursor: pointer;
      width: 1.0em;
      height: 1.0em;
      background: white;
      border-radius: 0.25em;
      border: 0.125em solid #555;
      position: relative;
    }
    
    input[type='checkbox']:checked {
      background: #adf;
    }
    
    input[type='checkbox']:checked:after {
      content: "✔";
      position: absolute;
      font-size: 90%;
      left: 0.0625em;
      top: -0.25em;
    }
    
    

提交回复
热议问题