简体   繁体   中英

Making sticky sidebar responsive?

I have a sticky sidebar but can't make it go to the bottom of the page when a media query is triggered.

It's working really well on desktop, but when resizing the page it will have a fixed position in top of everything.

<script>$.lockfixed("#spot_menu",{offset: {top: 0, bottom: 300}});</script>

I want it to have a relative position but CSS media query wont work in my media query:

#spot_menu { position: relative; }

Any idea of how to do this? Thank you

Something like (where x is the value you are checking against):

var height = $(window).height();

if(height === x) {
  ...
}

You could also use $(window).width() depending on what you are measuring.

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