【问题标题】:bottom-border hover transition下边框悬停过渡
【发布时间】:2017-06-22 07:43:03
【问题描述】:

谁能告诉我怎么做一个border-bottom从下到上的悬停效果?

源:http://www.sony.com/electronics/playstation

【问题讨论】:

  • 嗨。您是否有一些与您合作的 html 和 css 代码可以发布。

标签: css effect


【解决方案1】:

这是一个使用pseudo元素::after的简单示例

使用这个有利于border-bottom的好处,它不会上下移动元素

a {
  position: relative;
  padding: 10px 20px;
}
a::after {
  content: ' ';
  position: absolute;
  left: 0;
  bottom: -5px;
  width: 100%;
  height: 0;
  background: blue;
  transition: height 0.3s;
}
a:hover::after {
  height: 5px;
  transition: height 0.3s;
}

a + a::after {
  content: ' ';
  position: absolute;
  left: 0;
  bottom: -5px;
  width: 0;
  height: 5px;
  background: blue;
  transition: width 0.3s;
}

a + a:hover::after {
  width: 100%;
  transition: width 0.3s;
}
<a> Hover me </a> <a> Hover me 2 </a>

【讨论】:

    猜你喜欢
    • 2021-08-13
    • 2022-01-21
    • 1970-01-01
    • 2018-01-22
    • 2021-05-17
    • 2014-04-10
    • 1970-01-01
    • 2021-08-29
    相关资源
    最近更新 更多