Give help. Get help.

  • # January 9, 2013 at 4:32 pm

    Hi, I’m trying to add padding to the top of the h1 and h2 headers at this site when they are clicked. When the navbar is collapsed (i.e. < 980px) padding is added. But when the navbar is full width, it is not. I tried this script, but it’s not working $(document).ready(function() {
    $(‘.nav li a’).click(function() {
    $(‘h1, h2’).appendTo(‘.toppad’);


    .toppad {
    margin-top: 25px;

    I tried to set this up in codepen, but when I click the links, the content disappears.

    # January 9, 2013 at 7:21 pm

    Thanks Josh! That works great! I originally started with addClass but when it didn’t work, switched to AppendTo…I had some other things wrong in the code though, which I have since fixed.

    Once again, though I need this only to work for 980px and higher as Bootstrap appears to already add top padding to the headers when the nav bar is collapsed. I tried using some of the code from the other script you are helping me with (removing the Overlay function) but that didn’t work.

    # January 10, 2013 at 11:55 am

    Just can’t get the width thing to work…this removes all the padding for all widths…Tried a variation of this yesterday with the same result.

    # January 10, 2013 at 8:35 pm

    Looks like this is resolved, thanks to an answer posted here:

    Thanks so much for your help!

    $(document).ready(function() {
    var width = $(window).width();
    if (width > 979 ) {
    $(‘.nav li a’).click(function() {
    $(‘h1, h2’).addClass(‘toppad’);

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.