想把鼠标悬停在“用户”上时表格会显现出来,可是为什么以下代码不能实现?到底哪里错了好烦躁呀!
html
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> table{ visibility: hidden; } a:hover table{ visibility: visible; } </style> </head> <body> <p> <a href="">用户</a> <table> <tr> <td> <a href="">好友</a> </td> </tr> <tr> <td> <a href="">关注</a> </td></tr> <tr> <td> <a href="">设置</a> </td> </tr> <tr> <td> <a href="">消息</a> </td> </tr> </table> </p> </body> </html>
ringa_lee2017-04-17 11:11:11
The css selector is used incorrectly
css
a:hover table{ visibility: visible; }
represents a ancestor element that is a a
element, and the a
element whose status is hover
is visible. table
For your html, the
element is the a
table
sibling element of the element and should be:
css
a:hover + table{ visibility: visible; }