Using :before and :after CSS selector to insert HTML(使用 :before 和 :after CSS 选择器插入 HTML)
问题描述
我想知道以下是否可能.我知道它不起作用,但也许我没有用正确的语法编写它.
I'm wondering if the following is possible. I know it doesn't work, but maybe I'm not writing it in the correct syntax.
li.first div.se_bizImg:before{
content: "<h1>6 Businesses Found <span class="headingDetail">(view all)</span></h1>";
}
有什么办法吗?
推荐答案
content
不支持 HTML,只支持文本.您可能应该使用 javascript、jQuery 或类似的东西.
content
doesn't support HTML, only text. You should probably use javascript, jQuery or something like that.
您的代码的另一个问题是 "
在 "
块内.您应该混合使用 '
和 "
(class='headingDetail'
).
Another problem with your code is "
inside a "
block. You should mix '
and "
(class='headingDetail'
).
如果 content
确实支持 HTML,您可能会陷入无限循环,其中 content
被添加到 content
中.
If content
did support HTML you could end up in an infinite loop where content
is added inside content
.
这篇关于使用 :before 和 :after CSS 选择器插入 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 :before 和 :after CSS 选择器插入 HTML


基础教程推荐
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01