업로드 파일 필드의 찾아보기 버튼을 사용자 정의 (배경 및 색상 변경이 필요함)하고 싶습니다.찾아보기 버튼을 어떻게 사용자 정의 할 수 있습니까?
<input type="file" tabindex="6" class="medium" size="20" value="" id="input_5_13" name="input_13">
업로드 파일 필드의 찾아보기 버튼을 사용자 정의 (배경 및 색상 변경이 필요함)하고 싶습니다.찾아보기 버튼을 어떻게 사용자 정의 할 수 있습니까?
<input type="file" tabindex="6" class="medium" size="20" value="" id="input_5_13" name="input_13">
수 없습니다. 자신 만의 버튼을 만들어 실제 입력을 트리거해야합니다.
여기에서 jQuery를 사용하면됩니다. 참조 working example.
HTML :
<input type="file" class="hidden" id="uploadFile"/>
<div class="button" id="uploadTrigger">Upload File</div>
jQuery를 :
$("#uploadTrigger").click(function(){
$("#uploadFile").click();
});
CSS :
.hidden {
display:none;
}
.button {
border: 1px solid #333;
padding: 10px;
margin: 5px;
background: #777;
color: #fff;
width:75px;
}
.button:hover {
background: #333;
cursor: pointer;
}
스타일링 파일 입력 버튼 뒤에 기본 전제가 파일을 통해 절대 위치 제어를 오버레이하는 것입니다 업로드. 파일 업로드 불투명도가 0으로 설정되어 표시되지 않습니다. 컨트롤의 Z- 인덱스는 파일 업로드보다 낮게 설정되지만 Z- 인덱스는 오버레이 된 컨트롤 위에 설정됩니다. 사용자가 생각하는 그래서 때 여기에 0
정말 거친 예입니다 설정 불투명도 업로드가 실제로 파일을 클릭하는 오버레이 컨트롤을 클릭하면됩니다
HTML이
<div id="file-upload-cont">
<input id="original" type="file"/>
<div id="my-button">Find</div>
<input id="overlay"/>
</div>
CSS
#my-button{
position: absolute;
border: 1px solid black;
background: green;
padding 3px;
width: 50px;
height: 25px;
text-align: center;
left: 148px; /* Positioning over file-upload */
top: 0px;
z-index: 1; /* Lower z-index causes controls to sit under file upload */
}
#overlay{
position: absolute;
z-index: 1; /* Lower z-index causes controls to sit under file upload */
left: 0; /* Positioning over file-upload */
}
#original{
opacity: 0; /* Opacity makes it invisible*/
position: relative;
z-index: 100; /* z-index causes original file upload to sit above other controls*/
}
#file-upload-cont{
position: relative;
}
나는 그 코드 Kevin Bowersox를 시도했지만 그 입력 오버레이에서 선택된 파일을 볼 수 없다 ... 이것은 모두가 말하고있는 오류인가? – brainless
가능한 복제본 [HTML에서 파일 찾아보기 버튼을 대체하는 가장 좋은 방법은 무엇입니까?] (http://stackoverflow.com/questions/108149/what-is-the-best-way- html로 파일 찾기 버튼) –
@Manjit Singh 답변을 선택할 수 있다면 도움이 될 것입니다. 2 년 전이었습니다. – Cody
oops @DoctorOreo .. 답변을 선택하는 것을 잊었습니다. 생각 나게 해줘서 고마워. –