CSS-向样式表中的样式添加文本 [英] CSS - adding text to the styles in stylesheet

查看:96
本文介绍了CSS-向样式表中的样式添加文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没有找到任何文档,所以我认为它不可行.但这值得问.

I haven't found any documentation yet, so I don't think it's doable. But it's worth asking.

我可以在样式表中的样式内指定实际文本吗?

Can I specify actual Text inside a style, within the stylesheet?

我有几个地方在相同的div地方使用相同的文本.而且我没有考虑使用javascript或在div中重新键入相同的文本,而是在考虑样式是否可以在其中插入实际的文本".

I have a few places that use the same text in the same div places. And instead of using javascript or retyping the same text in the divs, I was pondering if styles can have actual "text" inserted inside.

.someclass {
  text:"for example";  /* this is how I'd imagine it, IF it were possible */
  color:#000;
}

我可能会推这个.

推荐答案

您正在寻找内容属性.

不幸的是,它只能与伪元素一起使用.

Unfortunately, it can only be used with pseudo-elements.

此属性与:before和:after伪元素一起使用以在文档中生成内容.

This property is used with the :before and :after pseudo-elements to generate content in a document.

所以您可以做类似...

So you could do something like...

.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"
}

这篇关于CSS-向样式表中的样式添加文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆