【发布时间】:2019-06-01 13:35:22
【问题描述】:
我试图在我的主 div 上悬停时触发多个悬停效果。我无法弄清楚如何使线条同时在所有三个链接上制作动画,以及这是否可以仅在 css 中完成,或者我是否必须使用 javascript,并且我找不到以前帖子的正确解决方案。代码如下:
.right-project-headline h2 a {
text-decoration: none;
color: black;
position: relative;
}
.right-project-headline h2 a::before, .right-project-headline h2 a::after {
content: '';
background: black;
position: absolute;
top: 55%;
height: 3px;
width: 0;
}
.right-project-headline h2 a::before {
left: 0;
}
.right-project-headline h2 a::after {
right: 0;
transition: width 500ms ease;
}
.right-project-headline h2 a:hover::before {
width: 100%;
transition: width 500ms ease;
}
.right-project-headline h2 a:hover::after {
width: 100%;
background: transparent;
transition: 0;
}
<div class="right-project-headline">
<h2><a href="industrial-rev.html">The</a></h2>
<h2><a href="industrial-rev.html">Industrial</a></h2>
<h2><a href="industrial-rev.html">Revolutions</a></h2>
</div>
【问题讨论】: