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. python3.x - python多进程,不能在同一窗口吗2. 如何解决tp6在zend中无代码提示3. python - 怎样在linux下开发flask web应用时查看代码出错(traceback)的地方。4. mysql - SQL添加记录的数据来源于同一个表5. php - 两个表数据怎么插到一个模板中,并按时间排序?6. 一道关于 JavaScript 中 this 的题目的困惑7. 取不出SQL得到的当前页8. android-studio - android app微信登录一定要申请了登录权限才能测试?9. javascript - 如何为大量的sprite添加碰撞检测框?10. mysql多表查询

网公网安备