-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeb.txt
More file actions
557 lines (401 loc) · 13.9 KB
/
Web.txt
File metadata and controls
557 lines (401 loc) · 13.9 KB
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
@@@@@@@@@@ Information Visualization: Programming with D3.js @@@@@@
Intro to HTML and CSS
Intro to D3
Visualization Steps
---
1) Transform Data
2) Map data to image space
3) Compute layout
4) Draw the chart
D3 APIs
---
- Every API of D3 starts with d3.something
- For: Transform Data
d3.cross, d3.max
- For: Map data to image space
d3.scaleLinear, d3.scaleTime
- Compute layout
d3.path, d3.treemap
- Draw the chart
d3.select, d3.append
D3 Selections
---
- Basic API of D3
- Can be used to select elements on our HTML and then manipulate them to assign
data to them.
- d3.select(selector) <- any selector that's used in CSS can be used here too.
- If there are multiple selectors on HTML page, first one is selected.
d3.select("p").select("main") <- chaining selection
let selection = de.select("p")
.select("main")
- d3.selectAll(selector) <- select all elements. You can chain them too.
@@@@@@@@@@@@@@@@ HTML5, CSS & Javascript for Web Developers @@@@@@@@@@@@
// starting browser-sync
$ browser-sync start --server --directory --files "*"
- HTML elements and tags are same. Used interchangeably.
- Tags have attributes (name-value pairs)
<p id="myId"> ... </p>
- Attributes have their own requirements. For ex. id attribute must be unique
across HTML document.
HTML Content Models: (1) Block-Level Elements (2) Inline Elements
- HTML5 has 7 types of elements
- Semantic HTML5 tags
- May help SEO ranking. But varying opinions
- HTML5 Lists: Ordered and Unordered Lists
Character Entity Reference:
---
< use '<' instead
> use '>' instead
& use '&' instead
- There are many more (like copyright symbol etc)
Links
-----
- Internal links
<a href="">
// value in href is absolute or relative url
- In HTML5, <a> tag is both block and inline tag (flow and phrasing content).
So, we can take a <a> tag and have <div> tag within it.
- <a href="#section1"> text </a>
...
<section id="section1"> more text </section>
- <img src="" width="" height="" alt=""> " text
Intro to CSS3
------
- Every browser comes with default style. CSS rules override it.
Anatomy of CSS Rule:
------
p {
color: blue;
}
p = selector
CSS declaration --> color: blue;
color = Property
blue = Value
- Collection of CSS rules is a Style Sheet
Element, Class and ID Selectors
------
Element Selector - we select element name (like 'p' above)
Class Selector -
.blue { <!-- note the . in front -->
color: blue;
}
- we create a 'blue' CSS class above
- How is Class Selector used?
<p class='blue'> ... </p>
<div class='blue'> ... </div>
ID Selector
#name { <!-- note the pound sign -->
color: blue;
}
<p id='name'> ... </p>
<div id='name'> ... </div>
Grouping Selectors with commas
div, .blue {
color: blue;
}
<p class='blue'> ... </p>
<p> ... </p> <!-- no effect -->
<div> ... </div>
- id attribute is least reusable as it can appear only once in the document
Combining Selectors
----
[1]
p.big {
font-size: 20pm;
}
<p class='big'> ... </p> <!-- rule applied>
<div class='big'> ... </div> <!-- rule NOT applied>
[2] Child Selector: Every 'p' that's direct child of 'article'
article > p { <!-- p is DIRECT child of article element -->
color: blue;
}
<article>
<p> ... </p>
</article>
<article>
<div> <p> ... </p> </div> <!-- unaffected -->
</article>
[3] Descendant Selector: Every 'p' inside (at any level) of 'article'
article p {
color: blue;
}
<article>
<div> <p> ... </p> </div> <!-- rule applied -->
</article>
[4]
- 1, 2, 3 are not limited to Element Selectors. It can be applied to class and
id selectors
<!-- every 'p' inside (at any level) an elem with class='colored' -->
.colored p {
color: blue;
}
<!-- every elem with class='colored' that's DIRECT child of 'article' elem
-->
article > .colored {
color: blue;
}
[5] Adjacent Sibling Selector
selector + selector
[6] General Sibling Selector
selector ~ selector
Pseudo Class Selectors
------
selector:pseudo-class {
...
}
- Many pseudo-class selectors exists, but we cover following 5:
:link
:visited
:hover
:active
:nth-child(...)
// TODO
- Pseudo-class selectors are very powerful. Watch Lesson 15 to get a feel.
More reading is necessary for this.
Style Placement
------
- Have external style file and use it in all HTML files
Conflict Resolution
------
- 4 concepts come in to play to resolve conflict
[1] Origin Precedence: Last declaration wins
[2] Declarations Merge: Two declaration (non-conflicting) refering to same
element gets merged. Both rules will be applied to the element.
[3] Inheritance: DOM Tree
A rule declared on a parent is inherited on all it's children
[4] Specificity: Most specific selector combination wins
- inline 'style' is highest score
- !important ---> overrides all other CSS rules. Avoid using this.
Specificity Score
inline Style | ID | Class, pseudo-class, | # of elements
| | attribute |
-----------------------------------------------------------------
| | |
- Calculate the scores above and in conflict, highest score wins.
Styling
-------
- Lots of CSS properties that affect styling
font-family: "Times New Roman", Times, serif, San Serif;
color: #0000FF; // RGB specification
font-style: italic;
font-weight: bold;
font-size: 24px; // its diff than points
text-transform: lowercase; // uppercase and others
text-align: center; // many more alignments
// em = width of 'm'. It's relative font-size
//TODO: Listen to Lecture 18 Part 2, Styling Text. Instructor talks about
//cumulative doubling of font-size
The Box Model
-------------
- Around the content, 3 terms are used:
* Padding
* Border
* Margin
(page layout)
+----------------------------------------------------+
| |
| +==========================================+ | ---
| | | | ^
| | +-------------------------------+ | | |
| | | | | | |
| | | | | | |
| | | | | |
| | | CONTENT | | |height
| | | | | |
| | | | | | |
| | | | | | |
| | +-------------------------------+ ^ | | |
| | | | | v
| +=======================================|==+ | ---
| ^ ^ | |
+--|--------------------|--------------------|-------+
| | |
margin border padding
|<----------- width ----------------->|
- Margins DO NOT define width of the box
- CDT (Chrome Dev Tools) have all these details
Star Selector
------
- Universal selector. Select "every" elem and apply the rule
* {
property: value;
// box-sizing: border-box;
}
- Margins are cumulative. If 2 boxes are adjacent to each other, then margin
between the boxes add up.
- It's not same for 2 boxes, top and bottom. Larger margin takes effect.
- 'box-sizing: border-box' - prefered CSS property.
- 'width' property applies to just the content. With 'box-sizing: border-box'
it is applied to entire box.
- Content overflow
- 'overflow' property: 'auto', 'hidden', 'visible', 'scroll'
- Lookup to understand
- Users do not prefer 'double scrolling': Having two scroll bars in a
browser.
Background Properties
------
background-color: blue;
background-image: url("");
background-repeat: no-repeat; // other options
background-position: bottom right; // other options
background: url("") no-repeat right center; // all properties in one
// background overrides all other individual properties since it's listed
// last?
Position Elems by Floating
----
float: right;
clear: left; // nothing should float to left of this elem
// It's all getting confusing and messy. Must listen few more times to
// this lecture.
- Floats can produce flexible layouts
2 Column Layout
----
Relative Positioning
CSS offset properties: top, bottom, left, right
- Elem is positioned relative to its position in normal doc flow
- Elem is NOT taken out of normal doc flow. Even if moved, its original spot
is preserved ex:
position: relative;
top: 50px; // negative values allowed
left: 50px;
- html elem is ALWAYS relative=positioned
- Absolute positioning depends on closest ancestor elem whose positioning is
set to non-static value.
Media Queries
-----
@media (max-width: 700px) {
p {
color: blue;
}
}
- If media feature (in this case "max-width: 700px") is true, the styles
within curly braces apply.
- max-width and min-width are most common.
- media features can be combined with 'and' and comma operators.
Ex:
@media (min-width: 768px) and (max-width: 991px) {...}
- Comma is treated as OR
Ex:
@media (min-width: 768px), (max-width: 991px) {...}
Responsive Design
------
- Site designed to adapt its layout to viewing environment by using fluid,
proportion-based grids, flexible images, and CSS3 media queries.
- 12 column grid responsive layout is most common layout
* 12 is used because of it's factors: 1, 2, 3, 4, 6, 12
* To achieve fluid width, use %
- Viewport meta tag is used to turn off default mobile zooming.
- Mobile phones zoom out the page and display it
<meta name="viewport" content="width=device-width, initial-scale=1">
- This tells browser to consider the width of device as real width of
screen and set zoom level to 1 (100%)
Twitter Bootstrap
------
- Bootstrap is the most popular HTML, CSS and JS framework for developing
responsive, mobile first projects on web
- Bootstrap grid system basics
<div class="container">
<div class="row">
<div class="col-md-4"> Col 1</div>
...
</div>
</div>
- Instead of 'div', can use other elems too
- "container" or 'container-fluid" classes must be at top
- All columns inside .row class
- "row" class has negative width to align with rest of the regular
content. Listen to Lecture 26 Part 1 for details
- col-SIZE-SPAN
- SIZE: Screen width range identifier. Columns will collapse on each other
(they'll stack) if width is less than SIZE
- SPAN: How many columns the elem must span (1 to 12)
References:
[1] jsfiddle.net
[2] css-tricks.com
[3] codepen.io
[4] caniuse.com // Keeps track of changes to HTML5/CSS etc
[5] w3c.org
[6] validator.w3c.org
[7] csszengarden.com
[8] HTML5, CSS and JS course from Coursera (John Hopkins, Yaakov Chaikin)
===============================================================================
Object Oriented Java (Coursera Course)
Map Providers:
1) http://unfoldingmaps.org/javadoc/
2) https://processing.org/reference/ - Flexible software sketchbook. Amazing
software for visual arts.
3)
http://unfoldingmaps.org/javadoc/de/fhpotsdam/unfolding/providers/package-summary.html
===============================================================================
Web Development with Steve Huffman (Udacity Course)
HTML Tags:
---
<b></b> - bold tag
<em></em> - italics
HTML Tag Attributes:
---
Resources:
[1] www.udacity.com/html_playground
===============================================================================
Web Dev (Udemy course) - Rob Percival
HTML Tags:
Header: h1, h2, ... h6
Self closing: <br />
Line break: <br>
Horizontal rule: <hr />
Bold: <strong>. Earlier, it was <b>, but it's deprecated
Italics: <em>. Can also use <i>
Underline: <u>
Strike through: <strike>
Unordered Lists:
<ul>
<li> Pizza </li>
<li> Chocolate </li>
<li> Curry </li>
</ul>
Ordered Lists:
<ol>
<li> Jeans </li>
<li> Shirt </li>
<li> Socks </li>
</ol>
Images:
<img src="images/example.jpg" />
<img src="URL" width="200" height="200"/> <--this is 200px wide/height
Forms: Lots of options within form tag
<form>
<input type="text" value="example" />
<input type="email" />
<input type="text" placeholder="type here ..." />
<br /><br />
<textarea> My content goes here </textarea>
<select>
<option> Select an option </option>
<option> 1 </option>
<option> 2 </option>
<option> 3 </option>
</select>
<br /><br />
// name="something" groups the radio input in to one
// then you take only one input
<input type="radio" name="color" /> Red
<input type="radio" name="color" /> Green
<br /><br />
<input type="checkbox" name="color" /> Dog
<input type="checkbox" name="color" /> Fish
<input type="checkbox" name="color" /> Cat
<br /><br />
<input type="submit" value="Click Me" />
</form>
Links:
<p> <a href="https://www.google.com"> Google </a> </p>
<a name="top"> </a>
<a href="#top"> Back to top </a>
Tables:
<tr> // table row tag
<th> // table header tag. Each tag will be a column
<td> // Cells of a table
<table>
<tr> <th>Names</th> <th>Age</th> <th>Gender</th> </tr>
<tr> <td>Rob</td> <td>30</td> <td>M</td> </tr>
</table>