This is a draft cheat sheet. It is a work in progress and is not finished yet.
Small, Medium, Big screen
small screen |
@media only screen and (max-width: 40em) { .class {...} #id{...} }
|
medium screen |
@media only screen and (min-width: 40.063em) and (max-width: 64em) { .class {...} #id{...} }
|
big screen |
no need to specify |
Class selectors - Examples&Explanation
|
Select all elements with the class name callout that are decendents of the element with an ID of header
|
|
Select the element which has an ID of header and also a class name of callout
|
|
<h1 id="one" class="two">This Should Be Red</h1>
|
.three.four { color: red; }
|
<h1 class="three four">Double Class</h1>
|
#header { color: red; } #header.override { color: black; }
|
The second targets the same element but overrides the color
|
Pseudo classes
|
p { display: none; background-color: yellow; padding: 20px; } div:hover p { display: block; }
|
hover div to show the p element |
|
|
Combinators
|
Descendant selector - selects all <p> elements inside <div> elements
|
|
Child selector - selects all <p> elements that are immediate children of a <div> element
|
|
Adjacent sibling selector - selects all <p> elements that are placed immediately after <div> elements
|
|
General sibling selector - selects all <p> elements that are siblings of <div> elements
|
|