@MaptimeSF
@mapsense
@jhnklly
john@mapsense.co
https://jhnklly.github.io/hello_code
You don't need to be fluent in “beep-boop-boop-beep” to make pretty things with code.
(Cmd + Opt + U)
(Cmd + Opt + I)
Hello, World!
Put your text editor on one half of the screen & browser on the other.
Don't worry if you miss things!
Exposure gradually brings fluency.
We'll stop to test when the code block has an orange border.
<h1> Hello, World!</h1>
h1 { color: green; }
<h1>Hello, World!</h1>
CSS gets
{curly brackets}
colons :
semi-colons;
<style>
tags.
<style>
h1 { color: green; }
</style>
<h1>Hello, World!</h1>
<!doctype html>
<html>
<head>
<style>
h1 { color: green; }
</style>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
<p>I'm a paragraph.</p>
<a>I'm a link.</a>
<div>I'm a div.</div>
<img />
<body>
<h1>Hello, World!</h1>
<img src="https://placekitten.com/g/200/300" />
<div>I'm a div.</div>
<a href="http://maptime.io">I'm a link.</a>
<p>Feline ipsum dolor ocelot, tabby so
bobtail. Norwegian forest such lynx. Nip nap.
</p>
</body>
<div id="unicorn" class="fantanimal" >I'm a div.</div>
<a href="http://maptime.io" >I'm a link.</a>
<p class="ipsum fantanimal" >Feline ipsum dolor ocelot, tabby so
bobtail. Norwegian forest such lynx. Nip nap.</p>
Whuck?
#name_of_id
.name_of_class
hash #id hash #id hash #id hash #id hash
dot .class dot .class dot .class dot .class
element element element element
<style>
#unicorn { border: 1px dotted green; }
.fantanimal { font-size: 2em; }
.ipsum { font-style: italic; }
a { font-family: 'Gotham', sans-serif; }
</style>
<!doctype html>
<html>
<head>
<style>
#unicorn { border: 1px dotted green; }
.fantanimal { font-size: 2em; }
.ipsum { font-style: italic; }
a { font-family: 'Gotham', sans-serif; }
</style>
</head>
<body>
<div id="unicorn" class="fantanimal">I'm a div.</div>
<a target="_blank" href="http://maptime.io">I'm a link.</a>
<p class="ipsum fantanimal">Feline ipsum dolor ocelot, tabby so
bobtail. Norwegian forest such lynx. Nip nap.</p>
</body>
</html>
Feline ipsum dolor ocelot, tabby so bobtail. Norwegian forest such lynx. Nip nap.
script
tags is special."just text"
.
<script>
alert("I'm an alert!");
</script>
var
to initialize variables
<script>
var text_var = "Meow.";
alert("I'm an alert!" + text_var);
</script>
var variable1 = 3000;
var variable2 = 857;
alert(variable1 + variable2);
(See how easy this is?)
var text_var = " Meow. ";
var call_it_what_you_want = " Woof. ";
alert(text_var + call_it_what_you_want);
if (this condition is true) {
do this; }
<script>var text_var = " Meow.";
var number_var = 0;
if (number_var >= 0) {
alert(number_var + text_var);
}
</script>
var text_var = "Meow.";
var number_var = 0;
while (number_var < 7) {
alert(number_var + text_var);
number_var = number_var + 1;
}
for
loops
var colors = ['red','orange','yellow',
'green','blue','indigo','violet'
];
for (i = 0; i < 21; i++) {
var element = '' +
i +
'';
document.write(element);
}
They're full of functions & power.
<script src="http://d3js.org/d3.v3.min.js">
</script>
<script>
d3.select('body')
.append('div')
.text('D3time!')
.attr('style','color: orange; font-size: 100px;');
</script>
<script src="http://d3js.org/d3.v3.min.js">
</script>
<script>
var colors = ['red','orange','yellow',
'green','blue','indigo','violet'
];
d3.select('body').selectAll('div')
.data(colors)
.enter()
.append('div')
.text('♥')
.attr('style',function(d) {
var css = 'color: ' + d;
return css;
});
</script>
#nailedIt
https://jhnklly.github.io/hello_code
@MaptimeSF
@mapsense
@jhnklly
john@mapsense.co