gpt4 book ai didi

css - 如何使生成的内容可选择?

转载 作者:技术小花猫 更新时间:2023-10-29 10:09:22 25 4
gpt4 key购买 nike

我可以使用生成的内容让 CSS 显示元素的 ID,如下所示:

<style>
h2:hover:after {
color: grey;
content: "#" attr(id);
float: right;
font-size: smaller;
font-weight: normal;
}
</style>
<h2 id="my-id">My ID</h2>
<p>Pellentesque habitant morbi tristique senectus et netus et.</p>

如何使生成的内容(“#my-id”)可选,以便用户可以突出显示并复制它?

最佳答案

您不能使伪元素可选,因为它在 DOM 中不存在。

5.10 Pseudo-elements and pseudo-classes

Neither pseudo-elements nor pseudo-classes appear in the document source or document tree.

关于css - 如何使生成的内容可选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19914349/

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