html - 求解關(guān)于偽類和visibility的問題
問題描述
想把鼠標(biāo)懸停在“用戶”上時(shí)表格會(huì)顯現(xiàn)出來(lái),可是為什么以下代碼不能實(shí)現(xiàn)?到底哪里錯(cuò)了好煩躁呀!
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'>關(guān)注</a> </td></tr><tr> <td><a href='http://www.aoyou183.cn/wenda/6147.html'>設(shè)置</a> </td></tr><tr> <td><a href='http://www.aoyou183.cn/wenda/6147.html'>消息</a> </td></tr> </table> </p></body></html>
問題解答
回答1:css選擇器用錯(cuò)了
cssa:hover table{ visibility: visible;}
表示一個(gè)祖先元素的是a元素,且該a元素狀態(tài)為hover 的 table 元素是可見的。對(duì)于你的html, a元素是 table 元素的兄弟元素,應(yīng)該是:
cssa:hover + table{ visibility: visible;}
相關(guān)文章:
1. [python2]local variable referenced before assignment問題2. 求救一下,用新版的phpstudy,數(shù)據(jù)庫(kù)過段時(shí)間會(huì)消失是什么情況?3. mysql - 如何在有自增id的情況下,讓其他某些字段能不重復(fù)插入4. python小白,關(guān)于函數(shù)問題5. django - Python error: [Errno 99] Cannot assign requested address6. Python2中code.co_kwonlyargcount的等效寫法7. java - 線上應(yīng)用,如果數(shù)據(jù)庫(kù)操作失敗的話應(yīng)該如何處理?8. node.js - win 下 npm install 遇到了如下錯(cuò)誤 會(huì)導(dǎo)致 無(wú)法 run dev么?9. python小白 關(guān)于類里面的方法獲取變量失敗的問題10. angular.js - 百度支持_escaped_fragment_嗎?
