我有一個奇怪的問題,我想在使用css的元素之前和之後添加大括號。由於花括號在html中並不存在,因此我使用css僞元素在前後添加花括號。我的問題是,僞元素正在從主CSS選擇器的CSS樣式。我不希望花括號有強調,穿透,藍色等。我怎樣才能防止這種情況?如何防止css僞元素從主元素中保留css?
這裏是什麼錯誤示例:
amdstyle[type="6"]{
\t margin-left: .5em;
\t text-decoration: line-through;
\t color: blue;
\t font-weight: bold;
\t border-bottom: 1px solid blue;
}
amdstyle[type="6"]:before{
\t content:"{";
\t text-decoration: none !important; /* Doesn't help */
\t border-bottom: none !important; /* Doesn't help */
}
amdstyle[type="6"]:after{
\t content:"}";
}
<amdstyle type=6>Here is my element</amdstyle>
我認爲這將是確定添加text-decoration: none
和border-bottom: none
的前後僞元素,但是這並不工作,他們總是採取正規元素的造型。將!important
添加到我的樣式中也無濟於事。這怎麼解決?
在我的情況,我不能用這個想法,但我喜歡這個主意。 – jabe