javascript-html a href jump anchor, you can move down a few ways?

Source: Internet
Author: User
There are settings in the HTML
In other words, "a small piece of button" (the predecessors should be very common)

Use the a herf="#id" anchor point to move the page, but clicking on the link anchor will take the page to "top", meaning that a part will be covered by the "header" part.
How do I move down the anchor point?

Almost like this.
http://segmentfault.com/q/1010000000124208

However, my div ID is generated and of course I have tried some JS

$(function(){   if(location.hash){      var target = $(location.hash);      if(target.length==1){          var top = target.offset().top-100;          if(top > 0){              $('html,body').animate({scrollTop:top}, 1000);          }      }   

Seeking Big Anext

1201 Modify HMTL as follows

    • The world system is my rotten.
    • 36588 system
    • Other systems

      天下系統我最爛    

Reply content:

There are settings in the HTML


In other words, "a small piece of button" (the predecessors should be very common)

Use the a herf="#id" anchor point to move the page, but clicking on the link anchor will take the page to "top", meaning that a part will be covered by the "header" part.
How do I move down the anchor point?

Almost like this.
http://segmentfault.com/q/1010000000124208

However, my div ID is generated and of course I have tried some JS

$(function(){   if(location.hash){      var target = $(location.hash);      if(target.length==1){          var top = target.offset().top-100;          if(top > 0){              $('html,body').animate({scrollTop:top}, 1000);          }      }   

Seeking Big Anext

1201 Modify HMTL as follows

    • The world system is my rotten.
    • 36588 system
    • Other systems

      天下系統我最爛    

If you want to offset to the following, you should only use JS it.

Looked at the first floor of the friend's method, the style of his span tag changed a bit,

.placeholder{display:block; width:100px; height:50px; margin-top:-50px; }

Without the implementation of JS.

Welcome to adopt.

The position:absolute; position of the anchor point is changed using the method of leaving the document flow without affecting the presentation.

http://jsbin.com/teqisuve/5/

PS. Adoption of the downstairs update

Do not jump to the element you want, set an empty element above it, and jump to that

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.