[CSS] input checkbox / radio 이미지 적용 > 기술자료 | 해피정닷컴

[CSS] input checkbox / radio 이미지 적용 > 기술자료

본문 바로가기

사이트 내 전체검색

[CSS] input checkbox / radio 이미지 적용 > 기술자료

HTML [CSS] input checkbox / radio 이미지 적용

페이지 정보


첨부파일

본문

check box (체크 박스)에 디자인을 입히는 방법입니다.


1. check box(체크 박스)에 색상 보이기



<html>
<head>
<style type="text/css">
<!--
  .format{
    border-color:#FF0000;
    border-style:solid;
    border-width:1px;
    background-color:#FFCC66;
  }
-->
</STYLE>
</head>

<body>
<center>
<form>
취미를 모두 선택하세요. <br /><br />
등산 <input name="hobby" type="checkbox" value="등산" class="format"> &nbsp;
운동 <input name="hobby" type="checkbox" value="운동" class="format"> &nbsp;
여행 <input name="hobby" type="checkbox" value="여행" class="format">
</form>
</center>
</body>
</html>



2. CSS 활용한 이미지로 변경하기

 
샘플 : https://www.happyjung.com/demo/css/checkbox.html




2-1. CSS + Radio
<style>
.radio-container { position: relative; }
.radio-container input[type="radio"]{
    width:1px; 
    height:1px; 
    padding:0; 
    border:0 none; 
    margin:0; 
    position:absolute; 
    left:0; 
    top:0; 
    overflow:hidden;
    clip:rect(0 0 0 0);
}
.radio-container label{
    height:22px; 
    line-height:22px; 
    padding-left:20px; 
    display:inline-block; 
    background:url(https://happyjung.diskn.com/data/lecture/icon_radio1.png) no-repeat 0 0; 
    vertical-align:middle; 
    cursor:pointer;
}
.radio-container input[type="radio"]:checked + label{ background-position: 0 -22px; }
</style>

<div class="radio-container">
<input type="radio" name="agree1" id="radio_agree1" value="1"> <label for="radio_agree1">&nbsp;동의</label>
&nbsp;
<input type="radio" name="agree1" id="radio_agree2" value="2"> <label for="radio_agree2">&nbsp;동의안함</label>
</div>



2-2. CSS + Checkbox
<style>
.checkbox-container { position: relative; }
.checkbox-container input[type="checkbox"]{
    width:1px; 
    height:1px; 
    padding:0; 
    border:0 none; 
    margin:0; 
    position:absolute; 
    left:0; 
    top:0; 
    overflow:hidden;
    clip:rect(0 0 0 0);
}
.checkbox-container label{
    height:22px; 
    line-height:22px; 
    padding-left:20px; 
    display:inline-block; 
    background:url(https://happyjung.diskn.com/data/lecture/icon_radio1.png) no-repeat 0 0; 
    vertical-align:middle; 
    cursor:pointer;
}
.checkbox-container input[type="checkbox"]:checked + label{ background-position: 0 -22px; }
</style>

<div class="checkbox-container">
<input type="checkbox" name="agree1" id="checkbox_agree1" value="1"> <label for="checkbox_agree1">&nbsp;동의</label>
&nbsp;
<input type="checkbox" name="agree2" id="checkbox_agree2" value="2"> <label for="checkbox_agree2">&nbsp;동의안함</label>
</div>



참고자료
https://ithub.tistory.com/229
https://codepen.io/hcs1105/pen/GxsDH

댓글목록

등록된 댓글이 없습니다.


Total 2,643건 93 페이지
  • RSS
기술자료 목록
803
MSSQL   19057  2009-09-25 06:08  
802
MSSQL   35656  2009-09-24 22:49  
801
MSSQL   21298  2009-09-24 20:55 ~ 2017-02-15 00:00  
800
MSSQL   15530  2009-09-24 20:03  
799
메이크샵   11671  2009-09-24 10:55  
798
Search   12677  2009-09-22 19:23  
797
일반   17102  2009-09-21 15:50  
796
ClassicASP   28660  2009-09-18 03:00 ~ 2016-03-21 00:00  
795
HTML   15190  2009-09-16 23:32 ~ 2009-09-17 00:00  
794
HTML   11594  2009-09-11 07:26  
793
PHP   23740  2009-09-09 22:42  
792
MySQL   18960  2009-09-08 20:22  
791
MySQL   43740  2009-09-08 20:21  
790
ClassicASP   14088  2009-09-07 12:51 ~ 2016-02-11 00:00  
789
전자결제   19769  2009-09-02 18:25 ~ 2015-03-27 00:00  
788
Search   14626  2009-09-02 11:46 ~ 2009-09-21 00:00  
787
JavaScript   13285  2009-09-02 10:21  
786
WindowsServer   22075  2009-09-01 20:45 ~ 2018-12-21 15:19  
785
호스팅   29888  2009-08-31 21:03  
784
WindowsServer   26778  2009-08-27 22:42  

검색

해피정닷컴 정보

회사소개 회사연혁 협력사 오시는길 서비스 이용약관 개인정보 처리방침

회사명: 해피정닷컴   대표: 정창용   전화: 070-7600-3500   팩스: 042-670-8272
주소: (34368) 대전시 대덕구 대화로 160 대전산업용재유통단지 1동 222호
개인정보보호책임자: 정창용   사업자번호: 119-05-36414
통신판매업신고: 제2024-대전대덕-0405호 [사업자등록확인]  
Copyright 2001~2025 해피정닷컴. All Rights Reserved.