Is there a way to margin an anchor in css?

前端 未结 5 1110
你的背包
你的背包 2021-02-12 12:18

I have a fixed header height 50px. In my body, I have a lot of anchors. The problem is that, when I click on links pointing to anchors, the anchor appears under my fixed header

5条回答
  •  悲哀的现实
    2021-02-12 12:36

    // For modern browsers, just add the CSS3 :target selector to the page. 
    // This will apply to all the anchors automatically.
    // ref: http://stackoverflow.com/a/21707103/6220029
    
    :target {
        display: block;
        position: relative;
        top: -120px; 
        visibility: hidden;}
    

提交回复
热议问题