pseudo-class

์ƒํƒœ์— ๋”ฐ๋ผ์„œ ์Šคํƒ€์ผ์„ ์ค„ ์ˆ˜ ์žˆ๋Š” Pseudo-class ์…€๋ ‰ํ„ฐ

<button class="btn"> ๊ตฌ๋งคํ•˜๊ธฐ</button>
<input class="input-test">
<a href="#" class="link-test">๋งํฌ</a>


.btn {
    padding: 15px;
    font-size: 20px;
    border: none;
    border-radius: 10px;
    background-color: coral;
    color: white;
    cursor: pointer;
}

.btn:hover {  /*๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ ค๋†“์„ ๋•Œ*/
    background-color: chocolate;

}
.btn:focus { /*ํด๋ฆญ ํ›„ ๊ณ„์† ํฌ์ปค์Šค ์ƒํƒœ์ผ ๋•Œ*/
    background-color: grey;

}
.btn:active {  /*ํด๋ฆญ ์ค‘์ผ ๋•Œ*/
    background-color: darkblue;
    border: 2px solid black;
}



.input-test{
    font-size: 20px;

}
.input-test:focus{
    border: 4px solid red;
}

.link-test {
    text-decoration: none;

}
.link-test:link {
    color: chocolate;
}

.link-test:visited {
    color: black;
}

๊ธฐํƒ€ ๋‹ค์–‘ํ•œ ๊ฐ€์ƒ ์„ ํƒ์ž

:any-link /*๋ฐฉ๋ฌธ ์ „, ๋ฐฉ๋ฌธ ํ›„ ๋งํฌ ํ•œ๋ฒˆ์— ์„ ํƒํ•  ๋•Œ*/
:playing /*๋™์˜์ƒ, ์Œ์„ฑ์ด ์žฌ์ƒ์ค‘์ผ ๋•Œ*/
:paused /*๋™์˜์ƒ, ์Œ์„ฑ์ด ์ •์ง€์‹œ*/
:autofill /*input์˜ ์ž๋™์ฑ„์šฐ๊ธฐ ์Šคํƒ€์ผ*/
:disabled /*disabled๋œ ์š”์†Œ ์Šคํƒ€์ผ*/
:checked /*์ฒดํฌ๋ฐ•์Šค๋‚˜ ๋ผ๋””์˜ค๋ฒ„ํŠผ ์ฒดํฌ๋˜์—ˆ์„ ๋•Œ*/
:blank /*input์ด ๋น„์—ˆ์„ ๋•Œ*/
:valid /*์ด๋ฉ”์ผ input ๋“ฑ์— ์ด๋ฉ”์ผ ํ˜•์‹์ด ๋งž์„ ๊ฒฝ์šฐ*/
:invalid /*์ด๋ฉ”์ผ input ๋“ฑ์— ์ด๋ฉ”์ผ ํ˜•์‹์ด ๋งž์ง€ ์•Š์„ ๊ฒฝ์šฐ*/
:required /*ํ•„์ˆ˜๋กœ ์ž…๋ ฅํ•ด์•ผํ•  input์˜ ์Šคํƒ€์ผ*/
:nth-child(n) /*n๋ฒˆ์งธ ์ž์‹ ์„ ํƒ*/
:first-child /*์ฒซ์งธ ์ž์‹ ์„ ํƒ*/
:last-child /*๋งˆ์ง€๋ง‰ ์ž์‹ ์„ ํƒ*/

input ๋“ฑ์—๋„ ์ž์ฃผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค

์ธํ’‹์— ์ปค์„œ๊ฐ€ ์ฐํ˜€์žˆ์„ ๋•Œ ์ธํ’‹์— ์Šคํƒ€์ผ์„ ์ฃผ๊ณ  ์‹ถ์œผ๋ฉด ๋‹น์—ฐํžˆ :focus๋ฅผ ๋ถ™์ด๋ฉด ๋ฉ๋‹ˆ๋‹ค.

input:focus {
  border : 2px solid red;
}

Last updated