我很难通过 CSS 插入 html 标签并将其解释为 html。
我想写<noscript><h2>Please enable javascript!</h2></noscript>
在所有页面的 h1 标题之后;所以我有
h1:after
{
content: "\003cnoscript\003e\003ch2\003ePlease enable javascript! \003c/h2\003e\003c/noscript\003e";
}
在我的 CSS 中。
虽然这成功写入了
<noscript><h2>Please enable javascript!</h2></noscript>
它被视为字符串文字,并将其作为原始 h1 标题的一部分显示在页面上。
由于显而易见的原因,我不能为这个特定任务使用 javascript :P
最佳答案
来自 W3 :
Generated content does not alter the document tree. In particular, it is not fed back to the document language processor (e.g., for reparsing).
<noscript>
中的内容仅在禁用 javascript 时显示。
关于css - 从 css 写 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13249919/