css中文字下面怎么加横线

admin 轻心小站 关注 LV.19 运营
发表于前端技术学习版块 css,教程

在一些网页设计中,我们可能需要对一些文本增加下划线来加强视觉效果。那么在CSS中,我们该如何实现这个效果呢? /* 基础样式 */ .text-underline { text-decoration:

在一些网页设计中,我们可能需要对一些文本增加下划线来加强视觉效果。那么在CSS中,我们该如何实现这个效果呢?

 /* 基础样式 */
  .text-underline {
    text-decoration: underline;
  } 

上面的代码可以实现文本下方展示一条横线的效果。

 /* 换行去除横线 */
  .text-underline {
    text-decoration: underline;
    text-underline-position: under;
  } 

如果不想让横线占用整行的空间,可以设置text-underline-position为under,使下划线位置在文本下面,而不是在整个行的底部。

 /* 颜色样式 */
  .text-underline {
    text-decoration: underline;
    color: #333;
    text-underline-position: under;
  } 

我们可以通过设置color属性,改变下划线的颜色。

 /* 完整样式 */
  .text-underline {
    text-decoration: underline;
    color: #333;
    text-underline-position: under;
    text-underline-offset: 3px;
  } 

还可以通过text-underline-offset属性,控制下划线的偏移量。

以上就是CSS中实现文本下方增加横线的方法。

文章说明:

本文原创发布于探乎站长论坛,未经许可,禁止转载。

题图来自Unsplash,基于CC0协议

该文观点仅代表作者本人,探乎站长论坛平台仅提供信息存储空间服务。

评论列表 评论
发布评论

评论: css中文字下面怎么加横线

粉丝

0

关注

0

收藏

0

已有0次打赏