我有一個div重疊在圖象重疊的div。頂部div有一些交互式創建的SVG內容。底層圖像具有滾動條。當我滾動圖像時,我正在尋找覆蓋div的內容也相應地滾動。換句話說,任何在頂部div上交互創建的項目都應該像直接在圖像上創建的那樣。它應該具有相對於底層圖像的固定位置,並且在圖像滾動時滾動。滾動內容上時底層圖像被滾動
以下是我有:
<div style="overflow: scroll; width: 800px; height: 680px">
<img style="max-width: 780px; display: block;"
src="someimage.png" />
<div style="display: block; max-width: 780px; top:70px; left:0px; border: solid 1px red; position: absolute">This text should scroll when the image behind is scrolled.</div>
</div>
我願意使用jQuery或任何其他插件實現這種行爲。任何建議,將不勝感激。
感謝您的建議。我曾嘗試將圖片用作背景圖片而不是單獨的「img」元素。它確實克服了將圖像和疊加div作爲單獨實體的問題,但它似乎與生成滾動條有關。 – ratty