我想我的鏈接將出現在圖像的中心,如果圖像懸停。 如何做到這一點?我更喜歡使用純CSS,但如果需要jQuery是沒有問題的。懸停鏈接將出現在圖像
<div class="container">
<img src="an_img.jpg">
<div> <a href="a link">i want this link on center</a> </div>
</div>
CSS:
<style>
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; }
</style>
就像這樣: http://jsfiddle.net/gye6f9yh/
但我想在圖像的中心垂直和水平。
[圖像懸停以顯示鏈接(http://stackoverflow.com/questions/9943818/image-hover-to-reveal-links)的可能重複 – Ancient 2015-02-06 10:07:20
哪個鏈路應該出現,「產品名稱」? – 2015-02-06 10:08:45
@古代我編輯,我想喜歡它,但鏈接是在圖像的中心 – 2015-02-06 10:26:24