用于从一边到另一边滑动长文本的Angular指令

Angular Directive for sliding long text from side to side

本文关键字:文本 Angular 指令 另一边 用于      更新时间:2023-09-26

有人知道当鼠标悬停在HTML元素上时滑动长文本的Angular指令吗?如果可能的话,我不喜欢使用jQuery插件。

目前,文本被截断使用css,但我希望能够显示剩余的字符给用户当悬停在它。

我们也欢迎任何替代方案。

我的Html:

<div class="name"><span>{{ field.name }}</span>

我的CSS:

span {
     padding: 0 10px;
    font-size: 16px;
    font-weight: 100;
    line-height: 32px;
    text-overflow: ellipsis;
    overflow: hidden;
    display: block;
    white-space: nowrap;
    }

我个人知道的唯一替代方法是使用CSS:

body{
  background-color: lightgrey;
}
.blue-btn{
  
  position:absolute;
  left:35%;
  top:40%;
}
.blue-btn a{
  color: white;
  text-decoration:none;
  margin-top: 0em;
  text-align: center;
  display:inline-block; /* important */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.blue-btn, .first-link{
  -webkit-transition: 3.3s;
  -moz-transition: 3.3s;
  transition: 3.3s;     
  
  -webkit-transition-timing-function: linear;
  -moz-transition-timing-function: linear;
  transition-timing-function: linear;
}
.blue-btn{
  height: 64px;
  font: normal normal 700 1em/4em Arial,sans-serif;
  overflow: hidden;
  width: 200px;
  background-color: #3b5998;
}
.blue-btn:hover{
   background-color: #003D99;
}
.blue-btn a:hover{
  text-decoration: none;
}
.first-link{
  margin-left: 0em;   
}
.blue-btn:hover .first-link{
  margin-left: -300px;
}
<html>
  <body>
    <div class="blue-btn">
      <a class="first-link" href="">
      This is a very long text, it will take a long time to reach the end
      </a>
    </div>
  </body>
</html>  

请使用CSS:

<style>
    span {
    padding: 0 10px;
    font-size: 16px;
    font-weight: 100;
    overflow-y: hidden;
    display: block;
    white-space: nowrap;
    width: 50px;
    }
 </style>