Difference between nth-of-type and nth-child, nth-of-type
When I checked out CSS3, I found an nth-of-type selector. I found that I have never seen it before. So I studied it. w3c explained it as follows:
: Nth-of-type (N) The selector matches each element of the
One, deep breathing, direct content: Nth-child and: Nth-of-type are CSS3 in the pseudo-class selector, its role is similar but not exactly the same, for unfamiliar people may not be very different, this article will introduce the difference between the two, in order to facilitate the correct use of both types of selectors.Let's look at a simple example, first of all, the HTML section:Then the two selectors
Nth-child and Nth-of-type are CSS3 in the new pseudo-class selector, in all fairness, the peacetime use of nth-child more, sometimes encounter some unexpected situation, but also changed to forget, and did not delve into, so that before today, I also dumb think nth-of-type than nth
The difference between Nth-child and Nth-of-type in CSS3 is actually very simple:: Nth-of-type Why to call: Nth-of-type? Because it is differentiated by "type". That is, Ele:nth-of-type (n) refers to the nth ele element under the parent element, while Ele:nth-child (n) refer
The difference between Nth-child and Nth-of-type in CSS3 is actually very simple:: Nth-of-type Why to call: Nth-of-type? Because it is differentiated by "type". That is, Ele:nth-of-type (n) refers to the nth ele element under the parent element, while Ele:nth-child (n) refer
Indicates that the element is a label and a p:nth-child(2) p second child element , which is two conditions that must be met.So, the first p label color is red (just match: P tag, second child element). If you div insert a label after the label span , the following:Then p:nth-child(2) no elements will be selected. p:nth-of-type(2) represents the second p element under the parent tag , and it is clear that the div span h1 p text in the second label is red, whether it is inserted after the label
Look at CSS3 when found a nth-of-type selector, found that at ordinary times have not seen the use, on the study of a bit, the information is this:: The Nth-of-type (n) selector matches each element of the nth child element of a particular type that belongs to the parent element.Looks a lot like nth-child.: The
Instance:First create an HTML structureclass="post"> Next use:. Nth-child and Nth-of-type to select and change their text color. Post>p:nth-child (2) { color: red; }. Post>p:nth-of-type (2) { color: red; }Now add a Heading 1 to the front of the paragraph.Divclass= "POST"> H1>I'm Heading 1.H1> P>I am the first paragraph of the articleP> P>I am the second paragr
First,: Nth-child1.1 Description
: the Nth-child (n) selector matches the nth child element that belongs to its parent element, regardless of the type of the element . n can be a number, a keyword, or a formula.
Note: If the nth child element differs from the selected element type, the style is invalid!1.
Casual -- pseudo-class selector: The difference between nth-child (n) and nth-of-type (n !!!, Nthoftypen
Not much talk! Answer the question !!!
I. E: nth-child (n) // select the (n) element in the parent element. if the nth element is E, it is selected. If the nth element
about: Nth-child and: Nth-of-type The difference has not been too much attention.Recently intends to dig deeper into some CSS3, only to discover inside actually hidden mystery. : Nth-child can select the Word element under the parent element: Nth-of-type can also.But what difference do they have? In fact the difference
First,: Nth-child1.1 Description
: the Nth-child (n) selector matches the nth child element that belongs to its parent element, regardless of the type of the element . n can be a number, a keyword, or a formula.
Note: If the nth child element differs from the selected element type, the style is invalid!1.
The nth-of-type requires attention when selecting a class. nth-of-typeclass
I checked the w3 and MDN manuals and did not find this instruction. I wrote down it as soon as possible.1,
. Class: nth-of-type (n)When selecting a class, if you insert x tags of the same type before the class, n needs to add x
When a p is inserted before the first 1st p. para:
At th
This post consists of: http://xinpure.com/css3-pseudo-class-difference-between-nthchild-and-nthoftype/First look at the common denominator of Nth-child (n) and Nth-of-type (n)The only common denominator is: the use of parameter nn can be a number, a keyword, or a formula (n > 0)Nth-child (2) represents the second child element of its parent elementNth-child (2n)
Remove Nth Node from End of ListGiven A linked list, remove the nth node from the end of the list and return its head.For example,Given linked list:1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list becomes 1->2->3->5.Note:Given n would always be valid.Try to do the in one pass.Idea: Delete the last nth node, because it is a sin
First look at the similarities between Nth-child (n) and Nth-of-type (n)
The only common denominator between the two is: the use of parameter n
n can be numbers, keywords, or formulas (n > 0)
Nth-child (2) represents the second child element of its parent element
Nth-child (2n) or
First,: Nth-child
1.1 Description
: the Nth-child (n) selector matches the nth child element that belongs to its parent element, regardless of the type of the element. n can be a number, a keyword, or a formula.
Note: If the nth child element differs from the selected element type, the style is invalid!
1.2 Example
1.
Css: nth-of-type () selector usage, nth-of-type Selector
I made a page today and accidentally saw thisnth-of-typeIt is quite convenient. Some of the previous single and double lines have horizontal lines, and some do not have horizontal lines. Generally, border-right: none and so on are separately written in html. Now we can quickly record this good thing.
: Nth-
This article mainly introduces about how to use CSS properties Nth-child (n) match select Nth Sub-element, has a certain reference value, now share to everyone, the need for friends can refer to
CSS Match Select the nth child element can be used: the Nth-child (n) selector, which matches the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.