【问题标题】:I need an advanced CSS code explanation我需要高级 CSS 代码说明
【发布时间】:2017-03-01 12:09:00
【问题描述】:

一些老 YouTube 创作者发布了这个作为他会做的事情,我以前从未见过这样的代码:

a[href]:not([href*="#"]):after {
    content:" - " attr(href);
}

他没空问,这段代码看起来很酷。

【问题讨论】:

    标签: css css-selectors pseudo-class


    【解决方案1】:

    为每个href 属性不包含# 字符的<a> 标签的每个:after 伪元素设置样式,所以它的内容是一个空格 +破折号 + 空格 + <a>的href属性:

    a[href]:not([href*="#"]):after {
        content:" - " attr(href);
    }
    <a href="href-attribute">With following dash</a> <br>
    <a href="#href-attribute">Without following dash</a>

    选择器解释:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-12
      • 1970-01-01
      • 2016-04-17
      • 2014-10-02
      • 2017-12-24
      • 2020-11-07
      • 1970-01-01
      相关资源
      最近更新 更多