如何使用CSS替换某些文本中的单词?

时间:2017-02-27 14:41:21

标签: css

我有第三方插件,我需要更改一个字。他们只允许我访问CSS:

<span class="apple">This is some words</span>

更改为:

<span class="apple">This is some text</span>

我如何用纯CSS做到这一点?

3 个答案:

答案 0 :(得分:1)

如果您可以访问HTML,则可以隐藏不需要的文本的包装:

p.old-text-class { diplay: none;}

将新文本插入HTML中的相同位置:

<p class="new-text-class">This is some text</p>

答案 1 :(得分:1)

尝试使用带有内容的伪元素。

.apple {
  visibility: hidden;
}
.apple:before {
  content: "This is NEW text";
  visibility: visible;
}
<span class="apple">This is OLD text</span>

答案 2 :(得分:1)

您可以尝试使用伪选择器:after

&#13;
&#13;
span{
  position:relative;
  color:transparent;
}
span:after{
  content:'This is some text';
  position:absolute;
  right:10px;
  color:#111;
}
&#13;
<span class="apple">This is some words</span>
&#13;
&#13;
&#13;

相关问题