advanced selectors

master
Matt Huntington 8 years ago
parent 19a17b548a
commit b35a0971a8

@ -20,10 +20,20 @@ Advanced selectors help eliminate extra classes. They provide no new functional
```html ```html
<div> <div>
<a class="style-me">content</a> <a>content</a>
<a class="style-me">content</a> <a>content</a>
<span class="style-me">content</span> <span>content</span>
</div> </div>
<section>
<a>content</a>
<a>content</a>
<span>content</span>
</section>
```
```css
div * {
padding: 10px
}
``` ```
- `>` - `>`
@ -31,7 +41,7 @@ Advanced selectors help eliminate extra classes. They provide no new functional
- if you want to add styling to just a child, but the parent has descendants that are similar to child - if you want to add styling to just a child, but the parent has descendants that are similar to child
```html ```html
<ul> <ul id="top-level">
<li> <li>
<ul> <ul>
<li></li> <li></li>
@ -39,6 +49,11 @@ Advanced selectors help eliminate extra classes. They provide no new functional
</li> </li>
</ul> </ul>
``` ```
```css
#top-level > li {
border: 1px solid red;
}
```
- `~` - `~`
- sibling selector - sibling selector
- only selects subsequent siblings, not preceding siblings - only selects subsequent siblings, not preceding siblings
@ -51,6 +66,11 @@ Advanced selectors help eliminate extra classes. They provide no new functional
</ul> </ul>
<p>paragraph</p> <p>paragraph</p>
``` ```
```css
ul ~ p {
color:red;
}
```
- `+` - `+`
- immediate sibling selector - immediate sibling selector
- only selects first sibling - only selects first sibling
@ -63,6 +83,11 @@ Advanced selectors help eliminate extra classes. They provide no new functional
</ul> </ul>
<p>paragraph</p> <p>paragraph</p>
``` ```
```css
h1 + p {
color:red;
}
```
### Attribute Selectors ### Attribute Selectors

Loading…
Cancel
Save