Scale
Skew
Translate
Rotate
.thing {
width: 20px;
height: 20px;
transform: scale(2);
}
.thing {
width: 20px;
height: 20px;
transform: scale(0.5, 2);
}
.thing {
width: 20px;
height: 20px;
transform: scaleX(0.5);
transform: scaleY(2);
}
.thing {
width: 20px;
height: 20px;
background-color: green;
transform: skew(20deg);
}
.thing {
width: 20px;
height: 20px;
background-color: green;
transform: skewX(20deg);
}
.thing {
width: 20px;
height: 20px;
background-color: green;
transform: skewY(20deg);
}
.thing {
width: 20px;
height: 20px;
background-color: green;
transform: rotate(45deg);
}
x
y
z
.thing {
width: 20px;
height: 20px;
background-color: green;
transform: rotateX(45deg);
}
.thing {
width: 20px;
height: 20px;
background-color: green;
transform: rotateY(45deg);
}
.thing {
width: 20px;
height: 20px;
background-color: green;
transform: rotateZ(45deg);
}
.thing {
width: 20px;
height: 20px;
background-color: green;
transform: translate(20px, 10px);
}
.thing {
width: 20px;
height: 20px;
background-color: green;
transform: translateX(20px);
}
.thing {
width: 20px;
height: 20px;
background-color: green;
transform: translateY(10px);
}
.thing {
width: 20px;
height: 20px;
background-color: green;
transform: perspective(500px) translateZ(20px);
}
https://desandro.github.io/3dtransforms/
https://css-tricks.com/almanac/properties/p/perspective/
@keyframes ANIMATION-NAME {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.element {
animation-duration: 2s;
animation-name: ANIMATION-NAME;
animation-iteration-count: infinite;
}
Define keyframes
Include animation
@keyframes ANIMATION-NAME {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.element {
animation: ANIMATION-NAME 5s infinite;
}
Define keyframes
Include animation
[animation-name]
[animation-duration]
[animation-timing-function]
[animation-delay]
[animation-iteration-count]
[animation-direction]
[animation-fill-mode]
[animation-play-state];
animation:
@keyframes ANIMATION-NAME {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
.element {
animation: ANIMATION-NAME 5s infinite;
}
@keyframes ANIMATION-NAME {
0%, 100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
@keyframes infinite-spinner {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.element {
animation: infinite-spinner 5s infinite;
}
@keyframes infinite-spinner {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.element {
animation: infinite-spinner 5s steps(10) infinite;
}
.element:hover {
//do something here//
}
.element:active {
//do something here//
}
@keyframes bounceIn {
0% {
transform: scale(0.1);
opacity: 0;
}
60% {
transform: scale(1.2);
opacity: 1;
}
100% {
transform: scale(1);
}
}
.element {
width: 200px;
height: 200px;
background-color: red;
animation: bounceIn 5s infinite;
}
.element:hover {
animation-play-state: paused;
}
https://robots.thoughtbot.com/css-animation-for-beginners
bit.ly/animatemountain
//this is a log statement//
console.log('hello world!')
String
Number
Object
Boolean
Null
Undefined
'Barry Manilow'
5
{firstName: 'Barry', lastName: 'Manilow'}
True/False
Null
Undefined
var hello;
//hello is undefined//
var hello = 'world';
//hello is the string 'world'//
Case-sensitive.
Unique name.
Need to start with a letter, $, or _.
Avoid reserved words
clarity and meaning for readability
break, case, catch, class, const, continue, debugger, default, delete, do, else, export, extends, finally, for, function, if, import, in, instanceof, new, return, super, switch, this, throw, try, typeof, var, void, while, with, yield
var hello = "Hello! ";
console.log(hello)
> Hello!
Number === Int
Number === Floats
var numberOfKittens = 5;
var cutenessRating = 9.6;
+ | Addition | a + b |
- | Subtraction | a - b |
* | Multiplication | a * b |
/ | Division | a / b |
% | Modulus | a % b |
var hello = "Hello! ";
var world += "World"
console.log(hello world)
> Hello World
var hello = "Hello! ";
var name = {firstName: 'Jane', lastName: 'Doe'}
var age = 30;
console.log(hello + "My name is " + name.firstname + name.lastName + " I am " + age)
> Hello! My name is Jane Doe and I am 30
Have variables for the bill pre-tip and the tip percentage.
Calculate the total bill.
Output a sentence like "Your total bill, with tip, is $14.75".
Bonus: Use toFixed() to round the bill total to 2 decimals.
There are 2 ways to write functions:
Function Expression
Function Declaration
function square(number) {
return number * number
}
console.log(square(4));
> 16
console.log(square(4));
> 16
var square = function(number) {
return number * number;
};
square();
console.log(number)
> 4
var number = 4
var square = function() {
return number * number;
};
square();
console.log(number)
> 16
var number = 4
var square = function() {
number = number * number;
return number
};
var x = 0;
while (x < 10) {
// do stuff here//
x++;
}
> 10
for ([initialization]; [condition]; [final-expression]) {
statement
}
var x;
for (x = 0; x < 10; x++) {
// do stuff here//
}
console.log(x)
> 10
var x = 0;
for (; x < 10; x++) {
// do stuff here//
}
console.log(x)
> 10
function foo(i) {
if (i < 0) {
console.log(i + " is positive")
} else {
console.log(i + " is negative")
}
}
> 3 is positive
foo(3)
Problem: In the number sequence 0-100 inclusive print `fizz` for all multiples of 3 and `buzz` for all multiples of 5.
Problem: In the number sequence 0-100 inclusive print `fizz` for all multiples of 3 and `buzz` for all multiples of 5 and `fizzbuzz` for multiples of 15
http://jsforcats.com/