Custom checkbox using only CSS and HTML

后端 未结 4 1836
故里飘歌
故里飘歌 2020-12-17 15:23

I need to create a custom checkbox using only html and CSS. So far I have:

HTML/CSS:

4条回答
  •  时光取名叫无心
    2020-12-17 16:02

    .checkbox-custom {
      position: relative;
    }
    
    .checkbox-custom input[type=checkbox] {
      display: none;
    }
    
    .checkbox-custom input[type=checkbox]~b {
      cursor: pointer;
      outline: 0;
      position: relative;
      display: inline-block;
      margin: 4px 1px 0;
      background-color: #ffffff;
      border: 2px solid #ad823a;
      width: 24px;
      height: 24px;
      vertical-align: middle;
      line-height: 1;
      text-align: center;
      font-size: 20px;
      color: #ad823a;
    }
    
    .checkbox-custom input[type=checkbox]:checked~b:after {
      content: '\2713';
    }

提交回复
热议问题