Cấu trúc của :hover
Ví dụ với mẫu html sau
Code:
<a class="hotrofm" href="http://www.hotrofm.net/"><span class="classhotro">hotrofm</span></a>
khi không có class thì tôi chọn a
Code:
a:hover {
property : value;
}
Nếu có class thì tôi sẽ chọn class hotrofm
Code:
a.hotrofm:hover {
property : value;
}
Sử dụng :hover với thuộc tính affter và before
không viết :before::hover mà hãy viết :hover::before
Code:
a:hover::before {
property : value;
}
Tương tự after cũng thế
Code:
a:hover::after {
property : value;
}
Sử dụng :hover áp dụng chọn cho class ở trong
ở đây mình chọn classhotro
Code:
a.hotrofm:hover .classhotro {
property : value;
}