form input[type="file"] 커스텀 하기
input file은 기본적으로 아래와 같이 나온다.
<input type="file" id="file">
커스텀을 해야했는데 label로 감싸고 input을 내부에 넣어주었다.
html
<div class="submitFile">
<div class="subHead">제출서류</div>
<div class="userCon">
<span class="userInfor">이력서</span>
<div class="fileBox">
<img src="images/icon_file.png" alt="">
<label for="file" id="fileTxt">
<span class="hide">이력서 첨부</span>
<input class="uploadName" >
<!--value="이력서 첨부"-->
<input type="file" id="file">
<!--기존 모양 숨김 처리-->
</label>
</div>
</div>
</div>
css
/* 이력서 파일 제출*/
.applyContainer form .submitFile {margin-bottom: 65px;}
.applyContainer form .submitFile .fileBox {display: flex; align-items: center; height: 55px; padding-left: 18px; border-radius: 10px; background-color: #d0cccd;}
.applyContainer form .submitFile .fileBox img {margin-right: 5px;}
.applyContainer form .submitFile .fileBox .hide {font-size: 18px; font-family: 'NotoSansR'; color: #3f3f3f;}
.applyContainer form .submitFile .fileBox input {width: auto; background-color: #d0cccd;}
/* 이력서 기존 디자인 없애기*/
.applyContainer form .submitFile .fileBox input[type="file"] {position: absolute; width: 0; height: 0; padding: 0; overflow: hidden; border: 0;}
script
$(document).ready(function(){
$('#file').on('change', function(){
var fileName = $('#file').val();
$(".uploadName").val(fileName);
});
});
참고
custom input[type="file"] - 폼 커스텀 파일업로드 #1
form input[type="radio"] 커스텀 하기
html구조
<div class="chkCon">
<div class="chkForm">
<input type="radio" name="chk_info" checked="checked" id="agr">
<label for="agr" class="agree">동의합니다.</label>
</div>
<div class="chkForm">
<input type="radio" name="chk_info" checked="checked" id="noagree">
<label for="noagree" class="agree">동의하지 않습니다.</label>
</div>
</div>
chkForm의 상위 부모는 chkCon으로 한번 더 감싸주었다.
.chkForm으로 input과 label을 감쌌음.
css
1. radio 기본 양식을 없애준다.
opacity를 통해 기본 동그라미를 없애준다.
/* radio 기본양식 없애기 */
.chkCon .chkForm input[type="radio"] {
position: relative;
width: 1px;
height: 1px;
margin: -1px;
overflow: hidden;
opacity: 0;
}
2. 라디오버튼의 모양을 바꿔주고, radio가 클릭되었을 때 label의 앞에 이미지를 넣어준다.
/*라디오버튼 뒤의 label*/
.chkCon .chkForm input[type="radio"] + label {
position: relative;
display: inline-block;
cursor: pointer;
margin-right: 5px;
}
/*라디오버튼 뒤의 label:before의 모양 바꿔주기*/
.chkCon .chkForm input[type="radio"] + label:before {
margin-right: 5px;
content: '';
background: url("../images/nonDot.png")no-repeat center;
background-size: contain;
width: 15px;
height: 15px;
display: inline-block;
}
/*라디오버튼이 클릭되었을때 바로 뒤의 label:before의 모양 바꿔주기*/
.chkCon .chkForm input:checked + label:before {
width: 15px;
height: 15px;
background: url("../images/redDot.png") no-repeat center;
background-size: contain;
}
참고자료
반응형
SMALL
'MarkUp > CSS' 카테고리의 다른 글
[CSS] iframe 반응형으로 비율유지하며 줄어들게 하기 (0) | 2022.03.10 |
---|---|
[CSS] pointer-event 알아보기 ing (0) | 2022.02.23 |
[CSS] hover 의 반대 :not(:hover) (0) | 2022.02.11 |
[CSS] 폰트어썸을 사용한 입력필드 만들어보기 (0) | 2022.01.08 |
[CSS] CSS 변수 사용하기 (0) | 2022.01.05 |