๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
HTML๐Ÿ”จ/html&css ํผ์š”์†Œ

css ์ด๋ฉ”์ผ select option๋ฐ•์Šค ๋งŒ๋“ค๊ธฐ

by hyojinny 2022. 10. 10.

์•„๋ž˜ ๋ฌธ์˜ํ•˜๊ธฐ์˜ ์ด๋ฉ”์ผ ๋ถ€๋ถ„์„ ๋งŒ๋“ค์–ด๋ณด์ž 

 

 

์ดˆ๊ธฐํ™”์ฝ”๋“œ๋กœ form ๋””์ž์ธ ์—†์• ๊ธฐ

/* legend,caption,๋ฉ”๋‰ด์ œ๋ชฉ,์„น์…˜์ œ๋ชฉ ๋ธ”๋ผ์ธ๋“œ */
legend, caption, .blind { position: absolute; overflow: hidden; clip: rect(0 0 0 0); margin: -1px; width: 1px; height: 1px }
 
/* ์นธ์˜ ์„ ์„ ํ•ฉ์น˜๊ธฐ, ์นธ์˜ ๊ฐ„๊ฒฉ์—†์• ๊ธฐ, ๊ฐ€๋กœ๋ฅผ ๋Š˜๋ ค์คŒ */
table {border-collapse: collapse; border-spacing: 0; width: 100%; table-layout: fixed;}

 

 


์ดˆ๊ธฐํ™” ์ฝ”๋“œ๊ฐ€ ์‚ฌ์šฉ๋œ ๋ฐฑ์ง€์ƒํƒœ์—์„  ํผ์š”์†Œ๋“ค์ด ์ด๋ ‡๊ฒŒ ๋‚˜์˜จ๋‹ค. 

 

 

<form>
 <fieldset>
  <legend>๋ฌธ์˜์ž‘์„ฑํ•˜๊ธฐ</legend>
   <div class="inquri_wrap">
    <table>
     <caption>๋ฌธ์˜ํ•˜๊ธฐํ…Œ์ด๋ธ”</caption>
      <tr>
       <th>์ด๋ฉ”์ผ<i class="star"></i></th>
         <td>
          <input type="text" readonly title="์ด๋ฉ”์ผ">
           <span>@</span>
             <input type="text" readonly title="์ด๋ฉ”์ผ">
               <select title="๋„๋ฉ”์ธ์„ ํƒ">
                <option>์ง์ ‘ ์ž…๋ ฅ</option>
                <option value="naver.com" selected="">naver.com</option>
                <option disabled="" value="hanmail.net">hanmail.net</option>
                <option disabled="" value="naver.com">naver.com</option>
                <option disabled="" value="naver.com">naver.com</option>
                <option disabled="" value="naver.com">naver.com</option>
                <option disabled="" value="naver.com">naver.com</option>
              </select>
             </div>
            </td>
          </table>
         </div>
       </fieldset>
    </form>

ํ•˜ ๋งŽ๋‹ค.. (์ด๊ฒŒ ๋ฒŒ์จ ๋งŽ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋ฉด ์•ˆ๋Œ€๋Š”๋ฐ ^_^)

 

์ด๋ฉ”์ผ ๋ถ€๋ถ„ ๋„“์ด๋ฅผ ์กฐ์ •ํ•ด์ฃผ๊ธฐ ์œ„ํ•ด  class๋ฅผ ๋”ฐ๋กœ ์ง€์ •ํ•ด์ค€๋‹ค. input class="input_small"

 

 

 

 

 

๋ฉ”์ผ ๋ฐ•์Šค๊ฐ€ ๋‹ค๋ฅธ ๋ฐ•์Šค์™€ ๊ธธ์ด๊ฐ€ ๋‹ค๋ฅด๊ธฐ ๋•Œ๋ฌธ์— 

์ง€์ •๋œ ํด๋ž˜์Šค๋กœ ๋„“์ด ๋ฐ ๊ฐ„๊ฒฉ์กฐ์ •

 

 

.inquiry_page .inquiry_area input[type=text].input_small {
    width: 200px;
}
.inquiry_page .inquiry_area .email {
    margin: 0 16px;
}
.inquiry_page .inquiry_area .select_wrap {
    margin-left: 6px;
}
.inquiry_page .inquiry_area .select_city {
    margin-left: 0;
}

 

 


 

๋งˆ์ง€๋ง‰์œผ๋กœ select option ์œผ๋กœ ๋“ค์–ด๊ฐ„ ์˜ต์…˜๋ฐ•์Šค๋ฅด ๋””์ž์ธ ํ•ด์ฃผ์ž 

html ์ฝ”๋“œ

<option disabled="" value="hanmail.net">hanmail.net</option>
option disabled  ๋น„ํ™œ์„ฑํ™” ํ•ด์ฃผ๊ธฐ  value ๊ฐ’ ์ง€์ • ํ…์ŠคํŠธ์ž…๋ ฅ
 

 

 

๋ณดํ†ต  value  ๋ฐ์ดํ„ฐ๋Š” ๋ฐฑ์—”๋“œ์—์„œ ์ž‘์—…ํ•œ๋‹ค.


after ๋กœ ๊พธ๋ฉฐ์ฃผ๊ธฐ

 

 

css select ๊ณตํ†ต์œผ๋กœ ์œ„์น˜ ๋ฐ ๋””์ž์ธ ์žก์•„์ฃผ๊ธฐ

์ดˆ๋ก์ƒ‰ ํ™”์‚ดํ‘œ๊ฐ€ ๋ฐ‘์— ๊น”๋ ค ๋ณด์ด์ง€ ์•Š์œผ๋ฏ€๋กœ position x-index๋กœ ๋„์–ด์ค€๋‹ค.

.select_wrap {
    display: inline-block;
    width: 192px;
    border: 1px solid #999999;
    position: relative;
    z-index: 0;
}
.select_wrap:after {
    content: '';
    position: absolute;
    z-index: -1;
    right: 15px;
    top: 50%;
    width: 12px;
    height: 7px;
    margin-top: -4px;
    background: url(../images/icon_select_arr.png) no-repeat;
}

 


๋งˆ์ง€๋ง‰์œผ๋กœ ์•ˆ์ชฝ ์„  ์ œ๊ฑฐ 

.select_wrap select {
    width: 100%;
    border: none;
    height: 41px;
    line-height: 41px;
    padding: 0 10px;
    color: #999;
    cursor: pointer;
    background: none;
}

 

 

 

ํฌ์ปค์Šค ๋  ์‹œ์— ์•„์›ƒ๋ผ์ธ์ด ๋œจ์ง€ ์•Š๋„๋ก ๊ฐ€๋ ค์ค€๋‹ค. 

.select_wrap select:focus {
     outline: none;
}

๋Œ“๊ธ€