HTML๐จ/html&css ํผ์์
css form input type="file" ์ฒจ๋ถํ์ผ์ฌ๋ฆฌ๊ธฐ
hyojinny
2022. 10. 10. 22:27
๋ฌธ์ํ๊ธฐ์์ ์ฒจ๋ถํ์ผ์ ์ฌ๋ฆด์์๋๋ก ํผ์ ๋ง๋ค์ด๋ณด์
๊ธฐ์กด์ text ์์์ ๊ณตํต ํด๋์ค๋ก ์ง์ ๋์ด์๋ ๋์์ธ์
file ์์ญ์๋ง ํด๋นํ์ง์๋๋ก :not ๋ถ์ ์ ํ์๋ฅผ ์ค ๋ชจ์ต
.inquiry_page .inquiry_area input[type=text]:not(.input_file) {
width: 100%;
height: 45px;
background: #f8f8f8;
border: none;
padding: 0 15px;
}
1. html ํ ์ด๋ธ์์ ์ฝ๋ ์์ฑ
<tr>
<th class="th_top">์ฒจ๋ถํ์ผ</th>
<td>
<div class="file_wrap">
<input class="blind" id="file" type="file">
<input class="input_file" type="text" readonly title="ํ์ผ๋ช
">
<label class="txt_point01" for="file">ํ์ผ์ ํ</label>
</div>
<p class="note">โป ๋ฑ๋ก ๊ฐ๋ฅ ํ์ฅ์ : pdf,docx,pptx,xlsx,jpg,jpeg,gif,png / ์ต๋ 5MB</p>
</td>
</tr>
ํ ์คํธ ๋ฌธ๋จ p์ ๋จ์ด๋จ๋ ค ์ฃผ๊ธฐ ์ํด์ div file_wrap์ ๊ฐ๋๋ค.
๊ธฐ๋ณธ input ์ผ๋ก file ๋ง ์ง์ ํ์๋ ๋์ค๋ ๋ธ๋ผ์ฐ์ ๊ธฐ๋ณธ ๋์์ธ
๊ธฐ๋ณธ ์ด๊ธฐํ ์ฝ๋ ์ฝ์ ์ ์์ ๋์์ธํ๋ ํผ์ ์ํฅ์ ๋ฐ๋๋ค
css ๊ณตํต ํด๋์ค ๋์์ธ
.file_wrap {
display: inline-block;
border: 2px solid #dddddd;
width: 100%;
position: relative;
}
/* ์ ํ์ ์ ์ ๋์ด๊ธฐ ์ํด ๊ฐ์ฅ ๋ฐ๊นฅ์ ์์ ์ด๋ฆ ๋ฃ๊ธฐ !impotant ์ฌ์ฉ๊ธ์ง */
.file_wrap input[type=text] {
height: 41px;
width: calc(100% - 98px);
border: none;
background: none;
padding: 0 15px;
}
๊ณตํตํด๋์ค๋ก ๋จผ์ ๋์์ธ ํ์ ์ก์ ์ฃผ๋๋กํ๋ค.
css ๊ฐ๋ณ์ํธ ๋์์ธ
.inquiry_page .inquiry_area .th_top {
vertical-align: top;
padding-top: 24px;
}
.inquiry_page .inquiry_area textarea:focus {
outline: none;
}
.inquiry_page .inquiry_area .file_wrap{
width: 466px;
}
.inquiry_page .inquiry_area .note {
display: inline-block;
font-size: 13px;
color: #999;
margin-left: 25px;
}