WEBAPP Lesson 5
WEBAPP Lesson 5
(AUDIO AND
ANIMATION
Wed Application
Objectives
HTML supports <audio> tag which is used to embed sound content in an HTML or XHTML document as
follows.
The current HTML5 draft specification does not specify which audio formats browsers should support in the
audio tag. But most commonly used audio formats areogg, mp3andwav.You can use <source&ggt; tag to
specify media along with media type and many other attributes. An audio element allows multiple source
elements and browser will use the first recognized format –
3
Example
4
Audio Attribute Specification
The HTML5 audio tag can have a number of attributes to control the look and feel and various
functionalities of the control:
5
Audio Attribute Specification
The HTML5 audio tag can have a number of attributes to control the look and feel and various
functionalities of the control:
6
Configuring Servers for Media
Types
Most servers don't by default serve Ogg or mp4 media with the correct MIME types, so you'll likely need
to add the appropriate configuration for this.
7
Transition, Transform and Animation
CSS Transitions do smooth out otherwise abrupt changes from state to state over time by filling in the
frames in between.
Transition Basics
Transitions are a lot of fun, so let’s give them a whirl. When applying a transition, there are a few
decisions to make, each of which is set with a CSS property:
8
The Markup
9
The Styles
10
The Styles
a.smooth:hover,a.smooth:focus
{
background-color: red;
}
11
Specifying the property
transition-property
12
How long should it take?
transition-duration
Values: time
Default: 0s
Applies to: all elements, :before and :after pseudo-elements
Inherits: no
Transition-duration sets the amount of time it will take for the animation
to complete in seconds (s) or milliseconds (ms).
13
Timing Functions
transition-timing-function
Default: ease
Applies to: all elements, :before and :after pseudo-elements
Inherits: no
14
Timing Functions
The property and the duration form the foundation of a transition, but
you can refine it further. There are a number of ways a transition can
roll out over time. For example, it could start out fast then slow down,
start out slow and speed up, or it could stay the same speed all the
way through, just to name a few. You can set the transition-timing-
function to ease-in-out to make the link change from blue to red more
gently.
15
Timing Functions
a.smooth {
transition-property: background-color;
transition-duration: 0.3s;
transition-timing-function: ease-in-out;
}
16
Timing Functions
ease - Starts slowly, accelerates quickly, then slows down at the end. This is
the default value and works just fine for most short transitions.
ease-in-out - Starts slowly, speeds up, then slows down again at the very end.
It is similar to ease, but with less pronounced acceleration in the middle.
17
Setting a delay
transition-delay
Values: time
Default: 0s
Applies to: all elements, :before and :after pseudo elements
Inherits: no
a.smooth {
...
transition-property: background-color;
transition-duration: 0.3s;
transition-timing-function: ease-in-out;
transition-delay: 0.2s;
}
If you were especially dastardly, you could make a button disappear
(opacity: 0;) after a person has held their finger or pointer down on it
(:active) for two seconds (transition-delay; 2s;) as shown in the
following example: 19
Setting a delay
20
Setting a delay
a.smooth {
...
transition-property: opacity;
transition-duration: .05s;
transition-timing-function: ease-out;
transition-delay: 2s;
}
21
Setting a delay
a.smooth:hover, a.smooth:focus {
background-color: red;
}
a.smooth:active {
opacity: 0;
}
Always include the non-prefixed version last for forward-compatibility
with supporting browsers of the future. This is how that blue-to-red link
transition we’ve been working on would be written out in the real world:
22
CSS Animation
23
The @keyframes Rule
When you specify CSS styles inside the @keyframes rule , the animation will
gradually change from the current style to the new style at certain times.
The following example binds the "example" animation to the <div> element.
The animation will last for 4 seconds, and it will gradually change the
background-color of the <div> element from "red" to "yellow".
24
Example
25
Example
26
Example
27
Example
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-iteration-count: 3;
}
28
Example
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-direction: reverse;
}
29
Example
@keyframes mymove {
from {left: 0px;}
to {left: 200px;}
}
30
Example
31
THANKS!
Any questions?
32