By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,605 Members | 2,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,605 IT Pros & Developers. It's quick & easy.

scroll two layers together

P: n/a
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)?

Sep 1 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

ma*****@hotmail.com написав:
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:100p x;height:50px;background-color:blue">top
layer</div>
</div>
</div>
</body>
</html>

Sep 1 '06 #2

P: n/a
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

Sep 2 '06 #3

P: n/a

ma*****@hotmail.com написав:
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.scrol lTo()

Sep 5 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.