WPSessions WordPress Theme Bootcamp: A Better Theme Process - Learning the Cascade. Learn how to utilize the cascading nature of CSS to your benefit, in creating a mobile first content focused theme.
11. (...but not too specific.)
BE Specific
Media Type Importance Specificity Declaration
12. Media Type Importance Specificity Declaration
/* Don¡¯t do this */
#content article .entry-header h2.entry-title {
font: 400 1.5em/1.2 Bebas Neue, sans-serif;
}
/* Keep it simple */
.entry-title {
font: 400 1.5em/1.2 Bebas Neue, sans-serif;
}
13. Media Type Importance Specificity Declaration
#content article .entry-header h2.entry-title {
font: 400 1.5em/1.2 Bebas Neue, sans-serif;
}
To override this...
IS Not FUN!
15. 1. Inline Styles
2. IDs
SPECIFICITY ORDER
Media Type Importance Specificity Declaration
16. 1. Inline Styles
2. IDs
3. Classes and pseudo-classes
SPECIFICITY ORDER
Media Type Importance Specificity Declaration
17. 1. Inline Styles
2. IDs
3. Classes and pseudo-classes
4. Elements and pseudo-elements
SPECIFICITY ORDER
Media Type Importance Specificity Declaration
19. Declaration Order
Media Type Importance Specificity Declaration
body {
color: #bada55;
}
.entry-title {
color: #d0ab1e
}
...
body {
color: #affec7;
}
21. Media Type Importance Specificity Declaration
body {
background: #fff;
}
@media (min-width: 760px) {
body {
background: #bada55;
}
}
@media (min-width: 960px) {
body {
background: #affec7;
}
}
22. Some css values are inherited by the
children of an element in the document
tree.
Inherence
Media Type Importance Specificity Declaration
23. Media Type Importance Specificity Declaration
body {
font: 16px/1.5 Georgia,Times,"Times New Roman",serif;
color: #222;
}
p {
/* font and color are inherited, and do not need to be
redeclared, unless values need to be changed. */
margin: .625em 0 1.25em;
}
24. cascade + Inherence =
Media Type Importance Specificity Declaration
(+ Media Queries)
25. Media Type Importance Specificity Declaration
/* Default styles, applied to all media types. */
body {
/* Base font size */
font: 16px/1.5 Minion Pro, serif;
}
.entry-title {
font: 400 1.5em/1.2 Bebas Neue, sans-serif; /* 24px */
}
@media (min-width: 760px) {
body {
/* Base font size for 760px+ */
font-size: 19px;
}
/* .entry-title = font-size: 29px; */
}
@media (min-width: 960px) {
body {
/* Base font size for 960px+ */
font-size: 18px;
}
/* .entry-title = font-size: 27px; */
}