bottom-border hover transition

你。 提交于 2019-12-29 02:01:30

问题


Can any one tell me how to do a border-bottom hover effect from bottom to top?

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


回答1:


Here is a simple sample using the pseudo element ::after

The advantage using this in favor of the border-bottom, it will not move the element up and down

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>


来源:https://stackoverflow.com/questions/42049603/bottom-border-hover-transition

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!