当悬停在导航项目下方时(*除了第一个),指示器就开始来回闪烁并出现错误!
值得一提的是,实际代码是One的站点是WordPress站点,语言是 hebrew ,所以它是从右到左的,不确定这是否会改变什么……
原始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技巧,但不起作用……