html - <header> 中的链接不可点击

标签 html css header

我有以下问题

如果我在页眉中放置了可点击的图片,您将无法点击它。 (或公共(public)链接,两者都不起作用)

当我尝试在 header 之外重新定位图像时 - 它起作用了。 但是,当它仍在 header 中时,您无法点击它。

header {
  position: relative;
  width: 100%;
  height: 80px;
  background-color: #454d58;
  margin: 0 auto 0 auto;
  z-index: -10;
  min-width: 100%;
}
li {
  position: absolute;
  top: 25px;
}
<body>
  <header>
    <ul>
      <li>
        <a href="#">
LINK
</a>
      </li>
    </ul>
  </header>
</body>

最佳答案

您的 header 上有一个负的 z-index,将其更改为正的或将其删除。

z-index 在堆叠上下文顺序中变得更低,因此您将无法点击它

header {
  position: relative;
  width: 100%;
  height: 80px;
  background-color: #454d58;
  margin: 0 auto;
  z-index: 1; /*whatever you need - want here - or just remove it */
  min-width: 100%;
}
li {
  position: absolute;
  top: 25px;
}
<body>
  <header>
    <ul>
      <li>
        <a href="#">
LINK
</a>
      </li>
    </ul>
  </header>
</body>

关于html - &lt;header&gt; 中的链接不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41572865/

相关文章:

html - 在一个序列中放置两个元素

javascript - 为什么我的 Javascript 变量没有初始化?

css - 2 列 100% 高度使用 HTML

html - 阻止 Firefox 中圆形按钮在圆外可点击

header - SystemC 和 Verilog 之间的通用头文件

android - 获取 ListView / View 中第一个项目的可见高度

html - 如何防止内容消失在固定标题后面?

javascript - 物化日期选择器不工作

html - 将类选择器与 ID 组合

css - CSS 标签限定(例如 h1.some-class)有什么问题?