html - 求解关于伪类和visibility的问题
问题描述
想把鼠标悬停在“用户”上时表格会显现出来,可是为什么以下代码不能实现?到底哪里错了好烦躁呀!
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='https://www.haobala.com/wenda/6147.html'>用户</a> <table><tr> <td><a href='https://www.haobala.com/wenda/6147.html'>好友</a> </td></tr><tr> <td><a href='https://www.haobala.com/wenda/6147.html'>关注</a> </td></tr><tr> <td><a href='https://www.haobala.com/wenda/6147.html'>设置</a> </td></tr><tr> <td><a href='https://www.haobala.com/wenda/6147.html'>消息</a> </td></tr> </table> </p></body></html>
问题解答
回答1:css选择器用错了
cssa:hover table{ visibility: visible;}
表示一个祖先元素的是a元素,且该a元素状态为hover 的 table 元素是可见的。对于你的html, a元素是 table 元素的兄弟元素,应该是:
cssa:hover + table{ visibility: visible;}
相关文章:
1. python - 字符串中反斜杠的替换2. 小程序怎么加外链,语句怎么写!求救新手,开文档没发现3. vue打包和PHP后台怎样同域名部署配置4. python中merge后文件莫名变得非常大5. javascript - 给页面加了动画,在微信浏览器中显示混乱,急救6. java - MySQL显示中文星期7. python - matplotlib 做一个饼状图出错8. MySQL 联合查询并更新到另一个表,求教9. python - <flask web 开发>项目permission问题10. base64_decode调用出错windows server 2008R2系统上出现的
