热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何使用border-bottom为链接加下划线设置动画,以便链接文本和下划线之间有空格?

如何解决《如何使用border-bottom为链接加下划线设置动画,以便链接文本和下划线之间有空格?》经验,为你挑选了2个好方法。

如何使用border-bottom为链接加下划线设置动画,以便文本和下划线之间有空格?

我知道如何以下面的方式执行它,以便默认的text-decoration元素是动画的.但是我希望链接和下划线之间有空格,这就是为什么我认为我需要使用border-bottom.但我无法通过过渡动画获得边框底部的工作.我怎么能这样做?我试着寻找其他解决方案,但找不到任何解决方案.谢谢!

h2 > a {
  position: relative;
  color: #000;
  text-decoration: none;
}

h2 > a:before {
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #000;
  visibility: hidden;
  -webkit-transform: scaleX(0);
  transform: scaleX(0);
  -webkit-transition: all 0.3s ease-in-out 0s;
  transition: all 0.3s ease-in-out 0s;
}

h2 > a:hover:before {
  visibility: visible;
  -webkit-transform: scaleX(1);
  transform: scaleX(1);
}

G-Cyr.. 11

你可以通过背景和背景大小伪造一个动画边框:

a {
  padding-bottom: 5px;
  /* set here size + gap size from text */
  background: linear-gradient(0deg, currentcolor, currentcolor) bottom center no-repeat;
  background-size: 0px 3px;
  transition: 0.5s;
  text-decoration: none;
}

a:hover {
  background-size: 100% 3px;
}

a[class] {
  color: gray;
}

a.tst {
  color: purple;
  background: linear-gradient(0deg, currentcolor, currentcolor) bottom center no-repeat, linear-gradient(0deg, turquoise, turquoise) center calc(100% - 2px) no-repeat;
  background-size: 0px 2px;
}

a.tst:hover {
  background-size: 100% 2px;
}
kake animated border
 why currentcolor ?
mix of colors ?



1> G-Cyr..:

你可以通过背景和背景大小伪造一个动画边框:

a {
  padding-bottom: 5px;
  /* set here size + gap size from text */
  background: linear-gradient(0deg, currentcolor, currentcolor) bottom center no-repeat;
  background-size: 0px 3px;
  transition: 0.5s;
  text-decoration: none;
}

a:hover {
  background-size: 100% 3px;
}

a[class] {
  color: gray;
}

a.tst {
  color: purple;
  background: linear-gradient(0deg, currentcolor, currentcolor) bottom center no-repeat, linear-gradient(0deg, turquoise, turquoise) center calc(100% - 2px) no-repeat;
  background-size: 0px 2px;
}

a.tst:hover {
  background-size: 100% 2px;
}
kake animated border
 why currentcolor ?
mix of colors ?


2> Ori Drori..:

您提供的代码使用伪元素而不是默认的文本修饰.由于伪元素绝对定位,您可以轻松更改距离.将a:before底部更改为-5px或任何负值适合您想要的距离:

a {
  position: relative;
  color: #000;
  text-decoration: none;
}

a:before {
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: -5px;
  left: 0;
  background-color: #000;
  visibility: hidden;
  -webkit-transform: scaleX(0);
  transform: scaleX(0);
  -webkit-transition: all 0.3s ease-in-out 0s;
  transition: all 0.3s ease-in-out 0s;
}

a:hover:before {
  visibility: visible;
  -webkit-transform: scaleX(1);
  transform: scaleX(1);
}
Long long text

推荐阅读
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • 一、选择器CSS规则由选择器以及声明组成。*选择器分组*h1,h2,h3{}*后代选择器*pem{}*子元素选择器*pem{}*兄弟选择器(选择位于其后具有相同父元素的元素)*h ... [详细]
  • 在DIV内垂直居中UL - Centering Vertically an UL inside a DIV
    iamtryingtomakeanavigationmenuinsidea200pxx200pxsquare,thisnavigationlist(UL)chang ... [详细]
  • 本文整理了常用的CSS属性及用法,包括背景属性、边框属性、尺寸属性、可伸缩框属性、字体属性和文本属性等,方便开发者查阅和使用。 ... [详细]
  • 本文由编程笔记#小编为大家整理,主要介绍了css回到顶部按钮相关的知识,希望对你有一定的参考价值。 ... [详细]
  • pytorch Dropout过拟合的操作
    这篇文章主要介绍了pytorchDropout过拟合的操作,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完 ... [详细]
  • 我正在使用ChemDoodleWebComponents在网页上显示分子。基本上,我可以在我的页面中插入以下脚本,它将创建一个HTML5canvas元素来显示分子。vartrans ... [详细]
  • JavaScript实现拖动对话框效果
    原标题:JavaScript实现拖动对话框效果代码实现:<!DOCTYPEhtml><htmllan ... [详细]
  • HTML制作简单首页导航
    h1大标题:李广程的作业列表查看演示地址一:http:js.lgcweb.cn查看演示备用地址:http:39.105.0.128Ja ... [详细]
  • Jq制作的页面顶部动态弹出的提示框,可以用于提示信息的显示以及通知信息的显示。Html代码 ... [详细]
  • 前端实用的CSS3技巧有哪些
    本文小编为大家详细介绍“前端实用的CSS3技巧有哪些”,内容详细,步骤清晰,细节处理妥当,希望这篇“前端实用的CSS3技巧有哪些”文章能帮助大家 ... [详细]
  • packagecom.lihong.DDPush.pms;importcom.lihong.DDPush.mybatis.Parser;importorg.junit.Test;impor ... [详细]
  • 学习过程-京东注册的静态界面
    HTML源代码:<!DOCTYPEhtml><html><head><title>京东注册<title><me ... [详细]
  • CSS基础复习昨天知识Css层叠样式表(级联样式表)Css的作用就是美好html标签。2.书写位置 ... [详细]
  • CSS超链接和导航
    在CSS中设置超链接样式之前我们在HTML中用标签来表示超链接通过点击跳转到另一个页面在CSS中可以通过伪类选择对超链接访问时不同状态进行设定:a:link:未被访问过的超链接样式 ... [详细]
author-avatar
漫猪傻滑_679
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有