【问题标题】:How to select ::after element?如何选择 ::after 元素?
【发布时间】:2023-04-05 05:55:01
【问题描述】:

我有一个与这个相似的元素树:

<div class="one">
  <div class="two">
    <div class="three">...</div>
    ::after
  </div>
</div>

是否可以使用 xpath / css 选择器选择这个 '::after' 元素?

【问题讨论】:

  • 你的意思是来自浏览器的JavaScript? stackoverflow.com/questions/38872290/how-to-get-pseudo-element
  • 请正确解释您的问题。对于 css 选择器,我的答案是完美的,因为您提到了 html 中的结构。
  • 抱歉不准确。是的,当然我的意思是从浏览器 / JS / 等中选择这个 '::after' 元素。据我所知,这是不可能的。谢谢你的回答。

标签: css dom xpath css-selectors


【解决方案1】:

.three::after{
  color:red;
  content:"text";
}
<div class="one">
  <div class="two">
    <div class="three"></div>

  </div>
</div>

你可以这样做,

<style>
.three::after{
  //your styles
}
</style>

【讨论】:

    猜你喜欢
    • 2012-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-28
    • 2015-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多