“CSS -Selektoren” Code-Antworten

CSS -Selektoren


.class1.class2 	    .name1.name2 	Selects all elements with both name1 and name2 set within its class attribute
.class1 .class2 	.name1 .name2 	Selects all elements with name2 that is a descendant of an element with name1

*                	* 	        Selects all elements
element 	        p 	        Selects all <p> elements
element.class       p.intro 	Selects all <p> elements with class="intro"
element,element 	div, p 	    Selects all <div> elements and all <p> elements
element element 	div p 	    Selects all <p> elements inside <div> elements
element>element 	div > p 	Selects all <p> elements where the parent is a <div> element
element+element 	div + p 	Selects the first <p> element that is placed immediately after <div> elements
element1~element2 	p ~ ul    	Selects every <ul> element that is preceded by a <p> element


/*Attribute selectors*/
    p[class="review"] /*all of paragraphs with review class on them*/
    img[href^="../my code guide/"] /*every image that starts with that addres (replacing "=" with"^=")*/
    img[href$="../my code guide/"] /* its end with this attribute*/
    img[href*="../my code guide/"] /*if its contain anywhere*/
    h1[class~="site-header"] /*only works with white space seperator*/
    h1[class|="subtitle"] /*selects ones that start with "subtitle" or "subtitle" and "-" in following*/

pra's play

Selektoren in CSS

/*Advanced selectors*/
    h2 + p  /*every paragraph that is after "h2" */
    textarea ~ button /*every button that is aftrer textarea with same parent (<form> is the same parent in this example)*/
    ul > li /*every signle "li" inside of the "ul"*/
    ul li /*every "li" that goes up to "ul"*/

/*Attribute selectors*/
    p[class="review"] /*all of paragraphs with review class on them*/
    img[href^="../my code guide/"] /*every image that starts with that addres (replacing "=" with"^=")*/
    img[href$="../my code guide/"] /* its end with this attribute*/
    img[href*="../my code guide/"] /*if its contain anywhere*/
    h1[class~="site-header"] /*only works with white space seperator*/
    h1[class|="subtitle"] /*selects ones that start with "subtitle" or "subtitle" and "-" in following*/
Angry puppy

Selektoren in CSS

/*Advanced selectors*/
    h2 + p  /*every paragraph that is after "h2" */
    textarea ~ button /*every button that is aftrer textarea with same parent (<form> is the same parent in this example)*/
    ul > li /*every signle "li" inside of the "ul"*/
    ul li /*every "li" that goes up to "ul"*/

/*Attribute selectors*/
    p[class="review"] /*all of paragraphs with review class on them*/
    img[href^="../my code guide/"] /*every image that starts with that addres (replacing "=" with"^=")*/
    img[href$="../my code guide/"] /* its end with this attribute*/
    img[href*="../my code guide/"] /*if its contain anywhere*/
    h1[class~="site-header"] /*only works with white space seperator*/
    h1[class|="subtitle"] /*selects ones that starts with "subtitle" or "subtitle" and "-" in following*/
Angry puppy

CSS -Selektor


.class1.class2 	    .name1.name2 	Selects all elements with both name1 and name2 set within its class attribute
.class1 .class2 	.name1 .name2 	Selects all elements with name2 that is a descendant of an element with name1

*                	* 	        Selects all elements
element 	        p 	        Selects all <p> elements
element.class       p.intro 	Selects all <p> elements with class="intro"
element,element 	div, p 	    Selects all <div> elements and all <p> elements
element element 	div p 	    Selects all <p> elements inside <div> elements
element>element 	div > p 	Selects all <p> elements where the parent is a <div> element
element+element 	div + p 	Selects the first <p> element that is placed immediately after <div> elements
element1~element2 	p ~ ul    	Selects every <ul> element that is preceded by a <p> element


/*Attribute selectors*/
    p[class="review"] /*all of paragraphs with review class on them*/
    img[href^="../my code guide/"] /*every image that starts with that addres (replacing "=" with"^=")*/
    img[href$="../my code guide/"] /* its end with this attribute*/
    img[href*="../my code guide/"] /*if its contain anywhere*/
    h1[class~="site-header"] /*only works with white space seperator*/
    h1[class|="subtitle"] /*selects ones that start with "subtitle" or "subtitle" and "-" in following*/
Encouraging Eagle

Beispiel für Selektor CSS

.skill { color:red; }
div    { color:blue; }
Pleasant Platypus

Ähnliche Antworten wie “CSS -Selektoren”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen