这样我们就可以做到.
a {
text-decoration: underline;
color: black;
}
#image {
position: absolute;
visibility: hidden;
top: 30%;
left: 60%;
}
a:visited {
color: red;
}
a:visited + #image {
visibility: visible;
}
a:hover {
color: white;
transition: color .3s ease;
}
a:hover + #image {
visibility: visible;
}
Hello - Click this to make it visited.
您也可以通过使用:target属性来执行此操作.
a {
text-decoration: underline;
color: black;
}
#image {
position: absolute;
visibility: hidden;
top: 30%;
left: 60%;
}
a:visited {
color: red;
}
#image:target {
visibility: visible;
}
a:hover {
color: white;
transition: color .3s ease;
}
a:hover + #image {
visibility: visible;
}
Hello - Click this to make it visited.
从MDN查看…
:target pseudoclass example#hidden-element {
display: none;
}
#hidden-element:target {
display: block;
}