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='http://www.aoyou183.cn/wenda/6147.html'>用戶</a> <table><tr> <td><a href='http://www.aoyou183.cn/wenda/6147.html'>好友</a> </td></tr><tr> <td><a href='http://www.aoyou183.cn/wenda/6147.html'>關注</a> </td></tr><tr> <td><a href='http://www.aoyou183.cn/wenda/6147.html'>設置</a> </td></tr><tr> <td><a href='http://www.aoyou183.cn/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. css3 - 微信前端頁面遇到的transition過渡動畫的bug2. javascript - 微信小程序里怎么把頁面轉成圖片分享3. node.js - 有沒有比較好的nodejs導出excel的插件?4. centos - apache配置django報錯:cannot be loaded as Python modules5. 微信端電子書翻頁效果6. mysql - SQL問個基礎例子,書上的,我怎么看都看不懂..誰幫我解釋一下第2個為什么和第1個一樣?7. mysql服務無法啟動1067錯誤,誰知道正確的解決方法?8. mysql事務日志的一些問題9. mysql - 我用SQL語句 更新 行的時候,發現全部 中文都被清空了,請問怎么解決?10. 數據庫 - mysql boolean型無法插入true
