Home > front end >  CSS first - the child
CSS first - the child

Time:10-11

I don't know why the first - child Settings to use
Div {
Width: 200 px;
Height: 200 px;
Border: 1 px solid hotpink;
/* border - the radius: 20 px; */

}
/* * have any questions/
Div: first - child {
Border - the radius: 20 px;
}









CodePudding user response:

You mean the selector, any element of the first child, and the element is a DIV,
So to:
Div: NTH - child (2) {
Border - the radius: 20 px;
}
Or:
Div: first - of - type {
Border - the radius: 20 px;
}

CodePudding user response:

dog egg, 1/f, reference response:
your selector mean, any element of the first child, and that this element is a DIV,
So to:
Div: NTH - child (2) {
Border - the radius: 20 px;
}
Or:
Div: first - of - type {
Border - the radius: 20 px;
}

Feel good strange, you said that the two methods, I only have a second useful, is my software problems?

CodePudding user response:

Please note: ': first - the child selector is used to select belongs to its immediate parent element of the first child element of the specified selectors,
The direct parent div tag is body, and the body is the first child of the hr, so of course you won't be applied to the first div
Solution, the hr and h2 tags deleted, again observe effect, can!!

CodePudding user response:

refer to the third floor of his reply:
please note: ': first - the child selector is used to select belongs to its immediate parent element of the first child element of the specified selectors,
The direct parent div tag is body, and the body is the first child of the hr, so of course you won't be applied to the first div
Solution, the hr and h2 tags deleted, again observe effect, can!!

Is the first element must be a div is

CodePudding user response:

reference 4 floor i_want_to_study_ response:
Quote: refer to the third floor of his reply:
please note: ': first - the child selector is used to select belongs to its immediate parent element of the first child of the specified selectors,
The direct parent div tag is body, and the body is the first child of the hr, so of course you won't be applied to the first div
Solution, the hr and h2 tags deleted, again observe effect, can!!

Is it to the first element must be div is

Not necessarily, see you how to design layout, but from the div selector: first - the child, the selector can only choose the first element in the body do

CodePudding user response:

refer to fifth floor escape his reply:
Quote: refer to 4th floor i_want_to_study_ response:

Quote: refer to the third floor from his reply:
please note: ': first - the child selector is used to select belongs to its immediate parent element of the first child element of the specified selectors,
The direct parent div tag is body, and the body is the first child of the hr, so of course you won't be applied to the first div
Solution, the hr and h2 tags deleted, again observe effect, can!!

Is it to the first element must be div is

Not necessarily, see you how to design layout, but from the div selector: first - the child, the selector can only choose the first element in the body

Ok thank you, will look after

CodePudding user response:

Frist - child is used in between father and son elements
  • Related