gpt4 book ai didi

html - 在悬停动画 : Icon must get closer to the text, 现在它以相反的方式工作

转载 作者:太空宇宙 更新时间:2023-11-04 09:45:11 25 4
gpt4 key购买 nike

我想要的:悬停时,如果“>”移近文本,我希望链接播放一个动画。

我有什么:动画有效,但文本是靠近“>”的那个。我知道为什么会这样,但我不知道如何解决。如果图标在右侧,这应该很容易。

HTML:

<a href="#">Lees Meer</a>

CSS:

a {
color: #0079D3;
font-weight: 700;
text-decoration: none;
}

a::before {
content: '\f054';
display: inline-block;
font-family: 'FontAwesome';
font-size: 0.65rem;
margin-right: 1rem;
}

a:hover {
color: #003082;
}

a:hover::before {
margin-right: 0.5rem;
}

最佳答案

最简单的方法是将图标设置为绝对定位,在链接上为图标添加间距,然后使用left属性移动图标。

a {
color: #0079D3;
font-weight: 700;
text-decoration: none;
position: relative;
padding: .5rem 1.5rem;
}

a::before {
content: '\f054';
display: inline-block;
font-family: 'FontAwesome';
font-size: 0.65rem;
margin-right: 1rem;
position: absolute;
left: 0;
}

a:hover {
color: #003082;
}

a:hover::before {
left: 0.5rem;
}
<a href="#">Lees Meer</a>

关于html - 在悬停动画 : Icon must get closer to the text, 现在它以相反的方式工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39538026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com