|
1 |
| -# CSS |
| 1 | +# Cascading Style Sheets |
2 | 2 |
|
3 |
| -CSS is what makes HTML look pretty |
| 3 | +Styles can be applied to either generic HTML tags or specific classes. One of the main goals of CSS is to be able to reuse as much as you can, within reason. |
| 4 | + |
| 5 | +## Resources |
| 6 | + |
| 7 | +- [Bootstrap](http://getbootstrap.com/) |
| 8 | +- [Braclets](http://brackets.io/) |
| 9 | +- [FontAwesome](http://fortawesome.github.io/Font-Awesome/icons/) |
| 10 | +- [Zeal](http://zealdocs.org/) |
4 | 11 |
|
5 | 12 | ## Syntax
|
6 | 13 |
|
7 |
| -Classes in CSS |
| 14 | +Classes |
| 15 | + |
| 16 | +```css |
| 17 | +.class_name { |
| 18 | + rule: value; |
| 19 | +} |
| 20 | +``` |
| 21 | + |
| 22 | +HTML tags |
| 23 | + |
| 24 | +```css |
| 25 | +div { |
| 26 | + rule: value; |
| 27 | +} |
| 28 | +``` |
| 29 | + |
| 30 | +### Vocabulary |
| 31 | + |
| 32 | +With the examples above, each code block with `{}` will be defined as a "set of rules" and each line inside the `{}` will be defined as a single rule. |
| 33 | + |
| 34 | +## Topics |
| 35 | + |
| 36 | +### Inspector Tools |
| 37 | + |
| 38 | +Inspector tools (or developer tools) are included in all browsers and are used to figure out issues with CSS in the browser making debugging easier. It also allows you to make quick changes locally. |
| 39 | + |
| 40 | +### Types of CSS classes |
| 41 | + |
| 42 | +#### Regular |
| 43 | + |
| 44 | +Regular CSS classes are the most used classes and is what you will be using the most. These should be as generic as possible and ideally should be as reusable as possible. |
| 45 | + |
| 46 | +**Example** |
| 47 | + |
| 48 | +```css |
| 49 | +.red-bg { |
| 50 | + background-color: #FF0000; |
| 51 | + color: #FFFFFF; |
| 52 | +} |
| 53 | +``` |
8 | 54 |
|
9 |
| - .class_name { |
10 |
| - /* rules */ |
11 |
| - } |
| 55 | +#### Combined Classes |
12 | 56 |
|
13 |
| -HTML Elements in CSS |
| 57 | +Combined classes are classes that are meant to be used together and will not work by themselves. These can be thought of as "modifiers" as in they are modifying the style of an element but not adding any significant. |
14 | 58 |
|
15 |
| - body { |
16 |
| - /* rules */ |
17 |
| - } |
| 59 | +**Example** |
18 | 60 |
|
19 |
| -## Rules |
| 61 | +```css |
| 62 | +.red-bg.dark { |
| 63 | + background-color: #A10000; |
| 64 | +} |
| 65 | +``` |
20 | 66 |
|
21 |
| -All the rules will always follow this syntax: |
| 67 | +#### Pseudo-classes |
22 | 68 |
|
23 |
| - rule-name: value(s); |
| 69 | +Selectors are special "modes" or statuses that CSS classes can have. |
24 | 70 |
|
25 |
| -### Some rules to play with |
| 71 | +**Usages** |
26 | 72 |
|
27 |
| - background-color |
28 |
| - color |
29 |
| - font-family |
30 |
| - font-size |
31 |
| - font-style |
32 |
| - font-weight |
33 |
| - margin |
34 |
| - padding |
35 |
| - text-align |
36 |
| - text-decoration |
| 73 | +- When something is being hovered over |
| 74 | +- When something has been clicked |
| 75 | +- When something is odd or even in a list |
37 | 76 |
|
38 |
| -### Page Layout |
| 77 | +##### Available Pseudo-classes |
| 78 | + |
| 79 | +- `:active` |
| 80 | +- `:after` |
| 81 | +- `:before` |
| 82 | +- `:checked` |
| 83 | +- `:disabled` |
| 84 | +- `:enabled` |
| 85 | +- `:first-child` |
| 86 | +- `:hover` |
| 87 | +- `:last-child` |
| 88 | +- `:nth-child` |
| 89 | +- `:only-child` |
| 90 | +- `:visited` |
| 91 | + |
| 92 | +```css |
| 93 | +.class_name:hover { |
| 94 | + color: #0000FF; |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | +#### Adjacent Siblings |
| 99 | + |
| 100 | +Used when an element is a direct child to a parent. |
| 101 | + |
| 102 | +**Example** |
| 103 | + |
| 104 | +```css |
| 105 | +div > h1 { |
| 106 | + margin-top: 0; |
| 107 | +} |
| 108 | +``` |
| 109 | + |
| 110 | +```html |
| 111 | +<div> |
| 112 | + <h1>Platypi</h1> |
| 113 | + <p>...</p> |
| 114 | + <h1>Uber Bus</h1> |
| 115 | +</div> |
| 116 | +``` |
| 117 | + |
| 118 | +#### Direct descendants |
| 119 | + |
| 120 | +Used when an element is a direct sibling to another object. |
| 121 | + |
| 122 | +**Example** |
39 | 123 |
|
40 | 124 | CSS
|
41 | 125 |
|
42 |
| - display |
43 |
| - float |
| 126 | +```css |
| 127 | +p + p |
| 128 | +{ |
| 129 | + font-weight: bold; |
| 130 | +} |
| 131 | +``` |
44 | 132 |
|
45 | 133 | HTML
|
46 | 134 |
|
47 |
| - article |
48 |
| - div |
49 |
| - footer |
50 |
| - header |
51 |
| - nav |
52 |
| - section |
| 135 | +Here the style would apply to the second <p> |
| 136 | + |
| 137 | +```html |
| 138 | +<div> |
| 139 | + <p></p> |
| 140 | + <p></p> |
| 141 | +</div> |
| 142 | +``` |
| 143 | + |
| 144 | +### Expanding CSS classes |
| 145 | + |
| 146 | +Specifying CSS classes to be used in very specific situations. *Notice the space.* |
| 147 | + |
| 148 | +```css |
| 149 | +nav ul.primary { |
| 150 | + float: left; |
| 151 | +} |
| 152 | + |
| 153 | +nav ul.secondary { |
| 154 | + float: right; |
| 155 | +} |
| 156 | +``` |
53 | 157 |
|
54 |
| -#### Important Classes |
| 158 | +## Usage |
55 | 159 |
|
56 |
| -- Clearfix |
| 160 | +### Fonts, Colors, & Backgrounds |
57 | 161 |
|
58 |
| - .clearfix:after { |
59 |
| - content: ""; |
60 |
| - display: table; |
61 |
| - clear: both; |
62 |
| - } |
| 162 | +- `background-color` |
| 163 | +- `background-image` |
| 164 | +- `background-repeat` |
| 165 | +- `background-position` |
| 166 | +- `color` |
| 167 | +- `font-family` |
| 168 | +- `font-size` |
| 169 | +- `font-style` |
| 170 | +- `font-weight` |
63 | 171 |
|
64 |
| -- Wrapper |
| 172 | +### Borders, Circles, & Padding vs Margin |
65 | 173 |
|
66 |
| - .wrapper { |
67 |
| - margin: 0 auto; |
68 |
| - width: 1000px; |
69 |
| - } |
| 174 | +- `border` |
| 175 | + - Syntax: `<width> <type> <color>` |
| 176 | +- `border-radius` |
| 177 | +- `margin` |
| 178 | +- `padding` |
70 | 179 |
|
71 |
| -## Loading CSS Externally |
| 180 | +## Bootstrap |
72 | 181 |
|
73 |
| -### Our own style sheets |
| 182 | +A CSS framework and grid system creating mobile-first websites |
74 | 183 |
|
75 |
| -We'll start using external files to load all of our CSS. |
| 184 | +### Concepts |
76 | 185 |
|
77 |
| - <link href="../assets/css/styles.css" rel="stylesheet" type="text/css"> |
| 186 | +- Columns |
| 187 | + - `col-xs-*` |
| 188 | + - `col-sm-*` |
| 189 | + - `col-md-*` |
| 190 | + - `col-lg-*` |
| 191 | +- Mobile first/responsive |
78 | 192 |
|
79 |
| -### Font Awesome |
| 193 | +## Font Awesome |
80 | 194 |
|
81 |
| -Visit the [Font Awesome website](http://fortawesome.github.io/Font-Awesome/). We'll be using them a lot for icons. |
| 195 | +Once it's been loaded, you have access to a whole range of icons that can be resized indefinitely. |
0 commit comments