Margin or Anchor Link Placement

1

I have an anchor link that leads from a button at the top to a certain part of the page, but as my menu accompanies the page, it ends up being cut as in the image below:

HowwouldIdotogiveaspace?Marginorposition,Idonotknow,butIneedthelinktogodownsoitlookslikethis:

I'musingascripttosmoothscroll:

<scripttype="text/javascript">
    jQuery(document).ready(function($) { 
        $(".scroll").click(function(event){        
            event.preventDefault();
            $('html,body').animate({scrollTop:$(this.hash).offset().top}, 800);
       });
    });
    </script>
    
asked by anonymous 04.04.2016 / 14:53

2 answers

1

Place a - 20 after the .top.

scrollTop:$(this.hash).offset().top - 20 

So it positions itself -20 pixels of its element.

    
05.04.2016 / 16:01
0

If you want to achieve the same result using only CSS, just add the following to your style.css or custom.css

:target:before {
content:"";
display:block;
height:90px; /* fixed header height*/
margin:-90px 0 0; /* negative fixed header height */
}

Where 90px is the spacing you want

    
13.04.2018 / 18:02