Pseudo-classes (의사 클래스) 사용하기
선택한 요소를 특별한 상태로 만든다.
1. hover
2. active
3. focus
<style>
a {
background-color: blue;
transition: background-color .5s;
}
a:hover {
background-color: gold;
}
/* 지정해 줄 태그 다음에 위치시킨다 */
/* 이렇게 되면 마우스가 올라갔을 때 blue->gold로 바뀐다 */
</style>
<style>
a:active {
background-color: yellow;
}
</style>
<body>
<a href="https://www.w3schools.com">W3schools.com</a><br>
</body>
<form>
<label for="my-button">내 버튼: </label>
<button id="my-button" type="button">
제 라벨이나 저를 클릭해보세요!
</button>
</form>
<style>
form :active {
color: red;
}
form button {
background: white;
}
</style>
생각다 어렵지 않았던 의사 클래스였다. 근데 왜 이름이 의사 클래스일까
필요할 때 잘 찾아서 적용하기!