-
Notifications
You must be signed in to change notification settings - Fork 4
/
css-basics.html
312 lines (214 loc) · 7.53 KB
/
css-basics.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Basics</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<link href="css/styles.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>CSS Basics</h1>
<h3>Box Model</h3>
<hr/>
<div class="row">
<div class="col-md-8">
<p>
All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about design and layout.
</p>
<p>
The CSS box model is essentially a box that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content.
</p>
<p>
The image below illustrates the box model:
</p>
<img src="box-model.gif" alt="box-model.gif" class="img-responsive" />
<p>
Explanation of the different parts:
</p>
<ul>
<li><strong>Content</strong> - The content of the box, where text and images appear</li>
<li><strong>Padding</strong> - Clears an area around the content. The padding is transparent</li>
<li><strong>Border</strong> - A border that goes around the padding and content</li>
<li><strong>Margin</strong> - Clears an area outside the border. The margin is transparent</li>
</ul>
<p>
The box model allows us to add a border around elements, and to define space between elements.
</p>
</div>
</div>
<hr/>
<h3>Fonts</h3>
<hr/>
<div class="row">
<div class="col-md-8">
<p class="font-family-sans">Font Family Sans-Serif</p>
<p class="font-family-serif">Font Family Serif</p>
<p class="font-weight">Font Weight</p>
<p class="font-size">Font Size</p>
<p class="font-color">Font Color</p>
<p class="font-varient">Font Varient</p>
</div>
</div>
<hr/>
<div class="row">
<div class="col-md-12">
<pre class="prettyprint">
//html
<p class="font-family-sans">Font Family Sans-Serif</p>
<p class="font-family-serif">Font Family Serif</p>
<p class="font-weight">Font Weight</p>
<p class="font-size">Font Size</p>
<p class="font-color">Font Color</p>
<p class="font-varient">Font Varient</p>
//css
.font-family-sans{
font-family: Arial, Helvetica, sans-serif
}
.font-family-serif{
font-family: "Times New Roman", Times, serif;
}
.font-weight{
font-weight: bold;
}
.font-size{
font-size: 30px;
}
.font-color{
color: red;
}
.font-varient{
font-variant: small-caps;
}
</pre>
</div>
</div>
<h3>Background Color</h3>
<hr />
<div class="row">
<div class="col-md-8">
<div class="block block-1">
</div>
<div class="block block-2">
</div>
<div class="block block-3">
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-12">
<pre class="prettyprint">
//html
<div class="block block-1">
</div>
<div class="block block-2">
</div>
<div class="block block-3">
</div>
//css
.block{
height: 200px;
margin: 0 0 20px 0;
width: 200px;
}
.block-1{
background-color: red;
}
.block-2{
background-color: #00FF00;
}
.block-3{
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#a7ed2f+0,f93618+100 */
background: #a7ed2f; /* Old browsers */
background: -moz-linear-gradient(top, #a7ed2f 0%, #f93618 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, #a7ed2f 0%,#f93618 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #a7ed2f 0%,#f93618 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a7ed2f', endColorstr='#f93618',GradientType=0 ); /* IE6-9 */
}
</pre>
</div>
</div>
<h3>Borders</h3>
<hr />
<div class="row">
<div class="col-sm-8">
<div class="block block-4">
</div>
<div class="block block-5">
</div>
<div class="block block-6">
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-12">
<pre class="prettyprint">
//html
<div class="block block-4">
</div>
<div class="block block-5">
</div>
<div class="block block-6">
</div>
//css
.block-4{
border: 5px solid red;
}
.block-5{
border-top: 1px solid green;
border-right: 3px solid blue;
border-bottom: 5px solid red;
border-left: 10px solid yellow;
}
.block-6{
border-width: 5px;
border-style: dashed;
border-color: red;
}
</pre>
</div>
</div>
<h3>Margins and Padding</h3>
<hr />
<div class="row">
<div class="col-sm-8">
<div class="block block-7">
<div class="block-7-inner"></div>
</div>
<div class="block block-8">
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-12">
<pre class="prettyprint">
//html
<div class="block block-7">
</div>
<div class="block block-8">
</div>
//css
.block-7,
.block-8{
background: red;
}
.block-7{
padding: 50px;
}
.block-7-inner{
background: yellow;
height: 50px;
width: 50px;
}
.block-8{
margin: 100px;
}
</pre>
</div>
</div>
</div>
</body>
</html>