【问题标题】:switching out link text on hover - transition在悬停时切换链接文本 - 过渡
【发布时间】:2015-05-31 07:55:17
【问题描述】:

寻找一个简单的解决方案来替换 :Hover 上的链接上的文本。我想要一个轻微的过渡(文本从下面出现),如果 java 关闭,只需替换常规。

HTML

<div class="bot-text">
  <a href="">Go here</a>
  <a href="">Or go here</a>
</div>

CSS

.bot-text a  {
  font: 600 15px/20px 'Open Sans', sans-serif;
  color: #383737;
  position: relative;
  display: inline-block;
  border: 2px solid #383737;
  padding: 25px;
  margin: 10px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
}

这将创建一个带有边框和填充的文本按钮。在悬停时,我希望文本更改为其他内容(总是更少的文本)。我希望文本用悬停时从底部向上滑动来替换当前链接文本。

【问题讨论】:

    标签: javascript jquery html css


    【解决方案1】:

    尝试使用:after伪元素

    .bot-text a  {
      font: 600 15px/20px 'Open Sans', sans-serif;
      color: #383737;
      position: relative;
      display: inline-block;
      border: 2px solid #383737;
      padding: 25px;
      margin: 10px;
      -webkit-border-radius: 5px;
      -moz-border-radius: 5px;
      border-radius: 5px;
    }
    
    .bot-text a:hover {
      color:transparent;
    }
    
    .bot-text a:hover:after {
      opacity:0;
      position:absolute;
      left:40%;
      color:blue !important;
      content:"abc";
      animation: slideup 1s ease-in 0s forwards;
      -moz-animation: slideup 1s ease-in 0s forwards;
      -webkit-animation: slideup 1s ease-in 0s forwards;
    }
    
    @keyframes slideup {
      from {
        top:50px;
      }
      to {
        top:25px;
        opacity:1;
      }
    }
    
    @-moz-keyframes slideup {
      from {
        top:50px;
      }
      to {
        top:25px;
        opacity:1;
      }
    }
    
    @-webkit-keyframes slideup {
      from {
        top:50px;
      }
      to {
        top:25px;
        opacity:1;
      }
    }
    <div class="bot-text">
      <a href="">Go here</a>
      <a href="">Or go here</a>
    </div>
    猜你喜欢
    • 2015-05-18
    • 2021-01-24
    • 2019-09-03
    • 2021-05-22
    • 2016-09-10
    • 2022-01-26
    • 2017-02-23
    • 2023-04-10
    • 2015-08-05
    相关资源
    最近更新 更多