scroll two layers together

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mayla_i@hotmail.com

    scroll two layers together

    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)?

  • marss

    #2
    Re: scroll two layers together


    mayla_i@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:relat ive" 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:300 px;height:300px ">
    <div style="width:50 0px;height:500p x;background-color:red">bott om
    layer
    <div
    style="position :relative;left: 80;top:70;width :100px;height:5 0px;background-color:blue">top
    layer</div>
    </div>
    </div>
    </body>
    </html>

    Comment

    • mayla_i@hotmail.com

      #3
      Re: scroll two layers together

      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

      Comment

      • marss

        #4
        Re: scroll two layers together


        mayla_i@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="innerlayer s.htm" .....
        and then call document.getEle mentById("frm") .contentWindow. scrollTo()

        Comment

        Working...