我有一個背景圖像的容器(div)。在這個div裏有一個菜單 - 一個水平列表。我需要的是在MouseOver上插入一張圖片,絕對定位它,並在文本後面顯示它(當然!),並在div的背景圖片上。我也使用jQuery,但我認爲這並不重要。該問題可以在線查看。轉到http://www.w3schools.com/css/tryit.asp?filename=trycss_zindex並粘貼以下文本Z-Index和javascript for rollover
<html> <head> <style type="text/css"> img { top: 0; left: 0; position:absolute; z-index:-1; } #main { color: red; margin: 30px; padding: 20px; width: 700px; min-height: 400px; z-index: -2; background-image: url("http://www.google.com/logos/mother10-hp.gif"); background-repeat: no-repeat; } </style> </head> <body> <div id="main"> <h1>Z-Index question:</h1> <img src="w3css.gif" width="100" height="140" /> <p>How can we place the green pic between the text and the div#main?</p> <p>I need the green gif to appear</p> <ol> <li>On top of #main's background image</li> <li>Behind the text</li> </ol> </div> </body> </html>
謝謝。它解決了我的問題 – Raffaele 2010-04-13 11:08:38
很高興我能幫上忙。 – 2010-04-13 12:26:14