【问题标题】:Angular Directive for sliding long text from side to side用于将长文本从一侧滑动到另一侧的 Angular 指令
【发布时间】:2017-01-12 13:46:12
【问题描述】:

有没有人知道在 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;
    }

【问题讨论】:

    标签: javascript jquery html css angularjs


    【解决方案1】:

    我个人知道的唯一替代方法是使用 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>  

    【讨论】:

    • 抱歉,我不太明白这个示例如何帮助查看长文本。我的意思是,悬停时,如何使文本向右滚动?
    【解决方案2】:

    请使用 CSS:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      • 2020-11-08
      • 1970-01-01
      • 1970-01-01
      • 2016-08-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多