html - 根据类使导航下划线动画化

标签 html css

我有一个.nav-link

.active 添加到它时,它会得到 text-decoration: underline。如何通过从左侧滑入来使此文本装饰动画?

最佳答案

您可以像这样创建和动画自定义下划线。由于您无法为文本装饰设置动画:下划线;

.nav-link:after{
      content: '';
      position: absolute;
      width: 0; height: 3px;
      display: block;
      margin-top: 5px;
      right: 0;
      background: #fff;
      transition: width .2s ease; // this will add animation from left to right.
      -webkit-transition: width .2s ease;
    }

.nav-link:active:after{
  width: 100%;
  left: 0;
  background: #fff;
}

关于html - 根据类使导航下划线动画化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56382911/

相关文章:

javascript - 使用 Javascript 将特定的 div 加载到 iFrame 或 div

css - 响应式设计 : 2 columns of posts, 1 查询,按css排序

python - if 和 elif 在模板 django 中不起作用

html - 如何将 wrapper-div 而不是内容居中

html - 自动完成时透明输入字段变为淡黄色

html - 谷歌图表的 Z-index 和页面上的其他元素

css - :first-child with *ngFor is not working properly

html - 使用 css 选择元素的第一个实例

html - 下拉菜单 : Only words clickable not whole box

javascript - 使用 javascript/jquery 触发文件上传对话框