公告:魔扣目录网为广大站长提供免费收录网站服务,提交前请做好本站友链:【 网站目录:https://www.morko.net 】, 免友链快审服务(50元/站),

点击这里在线咨询客服
新站提交
  • 网站:51998
  • 待审:31
  • 小程序:12
  • 文章:1030137
  • 会员:747

在 CSS 中,“text-decoration”属性用于给文本添加下划线、上划线和删除线。

在文本下划线表示在文本下方画一条线,在文本上划线表示在文本上方画一条线。删除文本意味着在文本上画一条线以显示文本已被删除。

在本教程中,我们将学习使用 text-decoration CSS 属性的不同值来设置不同的文本样式。

语法

text-decoration: style decoration color thickness;

登录后复制

值

    Style——代表装饰线的风格,如实线、点线、波浪线等

    装饰-它可以用“下划线”、“上划线”和“穿过线”值来装饰文本。

    颜色 – 设置装饰线的颜色。

    粗细——用于设置装饰线的粗细。

    示例

    在下面的示例中,我们使用“text-decoration”CSS 属性来装饰文本。我们设置了“实线”线条样式、红色“下划线”装饰和 5px 粗细,用户可以在输出中观察到。

    <html>
    <head>
       <style>
          .text {
             font-size: 1.2rem;
             text-decoration: solid underline red 5px;
          }
       </style>
    </head>
    <body>
       <h3> Setting the underline to the text using the 'text-decoration' property in CSS </h3>
       <div class = "text">
          This is a text with an underline.
       </div>
    </body>
    </html>
    

    登录后复制

    示例

    在下面的例子中,我们使用蓝色上划线的方式装饰了文本。在输出中,用户可以观察文本上方的蓝线。

    <html>
    <head>
       <style>
          .text {
             font-size: 1.2rem;
             text-decoration: wavy overline blue 5px;
          }
       </style>
    </head>
    <body>
       <h3> Setting the <i> overline to the text </i> using the 'textdecoration' property in CSS </h3>
       <div class = "text">
          This is a text with an overline.
       </div>
    </body>
    </html>
    

    登录后复制

    示例

    在此示例中,我们使用了“text-decoration”CSS 属性和“line-through”值来删除文本。在输出中,用户可以观察文本上方的行。这样,我们就可以在不删除文本的情况下显示文本中存在错误。

    <html>
    <head>
       <style>
          .text {
             font-size: 2rem;
             text-decoration: dotted line-through green 5px;
          }
       </style>
    </head>
    <body>
       <h3> Setting the <i> strickthrough to the text </i> using the 'textdecoration' property in CSS </h3>
       <div class = "text">
          This is a text with a strikethrough.
       </div>
    </body>
    </html>
    

    登录后复制

    示例

    在此示例中,我们创建了三个具有不同文本的不同 div 元素。我们为每个 div 元素的文本使用了不同的装饰风格。在输出中,用户可以观察“下划线”、“上划线”和“穿线”文本装饰样式之间的差异。

    <html>
    <head>
       <style>
          .underline {
             color: grey;
             text-decoration: solid underline yellow 2px;
             font-size: 1.5rem;
          }
          .overline {
             text-decoration: solid overline yellow 3px;
             font-size: 1.5rem;
          }
          .strikethrough {
             text-decoration: solid line-through yellow 2px;
             font-size: 1.5rem;
          }
       </style>
    </head>
    <body>
       <h3> Setting the strikethrough, underline, and overline to the text using the 'text-decoration' property in CSS </h3>
       <div class = "underline"> underline </div>
       <div class = "overline"> overline </div>
       <div class = "strikethrough"> strike through </div>
    </body>
    </html>
    

    登录后复制

    结论

    本教程教用户如何使用“text-decoration”CSS 属性来装饰文本。用户可以根据需要使用不同的值对文本进行不同的装饰。

    以上就是哪个属性用于使用 CSS 为文本添加下划线、上划线和删除线?的详细内容,更多请关注www.92cms.cn其它相关文章!

分享到:
标签:下划线 划线 属性 文本 用于
用户无头像

网友整理

注册时间:

网站:5 个   小程序:0 个  文章:12 篇

  • 51998

    网站

  • 12

    小程序

  • 1030137

    文章

  • 747

    会员

赶快注册账号,推广您的网站吧!
最新入驻小程序

数独大挑战2018-06-03

数独一种数学游戏,玩家需要根据9

答题星2018-06-03

您可以通过答题星轻松地创建试卷

全阶人生考试2018-06-03

各种考试题,题库,初中,高中,大学四六

运动步数有氧达人2018-06-03

记录运动步数,积累氧气值。还可偷

每日养生app2018-06-03

每日养生,天天健康

体育训练成绩评定2018-06-03

通用课目体育训练成绩评定