Skip to content

Commit 6999b23

Browse files
committed
add button animations
1 parent 93b0059 commit 6999b23

File tree

10 files changed

+966
-7
lines changed

10 files changed

+966
-7
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

README.md

+65-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CSS Transitions & Transforms
1+
# CSS Animations using Transitions & Transforms
22

33
### CSS transitions can enrich user experiences by adding animations to elements by smoothly changing CSS values over a specified duration
44

@@ -13,7 +13,12 @@ button {
1313
transition-timing-function: ease;
1414
}
1515
```
16-
shorthand `transition: background 0.3s ease;`
16+
Shorthand:
17+
```
18+
button {
19+
transition: background 0.3s ease;
20+
}
21+
```
1722

1823
The `transition-timing-function` value allows the speed of the transition to change over time. There are 6 values for this property: `ease`, `linear`, `ease-in`, `ease-out`, `ease-in-out` and `cubic-bezier`. The `ease` value is the default value.
1924

@@ -28,7 +33,12 @@ button {
2833
}
2934
```
3035

31-
shorthand `transition: background 0.3s ease 0.5;`
36+
Shorthand:
37+
```
38+
button {
39+
transition: background 0.3s ease 0.5;
40+
}
41+
```
3242

3343
You might think that the transition property goes on the pseudo-class like the `:hover` state, but you might want the transition triggered on other states like `:focus`, so you should only declare the transition on the normal state.
3444

@@ -53,11 +63,61 @@ button {
5363
}
5464
```
5565

56-
shorthand `transition: all 0.5s ease;`
57-
(both the background and the color would be transitioned)
66+
Shorthand:
67+
```
68+
button {
69+
transition: all 0.5s ease;`
70+
}
71+
```
72+
Both the background and the color would be transitioned
5873

5974
By stating the `all` value you can target all the available properties so they all have the same duration and timing function on all the pseudo-class states (:hover, :focus, :active).
6075

6176
Some other CSS properties that can be transitioned include `width`, `opacity`, `position` and `font-size`. Click [here](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties) for the complete list of properties that can be animated.
6277

6378
## Transform Examples:
79+
80+
`scale()` increases or decreases the size of an element
81+
82+
```
83+
button:hover {
84+
transform: scale(2);
85+
}
86+
```
87+
The button will be twice the original size when you hover over it
88+
89+
You can pass in two values into `scale(x, y)`
90+
```
91+
button:hover {
92+
transform: scale(2, 3);
93+
}
94+
```
95+
The button will be twice its original width and triple its original height
96+
97+
CSS3 animations use `keyframes` to specify what styles the element will have at certain times
98+
99+
```
100+
button:hover {
101+
animation-name: hover-pulse;
102+
animation-duration: 1s;
103+
animation-timing-function: linear;
104+
animation-iteration-count: infinite;
105+
}
106+
107+
@keyframes hover-pulse {
108+
25% {
109+
transform: scale(1.1);
110+
}
111+
75% {
112+
transform: scale(0.9);
113+
}
114+
}
115+
```
116+
117+
Shorthand:
118+
```
119+
button:hover {
120+
animation: hover-pulse 1s linear infinite;
121+
}
122+
```
123+
This button will infinitely pulse increasing and decreasing in size when hovered on

index.html

+29
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,34 @@ <h1>Background Transitions</h1>
3131
<button class="button19" type="button" name="button">Radial In</button>
3232
<button class="button20" type="button" name="button">Radial Out</button>
3333
</section>
34+
<section class="animation-buttons">
35+
<h1>2D Animations</h1>
36+
<button class="animationButton1" type="button" name="button">Float Right</button>
37+
<button class="animationButton2" type="button" name="button">Float Left</button>
38+
<button class="animationButton3" type="button" name="button">Float Bottom</button>
39+
<button class="animationButton4" type="button" name="button">Float Top</button>
40+
<button class="animationButton5" type="button" name="button">Rotate Right</button>
41+
<button class="animationButton6" type="button" name="button">Rotate Left</button>
42+
<button class="animationButton7" type="button" name="button">Expand</button>
43+
<button class="animationButton8" type="button" name="button">Shrink</button>
44+
<button class="animationButton9" type="button" name="button">Pulse</button>
45+
<button class="animationButton10" type="button" name="button">Push</button>
46+
<button class="animationButton11" type="button" name="button">Pop</button>
47+
<button class="animationButton12" type="button" name="button">Skew</button>
48+
<button class="animationButton13" type="button" name="button">Skew Forward</button>
49+
<button class="animationButton14" type="button" name="button">Skew Backward</button>
50+
<button class="animationButton15" type="button" name="button">Skew Wobble</button>
51+
<button class="animationButton16" type="button" name="button">Wobble Horizontal</button>
52+
<button class="animationButton17" type="button" name="button">Wobble Vertical</button>
53+
<button class="animationButton18" type="button" name="button">Wobble to Bottom Right</button>
54+
<button class="animationButton19" type="button" name="button">Wobble to Top Right</button>
55+
<button class="animationButton20" type="button" name="button">Wobble Top</button>
56+
<button class="animationButton21" type="button" name="button">Wobble Bottom</button>
57+
<button class="animationButton22" type="button" name="button">Shake</button>
58+
<button class="animationButton23" type="button" name="button">Shake Out</button>
59+
<button class="animationButton24" type="button" name="button">Bounce In</button>
60+
<button class="animationButton25" type="button" name="button">Bounce Out</button>
61+
<button class="animationButton26" type="button" name="button">Bob</button>
62+
</section>
3463
</body>
3564
</html>

0 commit comments

Comments
 (0)