粘贴菜单后,CSS粘贴菜单链接不起作用

时间:2018-11-30 05:20:19

标签: css jsfiddle sticky

JSFiddle code here

我正在尝试制作仅CSS的粘滞菜单(没有JavaScript)。向下滚动时,将鼠标悬停在菜单项上将不再起作用。我不确定为什么不这样做。

CSS:

* {
  margin: 0;
  padding: 0;
}

.row {
  background: #f8f9fa;
  margin-top: 20px;
}

.col {
  border: solid 1px #6c757d;
  padding: 10px;
}

body {
  max-width: 960px;
  margin: auto;
}

.cont2 h1 {
  background: black;
  color: lightskyblue;
  padding: 10px;
}

.cont2 nav ul {
  list-style-type: none;
  background: lightskyblue;
  padding: 20px;
}

.cont2 nav ul li {
  display: inline-block;
}

.cont2 nav ul li a {
  text-decoration: none;
  padding: 20px;
  color: black;
  text-transform: uppercase;
}

.cont2 nav ul li a:hover {
  background: black;
  color: orange;
}

.sticky-nav {
  position: sticky;
  box-sizing: border-box;
  top: 0;
}

我不在这里发布HTML,因为它太多了。

1 个答案:

答案 0 :(得分:1)

您需要将some value设置为课程socks -D

这是更新的代码段:

z-index:1;
.sticky-nav