CSS Selector / :where(), :is()

:where()

์‚ฌ์šฉ๋ฒ•1

button:focus,
button:hover,
button:active {
  background: blue;
}

/* ์•„๋ž˜์™€ ๊ฐ™์ด ๊ฐ„๊ฒฐํ•˜๊ฒŒ ์ž‘์„ฑ ๊ฐ€๋Šฅ */
button:where(:focus, :hover, :active) {
  background: blue;
}

์‚ฌ์šฉ๋ฒ•2

button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
  appearance: none;
  cursor: pointer;
  margin: 0;
  border: none;
  border-radius: 1em;
  padding: 0.5em 1em;
  color: white;
  font-weight: bold;
  background: royalblue;
}

/* ์•„๋ž˜์™€ ๊ฐ™์ด ์—ฌ๋Ÿฌ ์š”์†Œ์— ๋™์ผํ•œ ์Šคํƒ€์ผ ์ ์šฉ ๊ฐ€๋Šฅ */
:where(button, input[type="button"], input[type="reset"], input[type="submit"]) {
  appearance: none;
  cursor: pointer;
  margin: 0;
  border: none;
  border-radius: 1em;
  padding: 0.5em 1em;
  color: white;
  font-weight: bold;
  background: royalblue;
}

์‚ฌ์šฉ๋ฒ•3

button:focus,
button:hover,
button:active,
input[type="button"]:focus,
input[type="button"]:hover,
input[type="button"]:active,
input[type="reset"]:focus,
input[type="reset"]:hover,
input[type="reset"]:active,
input[type="submit"]:focus,
input[type="submit"]:hover,
input[type="submit"]:active {
  background: blue;
}

/* ํ•„์š”ํ•œ ์„ ํƒ์ž๋ฅผ ๋งŽ์ด ์ค„์ผ ์ˆ˜ ์žˆ๋‹ค. */
:where(button, input[type="button"], input[type="reset"], input[type="submit"]):where(:focus, :hover, :active) {
  background: blue;
}

:is() ์ฐจ์ด์ 

:where() ํ•จ์ˆ˜๋Š” CSS ๋ช…์‹œ๋„๊ฐ€ 0์ด๋ผ์„œ, **:where()์ด ์‚ฌ์šฉ๋œ CSS ๊ทœ์น™์€ ๋‹ค๋ฅธ ์„ ํƒ์ž๋ฅผ ํ†ตํ•ด์„œ ๋ฎ์–ด์“ฐ๊ธฐ๊ฐ€ ์šฉ์ดํ•˜๋‹ค.**

:is() ๋Š” CSS ๋ช…์‹œ๋„๋Š” ์ธ์ž๋กœ ๋„˜์–ด์˜จ ์„ ํƒ์ž ์ค‘์—์„œ ๊ฐ€์žฅ ๋ช…์‹œ๋„๊ฐ€ ํฐ ๊ฒƒ์ด ๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋‹ค๋ฅธ ์„ ํƒ์ž๋กœ ๋ฎ์–ด์“ฐ๊ธฐ๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ ์ž ํ•  ๋•Œ ๋” ์ ํ•ฉ

reference

Last updated