2010-04-18 93 views

回答

10

如果你這樣做多的地方,你可以這樣做:

<div style="position: relative;"> 
    <div style="position:absolute; width: 276px; height: 110px; z-index: 2;"> 
    Content here will be on top the image 
    </div> 
    <img style="width: 276px; height: 110px;" src='http://www.google.com/intl/en_ALL/images/logo.gif' alt="Test Img" /> 
</div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ 

如果匹配的內/歐爾div會在height/width樣式屬性,內<div><img />前並且你給內部<div>比圖像更高的z-index,它將完美地重疊圖像。

你可以在這裏看到一個例子:http://jsfiddle.net/ZcBus/

0

創建一個位置相對的容器div。然後將您的圖像放在div中,並將您的原始div作爲position:absolute,但是以相對於容器div的座標。例如

<div style='position:relative'> 
    <img src='' alt=''/> 
    <div id='original' style='position:absolute; top:10px; left:50px'/> 
</div> 

您可以使用jQuery注入部分或全部標記,或更改樣式,但是您根本不必使用腳本。

相關問題