简体   繁体   中英

How can I assign a max limit to margin-top

I have a div floating at the right side of the page. Using a plugin, it goes up and down when the window is scrolled vertically.

      upwards
        ^
        |
        |

-------------------
|                  |
|   The scrollable |
|      DIV         |
|                  |   
--------------------
        |
        |

     downwards

The scrollable DIV is like a Cart Summary Box. The problem is that when the scroll is made the div keeps scrolling down until you keep scrolling. I want to set a dynamic maximum margin-top for it. The scrolling is happening because of the change in its margin-top. Is there anyway, I can restrict that to happen? The page contains other elements on the left which can shrink or expand. I want the max scrollable height to be adjusted accordingly to the height of parent div.

Thanks for a thought.

Well it's almost impossible to tell you how to fix that without you posting some code.

I would recommend you use jQuery Stick'em to achieve that

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM