gpt4 book ai didi

css - 努力让这个 CSS 类选择器工作

转载 作者:太空宇宙 更新时间:2023-11-03 19:58:49 25 4
gpt4 key购买 nike

我有一个 CSS 规则:

.ajaxwebfont a {text-transform:lowercase;}

我希望它匹配的 HTML 是:

<a class="fa fa-check-square-o ss-prime ss-cmd ajaxwebfont" href="..">Click me</a>

如您所见,目标元素中还有其他类用于定义网络字体等。但是我曾希望我只需要匹配“ajaxwebfont”。

感谢您的想法。

最佳答案

选择器应该是 a.ajaxwebfont 因为它是具有该类的 anchor (a) 元素。

.ajaxwebfont a 将引用父元素中的任何 a 标签,其类为 ajaxwebfont

当你在两个值之间添加一个空格时,这意味着第二个是第一个的 child

.demo #sample /* refers an element with id=sample under a parent with class=demo */
a .demo /* refers an element with class=demo under a parent anchor tag */

没有空格表示两者属于同一元素。

a.ajaxwebfont /* refers an element with class=ajaxwebfont which is also an anchor tag */
.demo.ajaxwebfont /* refers an element with class=ajaxwebfont which also has clss=demo */
#demo.ajaxwebfont /* refers an element with class=ajaxwebfont which also has id=demo */

关于css - 努力让这个 CSS 类选择器工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24828564/

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