我还没有找到任何文档,所以我认为它不可行.但值得一提的是.
我可以在样式表中指定样式中的实际文本吗?
我有几个地方在相同的div位置使用相同的文本.而不是使用javascript或在div中重新输入相同的文本,我正在思考样式是否可以插入实际的"文本".
.someclass {
text:"for example"; /* this is how I'd imagine it, IF it were possible */
color:#000;
}
Run Code Online (Sandbox Code Playgroud)
我可能正在推动这一个.
Ric*_*uen 10
您正在寻找内容属性.
不幸的是,它只能与伪元素一起使用.
此属性与:before和:after伪元素一起使用,以在文档中生成内容.
所以你可以做点像......
.someclass:before {
content: "This text will be added at the beginning of the element"
}
.someclass:after {
content: "This text will be added at the end of the element"
}
Run Code Online (Sandbox Code Playgroud)
你可以使用这种方法:before和:after伪元素
.someclass:after {
content:"for example";
color:#000;
}
Run Code Online (Sandbox Code Playgroud)