css - 仅对 div 的前 10 个 <a> 标记应用 CSS 效果

标签 css css-selectors

如何对前 10 个应用 CSS 效果 <a> div 的标签?

这是我的方法,但我相信必须有更好的解决方案:

a:nth-child(1), a:nth-child(2), a:nth-child(3), a:nth-child(4),
a:nth-child(5), a:nth-child(6), a:nth-child(7), a:nth-child(8),
a:nth-child(9), a:nth-child(10){ color:#4faacb; }

最佳答案

我相信这个 CSS 应该可以解决问题

a:nth-child(-n+10) { color: #4faacb }

JSFiddle

希望对你有帮助

关于css - 仅对 div 的前 10 个 <a> 标记应用 CSS 效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16279896/

相关文章:

html - 需要 CSS hack 来让数字不显示在无序列表中

html - CSS/Bootstrap 3 : remove styling from links

html - 无法在 Firefox 12 中换行文本

javascript - 让 Internet Explorer 识别 "advanced"CSS 选择器

html - 外部样式表覆盖内部样式表,即使使用相同的选择器

html - 是否可以选择前面没有文本的元素?

jquery - CarouFREDsel 过滤器/CSS 问题

javascript - 当我打印我的网页时,我失去了所有的 css 着色。是否有选项或脚本可以准确打印网页的外观?

css - 未设置 attr 时使用 CSS2 样式

css - 我可以合并 :nth-child() or :nth-of-type() with an arbitrary selector? 吗