有這樣一種需求桥胞,給文字畫上刪除線,從簡單點來講考婴,一句代碼的事情:
text-decoration: line-through;
但是這貨有缺陷贩虾,就是只同文字的長度相關(guān)聯(lián),文字多長沥阱,這條線就多長缎罢,這就是很尷尬了,設(shè)計童鞋說要100%長怎么辦考杉,用偽類吧:
.text::before {
position: absolute;
content: "";
width: 100%;
height: 0;
border-top: 1px solid gray;
opacity: 0.5;
top:50%;
transform: translate3d(0,-50%,0);
-webkit-transform: translate3d(0,-50%,0);
}