본문 바로가기
실전 코딩/CSS

input [type="checkbox"], [type="radio"] 커스텀하기

by 정리무새 2021. 6. 23.
728x90
반응형
<div class="check_ty01">
  <input type="checkbox" name="agree" id="agree">
  <label for="agree">체크박스 커스텀</label>
</div>
.check_ty01 {display: inline-block;}
.check_ty01 input[type="checkbox"],
.check_ty01 input[type="radio"] {
  display: block; 
  overflow: hidden;
  width: 0; height: 0; 
  margin: 0; border: 0; 
  text-indent: -99999999px; 
  appearance: none; 
  -webkit-appearance: none;
  outline: none;
}
.check_ty01 label {
  position: relative; 
  padding: 0 0 0 25px; 
  font-size: 12px; 
  font-weight: 400; 
  cursor: pointer;
}
.check_ty01 label:before {
  content: '';
  display: inline-block; 
  position: absolute; left: 0; top: 3px; 
  width: 16px; height: 16px; 
  margin-right: 10px; 
  vertical-align: middle; 
  background: url(경로설정) no-repeat;
  background-size: cover;
}
/* 체크되었을 때 */
.check_ty01 input[type="checkbox"]:checked + label:before, 
.check_ty01 input[type="radio"]:checked + label:before {
  background: url(경로설정) no-repeat; 
  background-size: cover;
}

 

728x90
반응형

'실전 코딩 > CSS' 카테고리의 다른 글

테두리만 있는 글자 만들기  (0) 2021.07.21
마우스 hover시 background로 이미지 넣기  (0) 2021.06.25
css 선택자  (0) 2021.06.24
background 2개 넣기  (0) 2021.06.23
스크롤 바 커스텀하기  (0) 2021.06.23

댓글