Front End North
Saturday November 15th
Liam Richardson
Front-end developer
Sigma Consulting Solutions ltd.
@meevil
By the end of this presentation, you'll (hopefully) have learned how to...
Let's begin our whistle stop tour!
.mybackground span {
transition: opacity 2.5s ease;
}
The transition property allows you to smoothly affect an element when changing from one state to another
.style--one
.style--two
transition: border 5s linear;
The transition property can be triggered by any kind of "state" change
.mybackground {
position: relative;
display: inline-block;
text-indent: -9999px;
width: 250px;
height: 365px;
background: url(http://imagehost.vanweerd.com/images/testdm3.jpg);
background-position: 0 0;
}
.mybackground span {
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
background: url(http://imagehost.vanweerd.com/images/testdm3.jpg);
background-position: 0 -365px;
opacity: 0;
}
.mybackground span {
transition: opacity 2.5s ease;
}
.mybackground span {
opacity: 0;
transition: opacity 2.5s ease;
}
.mybackground span:hover {
opacity: 1;
}
transition-property: width;
transition-duration: 1s;
transition-timing-function: linear;
transition-delay: 2s;
transition: width 1s linear 2s;
Supports 81 properties
Classed as "Animatable"
transition: width 2s, height 2s, transform 2s;
transition: all 2s linear;
http://oli.jp/2010/css-animatable-properties/
On the majority of projects?
@mixin transition($transition-property, $transition-time, $method) {
transition: $transition-property $transition-time $method;
}
@keyframes mymove {
from {top: 0px;}
to {top: 200px;}
}
Keyframes are essentially a list of what the animation should do over a defined period of time
.car {
animation-name: drive;
animation-duration: 2s;
}
@keyframes drive {
from {margin-left: 0px;}
to {margin-left: 400px;}
}
@keyframes drive {
from {margin-left: 0px;}
to {margin-left: 400px;}
}
@keyframes drive {
0% {margin-left: 0px;}
50%{margin-left: 200px;}
100% {margin-left: 400px;}
}
.car {
animation-name: drive;
animation-duration: 2s;
}
What can you change using @keyframes?
The same 81 properties that you can influence with transition can be changed with @keyframes as well
linear
ease-in
ease-out
On projects that require additional visual "flair" or engagement that traditional methods can't provide.
Adding fluidity to an otherwise static design
http://codepen.io/Xpressive_Team/full/LeHGF/
Keyframes allow you to create amazing animations that work
seamlessly across
modern browsers
SVG + CSS animation = Awesomeness
Code you can apply classes too!
<rect class="background" fill="#D03E27" width="400" height="400" />
<path class="letter" fill="#F4F4F4" d="M60.858,129...." />
<path class="letter" fill="#F4F4F4" d="..." />
.path {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear alternate infinite;
}
@keyframes dash {
from {
stroke-dashoffset: 1000;
}
to {
stroke-dashoffset: 0;
}
}
A larger playset - SVG
only properties
clip-rule, flood-color, flood-opacity, stop-opacity, kerning, tech-anchor, color-profile, color-rendering, fill, fill-opacity, fill-rule, marker, marker-end, marker-mid, marker-start, stroke, stroke-width, stop-color, lighting-color, enable-background, dominant-baseline, color-interpolation-filters, color-interpolation, glyph-orientation-horizontal, glyph-orientation-vertical, shape-rendering, baseline-shift, alignment-baseline, stroke-miterlimit, stroke-linejoin, stroke-linecap, stroke-dashoffset, stroke-dasharray, stroke-opacity
Get experimenting with transforms!
/* Chrome, Safari, Opera */
@-webkit-keyframes myfirst {
0% {background: red;}
25% {background: yellow;}
50% {background: blue;}
100% {background: green;}
}
/* Standard syntax */
@keyframes myfirst {
0% {background: red;}
25% {background: yellow;}
50% {background: blue;}
100% {background: green;}
}
@meevil