【发布时间】:2016-02-16 23:23:33
【问题描述】:
我已经找到了一些不同的解决方案,但它们都依赖于其中一个元素位于另一个元素中,而我的问题中没有这个。
我做了一点JSFiddle,应该类似于我的问题。当有人悬停“悬停我!”我要“动我!”走向“悬停我!”并且也变得可见。只要“悬停我!”,我就设法让它发挥作用。也随着“移动我!”而向右移动。但我不希望这种情况发生,我想要“悬停我!”留在同一个地方。
查看,悬停在“悬停我!”我要“动我!”变得可见并向右移动到“悬停我!”在同一条线上不动“悬停我!”一点也不。
我们将不胜感激!
div.txtarea {
background-color: gray;
width: 100%;
height: 5em;
position: fixed;
text-align: center;
}
a.hoverme {
text-decoration: none;
color: blue;
font-size: 3em;
display: inline-block;
}
a.moveme {
float: left;
text-decoration: none;
color: blue;
font-size: 3em;
display: inline-block;
opacity: 1; /*THIS IS USUALLY 0 BUT I MADE IT 1 SO WE COULD SEE IT*/
}
a.hoverme:hover > a.moveme {
-webkit-animation: scrollingIn 1.5s linear;
}
@-webkit-keyframes scrollingIn {
0% {
margin-left: 0em;
opacity: 0;
}
50% {
margin-left: 1em;
opacity: .5;
}
100% {
margin-left: 2em;
opacity: 1;
}
}
<div class="txtarea">
<a class="moveme" href="#">
move me!
</a>
<a class="hoverme" href="#">
hover me!
</a>
</div>
【问题讨论】:
-
是的,这就是问题哈哈。有什么办法可以让我更清楚我想要什么?
-
我已将您的代码块转换为 sn-p。这不是强制性的,但我这样做是为了向您展示 sn-p 的工作原理。在工具栏中,只需单击
<>按钮并将代码粘贴到相关框中,就像在 Fiddle 中一样。这有助于将演示直接添加到问题中,从而避免创建小提琴所涉及的额外工作。
标签: html css css-selectors css-animations