html – 第一个孩子怎么样?
发布时间:2020-12-14 21:37:50 所属栏目:资源 来源:网络整理
导读:例如,我有如下HTML: div class='page' span2/span span2/span a1/a a6/a/div 第一个孩子怎么样? 我这样用:.page a:first-child {color:red} 但它不运行。 解决方法 使用 first-of-type 而不是 first-child .page a:first-of-type{ color:red;} The :fi
例如,我有如下HTML:
<div class='page'> <span>2</span> <span>2</span> <a>1</a> <a>6</a> </div> 第一个孩子怎么样? 我这样用:.page a:first-child {color:red} 但它不运行。 解决方法
使用
first-of-type 而不是
first-child
.page a:first-of-type{ color:red; }
摘自MDN Documentation.你可以找到更多的细节&示例here. 说明::first-child not working as expected (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |