css中怎么样将文字放在一条横线中间

html-css08

css中怎么样将文字放在一条横线中间,第1张

预览: <div class="sigma-content">

    <div class="sigma-middle-line">

        <span class="sigma-line-text">Sigma 的中横线</span>

    </div>

</div> .sigma-content{

    margin: 50px

    text-align: center

    background-color: #fff

}

.sigma-middle-line:before{

    content: ''

    display: block

    height: 1px

    width: 100%

    background-color: #999/*颜色需与主题大背景色一致*/ 

    position: relative

    top: 10px/*调节线高*/

    left: 0

}

.sigma-line-text{

    display: inline-block

    background: #fff

    padding: 0 18px 0 18px

    position: relative

    font-size: 14px

    font-weight: 500

}

2种方法:

1、给这个数字添加css属性:text-decoration: line-through

2、给这个数字添加标签:del。如:<del>9999</del>。

text-decoration详解:

text-decoration : none || underline || blink || overline || line-through

none :  无装饰。text-decoration:none 无装饰,通常对html下划线标签去掉下划线样式。

blink :  闪烁

underline :  下划线。text-decoration:underline 下划线样式。

line-through :  贯穿线。text-decoration:line-through 删除线样式-贯穿线样式。

overline :  上划线。text-decoration:overline 上划线样式。

扩展资料:

我们进行对3个盒子对象分别设置对象内文字下划线、文字删除线样式、字体上划线样式。

1、css代码片段:

.divcss5{text-decoration:underline}

.divcss5_1{text-decoration:line-through}

.divcss5_2{text-decoration:overline} 

2、html代码片段:

<div class="divcss5">我被加下划线</div>

<div class="divcss5_1">我被加贯穿删除线</div>

<div class="divcss5_2">我被加上划线</div>