CSS: When the mouse is hovering, the text moves slowly from left to right.

Please add image description
To achieve the overall text moving slowly from left to right when the mouse is hovering, you can use the CSS transition and transform properties to achieve this effect. Here's an example of how to smooth the overall horizontal displacement of text on mouseover:

<!DOCTYPE html>
<html>
<head>
<style>
  .hover-effect {
    
    
    display: inline-block;
    transition: transform 0.3s ease; /* 添加平滑的过渡效果 */
  }

  .hover-effect:hover {
    
    
    transform: translateX(10px); /* 在悬停时水平向右移动10像素 */
  }
</style>
</head>
<body>


<p>将鼠标悬停在下面的文字上,看看效果:</p>
<p><span class="hover-effect">这是一个示例文本。</span></p>

</body>
</html>

In the above example, a span element with the .hover-effect class is used. In the .hover-effect class, a transition effect is set, and the transition time and easing function of the transform attribute are specified.

When the mouse is hovering over the .hover-effect element, through the :hover pseudo-class, we apply translateX(10px) in the transform attribute, which will move the overall text horizontally to the right by 10 pixels.

Guess you like

Origin blog.csdn.net/yyyyyyyyyyy_9/article/details/132269871