css如何设置删除线

在css中,可以使用text-decoration属性设置删除线,语法“text-decoration:line-through”。text-decoration属性设置元素文本修饰,值为line-through时,定义穿过文本下的一条线。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

新建test.html页面,在test.html 页面body区域内,新建一个div,用来存放物品名。在div标签内新建span,用来存放物品价格。在test.html 页面body区域内新建style标签,在style标签里设置span标签内的价格为红色

<!DOCTYPE html>
<html lang=en>
<head>
    <Meta charset=UTF-8>
    <Meta http-equiv=X-UA-Compatible content=IE=edge>
    <Meta name=viewport content=width=device-width, initial-scale=1.0>
    <title>Document</title>
    <style>
        .price{
            color:red;
        }
    </style>
</head>
<body>
    <div>键盘:
        <span class=price>200元</span>
    </div>
</body>
</html>

在浏览器里打开test.html,看一下目前的效果

B$84`LEQUX19OM9[~4PEY)6.png

回到编辑器,在test的style标签内,给span设置text-decoration: line-through属性

<style>
        .price{
            color:red;
            text-decoration: line-through;
        }
    </style>

再次打开test.html,会发现价格上被加了删除线。

]E_4HY~3E67Q55`K]YW`L8I.png

推荐学习:css视频教程

相关文章

Css3如何实现鼠标移上变长特效?(图文+视频)
css3怎么实现鼠标悬停图片时缓慢变大效果?(图文+视频)
jquery如何实现点击网页回到顶部效果?(图文+视频)
css3边框阴影效果怎么做?(图文+视频)
css怎么实现圆角边框和圆形效果?(图文+视频教程)
Css3如何实现旋转移动动画特效