要将鼠标悬停在整个文本部分上以显示图像,您可以在悬停时显示和隐藏图像:
CSS@H_403_9@img{
display: none
}
p.one:hover + img{ //img is a sibling
display: block;
}
p.two:hover img{ //image is a child
display: block;
}
HTML@H_403_9@
HOVER OVER ME - IMG IS SIBLING
HOVER OVER ME -IMG IS CHILD
要么@H_403_9@
如果要将鼠标悬停在文本的特定部分上,可以将文本包装在跨度中,只需将图像作为该跨度的兄弟或子项:@H_403_9@
HTML@H_403_9@
This is some text. HOVER OVER ME
CSS@H_403_9@img{
display: none
}
span:hover + img{
display: block;
}