CSS删除线

1,776 阅读2分钟

CSS strikethrough

CSS删除线简介

CSS的删除线并不是什么,而是当我们在文件中启用了text-decoration属性,在css中创建具有删除线效果的文本数据。这也是css中的一种动画效果,在一些默认值的帮助下,如line-through是text-decoration属性中提到的默认值之一。我们把它用作内联或与其他样式表有相同效果的内联和外联功能,主要是在

标签中启用的,但选择器意味着我们要对html元素进行格式化。

语法和参数

CSS代码是用样式标签写在html页面上的;我们可以遵循一些规则和语法来使定制的网页更有吸引力。我们使用文本格式类型作为所有的css属性和它们的属性。

<html> <head> <style> .first { Background-color:; Color:; Font-size:; ---some default css properties,attributes and their values based on the requirements---- } </style> </head> <body> <p style=”text-decoration:line-through;”> </p> --some html codes--- </body> </html>

上述代码是文本装饰属性中css删除线值的基本代码;如果用户根据自己的需要改变值,它可能会有所不同。这里的参数是我们可以指定属性中的值,也可以调用代码中的值。

删除线在CSS中是如何工作的?

在CSS样式代码中,我们使用了很多属性,有默认值的属性。它包括文本、数字、特殊字符等;使用这些类型的值,我们可以启用其css属性的特定属性,以使演示更有吸引力。我们可以通过使用一些默认的HTML标签、ID或一些内置的类,在基于文本的html元素中使用css颜色代码。当我们在基于html标签的元素中使用css删除线时,

是html代码中默认和最广泛使用的一种,用于使它们成为css样式的颜色和表现形式,它也有助于CSS中的任何元素。

主要用于html中的标签,因为也在那里声明和初始化,所以标题行可能被我们用于网页中。

接下来,我们可以在html网页中借助span元素来使用css删除线,就像我们使用

标题标签、

标签一样。不过,html中提供的元素是给它默认的ID;这些ID是在样式代码的标题部分声明的;ID可以是任何使用的任何样式,与html标签中使用的一样。然而,重要的一点是ID值应该以特殊字符开始,如'#'符号;之后,我们可以使用任何数量的格式,如字母、数字等。在css中,我们可以在span元素的帮助下使用内联和外联元素的删除线文本;这是css样式表的text-decoration属性中添加删除线的方法之一。它也遵循上述两种方法,但不同的是没有'#'符号。css代码中的符号。

前缀值应该以点运算符开始,否则css代码就不能在html网页中使用,表现在屏幕上。除此之外,同样的类在标签中声明,同样的类名在标签元素中调用,就是类和

元素。这些都是在html网页中声明和初始化css属性的删除线文本值的方式,称为text-decoration元素。

此外,css使用了一组不同的属性,并与文本、颜色、视频等相关,根据一些数据,这些属性 "颜色、方向、字母间距、字间距、文本缩进、文本对齐、文本装饰、文本变换、空白和文本阴影",这些是一些默认的属性,已被用于每个属性的样式代码中,并且它有自己的CSS功能。

CSS删除线的例子

下面的例子提到了以下几点

例子#1

代码。

<!DOCTYPE html> <html> <head> <style> h1 { text-decoration: line-through; } h2 { text-decoration: overline; } h3 { text-decoration: underline overline; } h4 { text-decoration: underline; } </style> </head> <body> <h1>Welcome To My Domain</h1> <h2>Welcome To My Domain</h2> <h3>Welcome To My Domain</h3> <h4>Welcome To My Domain</h4> </body> </html>

输出。

css strikethrough output 1

例子 #2

代码。

<!DOCTYPE html> <html> <head> <title>Welcome To My Domain</title> <style> .first { text-decoration: underline overline; padding: 12px; width: 73%; margin: 2 auto; background-color:"#ffffff"; text-align: center; color: rgb(105%, 0%, 0%); border-radius: 1 2 52px 53px; border: 2px yellow; } .second{ text-decoration: underline; margin: 12px; padding: 13px; color: hsla(0, 105%, 50%, 0.5); border: 3px blue; } .third{ text-decoration: overline; width: 122px; display: inline-block; background-color: blue; } .four{ text-decoration: line-through; text-align: right; } .five{ text-align: center; } .six{ text-align: left; } .eleven { width: 83%; margin: 2 auto; padding: 23px; background: green; } .sam { position: absolute; right: 3px; width: 303px; background-color: yellow; } </style> </head> <body> <div class="first">Siva</div> <div class="second">Raman</div> <div class="third">Arun</div> <p style="color: #ffffff; background-color: #ff0000">Namer is: red, background-color is : blue</p> <div class="five">Sam</div> </body> </html>

输出。

css strikethrough output 2

例子 #3

代码。

<!DOCTYPE html> <html> <head> <title>Welcome To My Domain</title> <style> .first { text-decoration: underline overline; padding: 12px; width: 73%; margin: 2 auto; background-color:"#ffffff"; text-align: center; color: rgb(105%, 0%, 0%); border-radius: 1 2 52px 53px; border: 2px yellow; } .second{ text-decoration: underline; margin: 12px; padding: 13px; color: hsla(0, 105%, 50%, 0.5); border: 3px blue; } .third{ text-decoration: overline; width: 122px; display: inline-block; background-color: blue; } .eleven { text-decoration: line-through; width: 83%; margin: 2 auto; padding: 23px; background: green; } .sam { position: absolute; right: 3px; width: 303px; background-color: yellow; } </style> </head> <body> <div class="first">Siva</div> <div class="second">Raman</div> <div class="third">Arun</div> <div class="eleven"> <img src="first.jpg" alt="centered image" /> </div> </body> </html>

输出。

output 3

结论

删除线是一个重要的属性,因为它被用于CSS文本装饰属性中,具有基于文本的特性。它被放置在网页的正确位置;它不会影响其他内容,如图像和动画。

推荐文章

这是一份关于CSS删除线的指南。我们在这里讨论了删除线在CSS中是如何工作的,并举例说明了代码和输出。你也可以看看下面的文章,以了解更多信息。

  1. CSS链接颜色
  2. CSS 父级选择器
  3. CSS 旋转文本
  4. CSS视口

The postCSS strikethroughappeared first onEDUCBA.