【问题标题】:I want an anchor to move to the right when i hover over it with an ease in animation当我将鼠标悬停在锚点上时,我希望锚点向右移动,并且动画很轻松
【发布时间】:2019-06-19 22:10:42
【问题描述】:

基本上,当我将鼠标悬停在锚点上方时,我希望锚点以流畅的动画向右移动。我在锚点之前设置了一个“>”,我不想移动它。我设法在我不久前创建的一个网站上做到了这一点,但丢失了文件并且不记得如何做到这一点。希望得到一些帮助。

a::before {
    content: ">";
    color: black;
}

a:hover {
    right: -2px;
}

【问题讨论】:

    标签: css css-animations


    【解决方案1】:

    您需要正确的选择器。 a:hover:before 在标签悬停时选择:before 伪元素。

    这假设您这里缺少更多代码。

    a:before {
        content: ">";
        color: black;
    }
    
    a:hover:before {
        right: -2px;
    }
    

    【讨论】:

    • 是的,什么也没做
    【解决方案2】:

    类似这样的:

    a::before {
      content: ">";
      color: black;
      display: inline-block;
      padding-right: 0;
      transition: all 1s ease;
    }
    
    a:hover::before {
      padding-right: 5px;
    }
    <a href="#">Linky</a>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-07
      • 2022-12-09
      • 1970-01-01
      • 2021-03-04
      • 1970-01-01
      相关资源
      最近更新 更多