其中是在DOM中添加的:: before的内容 [英] where is the content of ::before added in DOM

查看:373
本文介绍了其中是在DOM中添加的:: before的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码:

<!DOCTYPE html>
<html>
<head>
<style>
div::before {
    content: "Adding Before -";
}
</style>
</head>
<body>

<p>Test</p>

<div>Content</div>

</body>
</html>

输出将是添加之前 - 内容

The out put would be "Adding Before - Content"

但我的问题是,在DOM中我只能看到< div> Content< / div> 。 DOM中的添加之前字词在哪里?

But my question is, in the DOM i can see only the "<div>Content</div>". Where are the words "Adding Before -" present in the DOM?

EDITED:我想知道我们是否会在DOM中显示的值。如果没有,请解释一下架构是如何工作的。 / p>

EDITED : i want to know if the values that we would would be present in theDOM or not.If no, please can you explain the architecture as how it works.

推荐答案

CSS 伪元素,例如 :: before :: after :: first-line 不存在于DOM中,因为它们不是真正的DOM元素(因此,伪)。伪元素是由CSS创建的并由浏览器呈现的虚拟元素。它们不是HTML的一部分。此外,因为它们不是DOM的一部分,所以不能使用JavaScript直接定向和控制。但是,您应该能够通过浏览器直接访问伪元素。

CSS pseudo-elements such as ::before, ::after and ::first-line are not present in the DOM because they are not real DOM elements (hence, "pseudo"). Pseudo-elements are virtual elements created by CSS and rendered by browsers. They are not part of the HTML. Also, because they are not part of the DOM they cannot be directly targeted and controlled with JavaScript. You should, however, be able to access pseudo-elements directly through the browser.

这篇关于其中是在DOM中添加的:: before的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆