Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Dave Harrison
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
218,813 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:

  topSpacing: window.innerWidth > 1200 ? 60 :
              window.innerWidth >  800 ? 45 : 30,
   /* other settings */