我无法访问 JavaScript 或 HTML,只能访问 CSS。
我正在尝试将已经存在的文本更改为其他内容。
#element::before {
content: "This is the new text."
}
<div id="element">This is the original text.</div>
是否可以使用 CSS 专门针对旧文本,然后应用 text-indent: -9999px;
?
最佳答案
无法专门针对元素的文本节点;见Is there a CSS selector for text nodes?获取更多信息。
您可以通过多种方式实现您想要的效果,但正如 Paulie_D 所建议的那样,这是否是一个好主意取决于您要实现的目标。
#element {
visibility: hidden;
}
#element:before {
content:"My new text using visibilty.";
visibility: visible;
}
#element2 {
font-size: 0;
}
#element2:before {
content:"My new text using font-size.";
font-size: 16px;
}
<div id="element">This is the original text.</div>
<div id="element2">This is the original text.</div>
关于html - 使用 CSS 时是否可以只定位::before 和::after 之间的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26651723/