編碼的世界 / 優質文選 / 生涯

HTML中 用CSS樣式實現 文字兩邊添加水平線


2022年3月28日
-   

(1)html中的代碼:
<div class="content">
<p class="title">新特賣每日早10晚8上新</p>
</div>

(2)css樣式中的代碼:
.content{
width: 960px;
margin: 100px auto;
border-top: 1px solid black;
position: relative;
}
.content .title{
width: 320px;
height: 50px;
background: #FFFFFF;
text-align: center;
line-height: 50px;
font-size: 25px;
color: #666666;
position: absolute;
top: -25px;
left: 320px;
}

效果圖如下:

熱門文章