๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
[๊ฐœ๋ฐœ] Practice/HTML CSS

[HTML/CSS] ์‡ผํ•‘ ์นดํŠธ ๋ ˆ์ด์•„์›ƒ & pseudo-class๋กœ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ๋ฒ„ํŠผ ๋งŒ๋“ค๊ธฐ

by Connecting-the-dots 2022. 3. 1.
728x90
๋ฐ˜์‘ํ˜•

๐Ÿ’ก ์‹ค์Šต ํฌ์ธํŠธ!

  • ๋ ˆ์ด์•„์›ƒ ๋””์ž์ธ์€ ๋ฌผ๋ก ์ด๊ณ  pseudo-class ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ํŠน์ • ํ–‰์œ„(๋งˆ์šฐ์Šค ์˜ค๋ฒ„, ํฌ์ปค์Šค, ํด๋ฆญ ์ค‘ ๋“ฑ)์— ๋Œ€ํ•œ ๋””์ž์ธ์„ ๋‹ค๋ฅด๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Œ!

๐Ÿ’œ Pseudo-class ์…€๋ ‰ํ„ฐ

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

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

.btn:active {
  background : brown; /*ํด๋ฆญ ์ค‘์ผ ๋•Œ*/
}

 

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

 

a:link {
  color : red; /*๋ฐฉ๋ฌธ ์ „ ๋งํฌ*/
}
a:visited {
  color : black; /*๋ฐฉ๋ฌธ ํ›„ ๋งํฌ*/
}
  • pseudo-class ์…€๋ ‰ํ„ฐ๋ฅผ ๋ถ™์ด๋ฉด ์—ฌ๋Ÿฌ ์ƒํƒœ์— ๋”ฐ๋ฅธ ์Šคํƒ€์ผ์„ ์ง€์ • ๊ฐ€๋Šฅ
  • hover, focus, active ์Šคํƒ€์ผ ๋„ฃ์„ ๋•Œ ์ˆœ์„œ๋Š” ๊ผญ ์ด๋ ‡๊ฒŒ "hover - focus - active" ์ˆœ์œผ๋กœ ์„ ์–ธํ•ด์•ผ ์ž˜ ๋™์ž‘ํ•จ
  • ์ด์™ธ์—๋„ ๋งŽ์€ pseudo-class ๊ฐ€ ์กด์žฌํ•˜๋ฏ€๋กœ ํ•„์š”ํ•˜๋ฉด ์•„๋ž˜์˜ ์‚ฌ์ดํŠธ์—์„œ ์ฐพ์•„์“ธ ๊ฒƒ!
 

Pseudo-classes - CSS: Cascading Style Sheets | MDN

A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s). For example, :hover can be used to change a button's color when the user's pointer hovers over it.

developer.mozilla.org

 

728x90
๋ฐ˜์‘ํ˜•