scroll two layers together

M

mayla_i

Hi

I have two layers contain two images (with different sizes), the second
layer is positioned exactly over the other one.

can I find a way to scroll both of them together (to keep them
positioned the way they were)?
 
M

marss

(e-mail address removed) напиÑав:
Hi

I have two layers contain two images (with different sizes), the second
layer is positioned exactly over the other one.

can I find a way to scroll both of them together (to keep them
positioned the way they were)?

Here the short sample of problem solution. Place the top layer into the
bottom layer with "position:relative" in style definition. Then place
bottom layer in the scrollable div ("overflow:auto").
Try, maybe it is that you looking for.

<html>
<body>
<div style="overflow:auto;width:300px;height:300px">
<div style="width:500px;height:500px;background-color:red">bottom
layer
<div
style="position:relative;left:80;top:70;width:100px;height:50px;background-color:blue">top
layer</div>
</div>
</div>
</body>
</html>
 
M

mayla_i

Yeah it's working.. that's exactly what I was looking for.

but now how do I use the "scrollTo()" method to scroll this div? (not
the whole window)?

I appreciate your help. thanks alot
 
M

marss

(e-mail address removed) напиÑав:
Yeah it's working.. that's exactly what I was looking for.

but now how do I use the "scrollTo()" method to scroll this div? (not
the whole window)?

I appreciate your help. thanks alot

Method scrollTo applies for window only.
I think you can try next scenario (not tested):

Use iframe instead of top div and place inner layers in the separate
page:
<iframe id="frm" scrolling="yes" src="innerlayers.htm" .....
and then call document.getElementById("frm").contentWindow.scrollTo()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top