Fixed page header overlaps in-page anchors

前端 未结 30 3498
逝去的感伤
逝去的感伤 2020-11-22 00:25

If I have a non-scrolling header in an HTML page, fixed to the top, having a defined height:

Is there a way to use the URL anchor (the #fragment part) t

30条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 00:57

    I think this approach is more useful:

    Bar

    [id]:target {
        display: block;
        position: relative;
        top: -120px;
        visibility: hidden;
    }
    
    [id]:target::before {
        content: attr(title);
        top: 120px;
        position: relative;
        visibility: visible;
    }
    

提交回复
热议问题