所以我有一個div,將包括圖像http://www.reversl.net/hovers/,我希望圖像顯示兩個鏈接時,像這裏所示的佈局懸停http://www.reversl.net/demo/是否有可能實現這隻使用CSS?圖像懸停以顯示鏈接
4
A
回答
1
的另一種方式,你可以用顯示器做:無/塊
div.container { width: 200px; height: 200px; position: relative; }
div.container img { width: 100%; height: 100%; position: absolute; top: 0; }
div.container div { width: 100%; position: absolute; top: 0; display: none; }
div.container img:hover + div { display: block; }
div.container div:hover { display: block; }
<div class="container">
<img src="an_img.jpg">
<div> <a href="a link">A link should be here</a> </div>
</div>
4
您可以創建鏈接,並在CSS股利:
div.myimage div.links { display:none;}
div.myimage:hover div.links { display:block;}
樣本HTML:
<div class="myimage">
<div class="links"> we are the links</div>
<img src="animage.png" />
</div>
很明顯,如果你想將鼠標懸停在您必須設置自己的div定位
0
僅供參考:
div.container { width: 200px; height: 200px; position: relative; }
div.container img { width: 100%; height: 100%; position: absolute; top: 0; }
div.container img:hover { z-index: -1; }
div.container div { width: 100%; position: absolute; top: 0; }
div.container div:hover { z-index: 1; }
(最後一個需要懸停在鏈接時消除閃爍)
<div class="container">
<div> <a href="">A link should be here</a> </div>
<img src="an_img.jpg">
</div>
1
你總是可以使用「不透明度」 。
您的標記將是這樣的:
<div class="wrapper">
<img src="example.png" alt="example" />
<ul class="links">
<li><a href="">Example Link</a></li>
<li><a href="">Example Link</a></li>
</ul>
</div>
然後在CSS:
.wrapper {
position: relative; /*so the absolute positioning works */
}
.links {
position: absolute;
top: 0;
left: 0;
opacity: 0; /*hidden by default */
width: 100%;
height: 25px; /*making this up */
}
.wrapper:hover .links, .wrapper:focus .links {
opacity: 1; /*visible on hover */
}
一個警告夫婦這種技術:
- 你需要使用一個opacity filter對於IE8及以下版本,因爲他們不理解不透明CSS屬性
- 我不會推薦這種導航技術,因爲你似乎打算這麼做。觸控設備上的用戶(智能手機和平板電腦)實際上並沒有「懸停」狀態依賴。
如果你想要一些積分,但是,對於現代瀏覽器的用戶,補充一點:
.links {
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
和鏈接不會在「褪色」 - 所有的CSS。
相關問題
- 1. 當鏈接顯示圖像懸停在鏈接旁邊時
- 2. css圖像懸停鏈接
- 3. 在鏈接懸停顯示div,顯示懸停的該div和鏈接
- 4. 懸停效果以顯示圖像
- 5. ImageMapster - 顯示影像地圖上的文字鏈接懸停
- 6. 突出顯示鏈接懸停時的相應圖像
- 7. 當文字鏈接懸停時顯示圖像?
- 8. 文本鏈接在懸停上顯示圖像
- 9. 當鼠標懸停在鏈接上時顯示圖像
- 10. 圖像懸停時,如何在懸停時顯示圖像?
- 11. 在懸停的圖像上顯示圖層/ div與圖像上的鏈接
- 12. CSS懸停在點上以顯示圖像 - 不在圖像上懸停
- 13. JS畫廊懸停以顯示大圖像 - 如何刪除超鏈接
- 14. 將鼠標懸停在圖像上並在該圖像上顯示鏈接
- 15. 鼠標懸停時的顯示鏈接
- 16. 鏈接顯示元素:懸停之前
- 17. jquery懸停不顯示鏈接
- 18. jQuery:懸停鏈接顯示/隱藏div
- 19. 錨鏈接懸停狀態不顯示
- 20. 懸停工具提示顯示圖像
- 21. 引導懸停圖像顯示示例
- 22. 彈出圖像css鏈接上懸停
- 23. CSS鏈接懸停不是圖像
- 24. jQuery懸停鏈接交換圖像
- 25. 移動鏈接圖像5px懸停
- 26. 圖像放大懸停與鏈接
- 27. 更改鏈接圖像懸停
- 28. 將圖像懸停添加到鏈接
- 29. HTML鏈接和懸停的圖像
- 30. 禁用圖像鏈接懸停強調
請編輯以前的答案,而不是發佈新的答案。 – kappa 2012-03-30 14:03:23
感謝熊貓34。幾乎正是我在找什麼。唯一的事情是...圖像現在溢出了div。我怎麼能解決這個問題? http://www.reversl.net/hovers/ – Jedda 2012-03-30 15:00:28
如果你已經設置了你的容器(div.image),使用它來代替我的div.container,我只是提供它作爲例子。所以,它溢出你的div,因爲它有不同的寬度,擺脫它。 – 2012-03-30 15:15:56