input type='radio'(:after)

๋‹ˆ๋‚˜๋…ธ๊ฐœ๋ฐœ์ƒํ™œยท2021๋…„ 5์›” 25์ผ
0

๐Ÿ’กah-ha

๋ชฉ๋ก ๋ณด๊ธฐ
21/51
post-thumbnail

๐Ÿšจ input ๋ผ๋””์˜ค ๋ฒ„ํŠผ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ css๋ฅผ ์ ์šฉํ•˜๊ณ  ์‹ถ์–ด์„œ ์ฐพ์•„๋ณด๋‹ค ์•Œ๊ฒŒ๋œ ๊ฐ€์ƒ์š”์†Œ before, after ์ดํ•ดํ•˜๊ธฐ!

  • :before - ํ•ด๋‹น ์—˜๋ฆฌ๋จผํŠธ ์•ž์— ๊ฐ€์ƒ ์ฝ˜์„ผ์ธ  ์‚ฝ์ž…
  • :after - ํ•ด๋‹น ์—˜๋ฆฌ๋จผํŠธ ๋’ค์— ๊ฐ€์ƒ ์ฝ˜ํ…์ธ  ์‚ฝ์ž…

๊ฐ€์ƒ์š”์†Œ before/after์„ ์‚ฌ์šฉํ•  ๋•Œ ๊ผญ content ์†์„ฑ์„ ํ•จ๊ป˜ ์‚ฌ์šฉํ•œ๋‹ค.

content='';

html์—๋Š” ์กด์žฌํ•˜์ง€ ์•Š๊ณ  css์—๋งŒ ์กด์žฌํ•˜๋Š” ๊ฐ€์ƒ์š”์†Œ์ด๊ธฐ ๋•Œ๋ฌธ์— js๋กœ ์ œ์–ดํ•˜๊ธฐ์—” ์–ด๋ ค์›€์ด ์žˆ๊ณ  content ๊ฐ’์— ํ…์ŠคํŠธ๋‚˜ ์ด๋ฏธ์ง€ ๋“ฑ์„ ๋„ฃ์–ด css๋งŒ์œผ๋กœ ๊ฐ€์ƒ ์š”์†Œ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

์šฐ์„  radio์˜ appearance๋ฅผ none์œผ๋กœ ๋ณ€๊ฒฝํ•˜์—ฌ ์ฒ˜์Œ๋ถ€ํ„ฐ ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ๋ชจ์–‘์œผ๋กœ ๋งŒ๋“ค์–ด์ค€๋‹ค.
checked ์ƒํƒœ์ผ ๋•Œ๋ฅผ ์„ค์ •ํ•œ๋‹ค.

.checks input[type="radio"] {
    -webkit-appearance: none;
    width: 23px;
    height: 23px;
    border-radius: 50%;
    border: 1px solid black;
    margin-right: 15px;
}

.checks input[type="radio"]:checked:after {
    background: #111;
    content: "";
    width: 19px;
    height: 19px;
    border-radius: 50%;
    margin: 1px;
    display: block;
}

โญ๏ธ ์™„์„ฑ!

profile
๊นƒํ—™์œผ๋กœ ์ด์‚ฌ์ค‘..

0๊ฐœ์˜ ๋Œ“๊ธ€