div a:nth-child(7) 也不难。 第二个呢,可以这么写 div a:first-child+a 可是倒数第二个该怎么写呢? 最终我还是找到了css标准 http://www.w3.org/TR/selectors/#nth-last-child-pseudo 也许这个是学习css的最佳途径
This CSS tutorial explains how to use the CSS selector called :nth-child with syntax and examples. The CSS :nth-child selector allows you to target an element that is the nth child element within its parent.
The child selector uses the > combinator to target an element that is a direct child of another element. See also thedescendant selector. Browser Compatibility The CSS child selector has basic support with the following browsers: Chrome
As a web developer, you may have encountered scenarios where you need to apply specific styles to the first child element within a parent container. This is wheretheCSS:first-child selectorcomes in handy. In this post, we will explore the:first-child selector,understand its usage, and provi...
The :first-child selector matches the first child element.:first-child is a Pseudo-class and it applies to any element that is the first child of another element. With :first-child pseudo-class, an element is matched only when it is the first child of another element. For example, p:...
SelectorExampleExample description elementpSelects all <p> elements #id#firstnameSelects the element with id="firstname" **Selects all elements .class.intro p.introSelects all elements with class="intro" Selects all <p> elements with class="intro" ...
element. */div:has(p){background-color:blue;}/* Select all <div> elements that contain a child element with the class "important". */div:has(.important){border:1px solid black;}/* Select all <div> elements that contain at least two child elements. */div:has(>*+*){padding:10px;...
Striped tables are styled via the :nth-child CSS selector, which is not available in Internet Explorer 8. #First NameLast NameUsername 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter <table class="table table-striped"> ... </table> Bordered table Add .table-bordered...
p::nth-last-child(n)同上,从最后一个子元素开始计数。 :empty p:empty选择没有子元素的每个<p>元素(包括文本节点)。 :not(selector) :not(p)选择非<p>元素的每个元素。 input状态选择器 :focus获得焦点的 input 元素 :enabled每个启用的 input 元素 ...
p[spec^='len2'] 选择spec属性值以len2开头的p元素 p[spec&='len2'] 选择spec属性值以len2结尾的p元素 p[class=special][name=p1] 选择class值等于special,并且name值等于p1的p元素 p:nth-child(1) 选择第一个p元素 p:nth-last-child(1) 选择倒数第一个p元素(要保证最后一个元素是p)...