gpt4 book ai didi

html - CSS 属性选择器 + : Not Working in Chrome? 之后

转载 作者:搜寻专家 更新时间:2023-10-31 22:47:29 28 4
gpt4 key购买 nike

我有以下 css/html

<!DOCTYPE html>
<html>
<head>
<style>
a[href$=".pdf"]:after{
content: "[pdf]";

}
</style>
</head>
<body>
<p>This is an example <a href="helloworld.pdf">Text with a pdf link</a></p>
<p>This is an example <a href="helloworld.png">Non PDF link</a></p>
</body>
</html>

当我在 IE8 中打开它时,它按预期工作:PDF 链接之后添加了文本,而 PNG 则没有。但是,当我在 Chrome 23.0.1271.97 中打开它时,两个链接都会在末尾附加 [pdf]。更奇怪的是,当我点击非pdf链接时,最后的[pdf]会随着点击而消失,而点击PDF链接时它不会消失。

see what the Chrome result looks like here

当我这样做

a[href$=".pdf"]{
color: red;
}

pdf 链接是红色的,而非 pdf 链接不是,即使在 Chrome 中也是如此。

为什么 Chrome 在使用 :after 和 content 时似乎不尊重属性选择器?

最佳答案

当我有一个 fiddle with just the :after rule ,我看到了同样的问题。

a[href$=".pdf"]:after{
content: "[pdf]";
}

但是当我add the rule without :after ,[pdf] 不再位于底部。确实很奇怪。

a[href$=".pdf"]:after{
content: "[pdf]";
}

a[href$=".pdf"]{
color: red;
}

看起来这可能是一个 chrome bug . :before/:after 不使用属性选择器,除非元素已经使用属性选择器设置样式。 Here's the logged bug .

关于html - CSS 属性选择器 + : Not Working in Chrome? 之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14324924/

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