解决锚定位被fixed遮挡

April 05, 2021

需求:锚定位元素跳转后会到达视口顶部时,不让fixed布局的导航栏遮挡

HTML

<header></header>
<a id="anchor"></a>

CSS

header{
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9;
  width:100%;
  height: 60px;
}

#anchor {
  display: block;
  position: relative;
  top: -60px;
  visibility: hidden;
}

Category

CSS

You may also like

水平垂直居中 插入svg的方法

Comments (2)

Leslie:

test

September 13, 2023
lcr:

test

November 08, 2023

Leave a comment

Sending failed, please try again.
Sending succeeded! It will be displayed in one minute, please refresh.
Newer Older