gpt4 book ai didi

html - 使用 CSS 时是否可以只定位::before 和::after 之间的内容?

转载 作者:行者123 更新时间:2023-12-02 01:02:42 26 4
gpt4 key购买 nike

我无法访问 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com