html - 使用CSS从右向左滑动边框

标签 html css sliding

我有一个 header ,希望在悬停时从右向左滑动边框,如果可能的话,请使用纯CSS。

目前,我可以使用以下CSS从左向右滑动边框:

#header a:after {
content: '';
display: block;
border-bottom: 3px solid $(header.hover.color);
width: 0;
-webkit-transition: 1s ease;
        transition: 1s ease;
}

#header a:hover:after { width: 100%; }

有没有人很好的解决方案来完成此任务?

最佳答案

您可以将:after元素放置在右侧

#header {
  position: relative;
}
#header a:after {
  content: '';
  display: block;
  border-bottom: 3px solid red;
  width: 0;
  position: absolute;
  right: 0;
  -webkit-transition: 1s ease;
  transition: 1s ease;
}

#header a:hover:after { 
  width: 100%; 
}

关于html - 使用CSS从右向左滑动边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31180810/

相关文章:

html - WordPress CSS 问题

javascript - 如何强制 Chrome 在固定的高度上向下滚动?

javascript - 沿着半圆形的星级评分

html - 柠檬形状(CSS 和 HTML)

jquery - 按时间改变div位置

ios - 如何在打开新窗口时在钛合金中实现滑动过渡

安卓 slider 拼图

javascript - 每次从函数中得到相同的结果

javascript - 在多个事件处理程序中访问 JQuery 对象

css - 滑动可扩展内嵌菜单