我有一个奇怪的问题,我想在使用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