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

Warren Leyes
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Warren Leyes
Front End Web Development Techdegree Graduate 31,323 Points

why not target '.grid-full h5' ?

I was wondering why on the solution he didn't just target '.grid-full h5' or addClass() ? I found that by targeting grid-full h5 I only needed to adjust the font color in CSS as I was happy with the pre-set white with alpha (Thinking I might use an rgba instead for color) and found it super easy to get the sticky to function as it should. as for the position: I used the dev tools to confirm the header bar height and went off of that.

my full solution: https://w.trhou.se/asbo1y32sy

$('.header').sticky({
  getWidthFrom: '.container',
  responsiveWidth: true
}).on('sticky-start', function(){
  $('.description').html('We build <strong>great</strong> apps');
}).on('sticky-end', function(){
  $('.description').html('We build apps');
});

$('.grid-full h5').sticky({
  topSpacing: 64,
}).on('sticky-start', function(){
  $('.grid-full h5').append(' <a href="mailto:webmaster@example.com">Email us</a>')
}).on('sticky-end', function(){
  $('.grid-full h5').html('Want us to work on your project?');
});

I did the same, and didn't have to modify any of the CSS either.

I guess if there were other areas using the h5 within the "grid-full" div, or if there was potential for more h5's to be added to it, this could cause an issue that would be avoided by doing it the way shown, but for this example I guess it's fine