当悬停在导航项目下方时(*除了第一个),指示器就开始来回闪烁并出现错误!

值得一提的是,实际代码是One的站点是WordPress站点,语言是 hebrew ,所以它是从右到左的,不确定这是否会改变什么……

代码:Nav menu link

原始html和css:

nav {
  background-color: #fff;
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  width: 100%;
  display: table;
  transform: translateY(-50%);
  margin: 0 auto;
}

nav a {
  position: relative;
  width: 25%;
  display: table-cell;
  text-align: center;
  color: #444;
  text-decoration: none;
  font-family: Assistant;
  font-weight: light;
  padding: 10px 20px;
  transition: 0.4s ease color;
}

nav a:before,
nav a:after {
  content: "";
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  transition: 0.5s ease transform;
}

nav a:before {
  top: 0;
  left: 37%;
  width: 6px;
  height: 6px;
}

nav a:after {
  top: 5px;
  left: calc(37% + 12px);
  width: 4px;
  height: 4px;
}

nav a:nth-child(1):before {
  background-color: rgb(255, 199, 44);
}

nav a:nth-child(1):after {
  background-color: rgb(216, 215, 195);
}

nav a:nth-child(2):before {
  background-color: rgb(216, 215, 195);
}

nav a:nth-child(2):after {
  background-color: rgb(125, 185, 179);
}

nav a:nth-child(3):before {
  background-color: rgb(125, 185, 179);
}

nav a:nth-child(3):after {
  background-color: rgb(22, 102, 120);
}

nav a:nth-child(4):before {
  background-color: rgb(22, 102, 120);
}

nav a:nth-child(4):after {
  background-color: rgb(14, 46, 59);
}

#indicator {
  position: absolute;
  right: 10%;
  bottom: 0;
  width: 5%;
  height: 3px;
  background-color: #aaa;
  border-radius: 5px;
  transition: 0.15s ease right;
}

nav a:hover {
  color: #0e2e3b;
}

nav a:hover:before,
nav a:hover:after {
  transform: scale(1);
}

nav a:nth-child(1):hover~#indicator {
  right: 85%;
  background: linear-gradient(130deg, rgb(255, 199, 44), rgb(216, 215, 195));
}

nav a:nth-child(2):hover~#indicator {
  right: 60%;
  background: linear-gradient(130deg, rgb(216, 215, 195), rgb(125, 185, 179));
}

nav a:nth-child(3):hover~#indicator {
  right: 35%;
  background: linear-gradient(130deg, rgb(125, 185, 179), rgb(22, 102, 120));
}

nav a:nth-child(4):hover~#indicator {
  right: 10%;
  background: linear-gradient(130deg, rgb(22, 102, 120), rgb(14, 46, 59));
}
<nav lang="he">
  <a href="#about">about</a>
  <a href="#method">the method</a>
  <a href="#twitter">blog</a>
  <a href="yairgoren.com/en">English</a>
  <div id="indicator"></div>
</nav>

try 一些隐藏指示器并将其悬停在其上的CSS技巧,但不起作用……

推荐答案

施药

#indicator {
  pointer-events: none;
}

...解决了问题.

当您悬停链接时,指示器会在其下方移动并自动悬停.在这一点上,链接不再悬停,指示器移回其原始位置,这使得链接再次悬停,进入无限循环.

因此,使指示器对指针事件透明可以防止闪烁行为,因为当在鼠标位置下转换时,指示器不再能够从链接中窃取:hover.

Html相关问答推荐

弹性项在主轴方向溢出

嵌套表列高度不是100%高度的问题

如何使用html和css关键帧创建动画

禁用的文本区域会丢失换行符

一切停止工作后,添加不透明度(在tailwind )

如何使用*ngFor将模板从父级传递到子级

如何使VS代码支持以模仿嵌套的方式对已经包含注释的HTML进行注释?

如何使背景图像在面包屑中相互重叠

带有数据 URI 的音频在 Chrome 中失败

文本不显示在 div 下方

为什么即使我点击其他地方,我的 contenteditable="true" 也会被激活?

如何使用jQuery将我制作的通用头部和底部加载到多个HTML文件中?

css 网格创建空行和列

屏幕缩小时背景图像裁剪高度

如何将元素均匀分布到容器的边缘?

什么没有 margin-right 和 width:100% 溢出子元素到左边?

子 div 在父 div 中溢出

有没有办法使用 CSS border-radius 创建 HTML 视频标签的三角形显示?

自定义进度条 Html 和 CSS 布局

无法使用 Reactjs 多次更新本地存储