Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Using jQuery Plugins Add a Sticky Navigation Bar The Plugin Challenge Solution

Dave Harrison
seal-mask
.a{fill-rule:evenodd;}techdegree
Dave Harrison
Front End Web Development Techdegree Student 7,400 Points

How would you resize topSpacing for smaller screen sizes

For mobile screen sizes the menu buttons are covered by the 2nd sticky element. How would you resize topSpacing for smaller screen sizes?

1 Answer

Steven Parker
Steven Parker
231,236 Points

I haven't used "sticky" myself but I would first check the documentation in case there is a parameter that you can set that will make that part responsive also.

But as a last resort, you could create your own "faux media query" by setting different values based on the current window. Something like this, for example:

$('work').sticky({
  topSpacing: window.innerWidth > 1200 ? 60 :
              window.innerWidth >  800 ? 45 : 30,
   /* other settings */
});