Skip to content

Commit 636c7ec

Browse files
committed
initial commit
0 parents  commit 636c7ec

File tree

19 files changed

+478
-0
lines changed

19 files changed

+478
-0
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

README.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# CSS Transitions & Transforms
2+
3+
### CSS transitions can enrich user experiences by adding animations to elements by smoothly changing CSS values over a specified duration
4+
5+
### CSS transforms change the shape and position of the content by rotation, skewing, scaling and translation in 2-d and 3-d space
6+
7+
## Transition Examples:
8+
9+
```
10+
button {
11+
transition-duration: 0.3s;
12+
transition-property: background;
13+
transition-timing-function: ease;
14+
}
15+
```
16+
shorthand `transition: background 0.3s ease;`
17+
18+
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.
19+
20+
Add a `transition-delay` property to delay the transition the moment the change of state is triggered
21+
22+
```
23+
button {
24+
transition-delay: 0.5
25+
transition-duration: 0.3s;
26+
transition-property: background;
27+
transition-timing-function: ease;
28+
}
29+
```
30+
31+
shorthand `transition: background 0.3s ease 0.5;`
32+
33+
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.
34+
35+
```
36+
button {
37+
background: #2b5ea2;
38+
transition-delay: 0.5
39+
transition-duration: 0.3s;
40+
transition-property: background;
41+
transition-timing-function: ease;
42+
&:hover, &:focus {
43+
background: darken(#2b5ea2, 15%);
44+
}
45+
}
46+
```
47+
48+
You can chain multiple transition properties
49+
50+
```
51+
button {
52+
transition: background 0.5s ease, color 0.5s linear;
53+
}
54+
```
55+
56+
shorthand `transition: all 0.5s ease;`
57+
(both the background and the color would be transitioned)
58+
59+
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).
60+
61+
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.
62+
63+
## Transform Examples:

css/body.scss

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
* {
2+
box-sizing: border-box;
3+
}
4+
5+
section {
6+
margin: auto;
7+
width: 80%;
8+
}
9+
10+
h1 {
11+
font-family: 'Spicy Rice', serif;
12+
font-size: 30px;
13+
letter-spacing: 3px;
14+
text-align: center;
15+
}

css/buttons.scss

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
@import 'variables.scss';
2+
@import 'mixins.scss';
3+
4+
button {
5+
background: #ccc;
6+
border: none;
7+
border-radius: 5px;
8+
box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.50);
9+
color: #111;
10+
font-family: 'Puritan', sans-serif;
11+
font-size: 20px;
12+
padding: 15px;
13+
margin: 5px;
14+
}
15+
16+
.button1 {
17+
transition: background 0.3s ease;
18+
&:hover, &:focus {
19+
background: $button-background-color;
20+
color: $button-hover-text;
21+
}
22+
}
23+
24+
.button2 {
25+
transition: background 1s ease;
26+
&:hover, &:focus {
27+
background: $button-background-color;
28+
color: $button-hover-text;
29+
}
30+
}
31+
32+
.button3 {
33+
transition: background 0.3s ease 0.5s, color 0.3s ease 0.5s;
34+
&:hover, &:focus {
35+
background: $button-background-color;
36+
color: $button-hover-text;
37+
}
38+
}
39+
40+
.button4 {
41+
transition: background 0.5s ease, color 0.5s linear;
42+
&:hover {
43+
background: $button-background-color;
44+
color: #fe29b5;
45+
}
46+
}
47+
48+
.button5 {
49+
position: relative;
50+
transform: translateZ(0);
51+
transition: color 0.3s ease;
52+
&:hover, &:focus, &:active {
53+
color: $button-hover-text;
54+
&:before {
55+
transform: scaleX(1);
56+
}
57+
}
58+
}
59+
60+
.button5:before {
61+
@include position-absolute;
62+
background: $button-background-color;
63+
border-radius: 5px;
64+
content: "";
65+
transform: scaleX(0);
66+
transform-origin: 0 50%;
67+
transition: transform 0.3s ease-out;
68+
z-index: -1;
69+
}
70+
71+
.button6 {
72+
position: relative;
73+
transform: translateZ(0);
74+
transition: color 0.3s ease;
75+
&:hover, &:focus, &:active {
76+
color: $button-hover-text;
77+
&:before {
78+
transform: scaleX(1);
79+
}
80+
}
81+
}
82+
83+
.button6:before {
84+
@include position-absolute;
85+
background: $button-background-color;
86+
border-radius: 5px;
87+
content: "";
88+
transform: scaleX(0);
89+
transform-origin: 100% 50%;
90+
transition: transform 0.3s ease-out;
91+
z-index: -1;
92+
}
93+
94+
.button7 {
95+
position: relative;
96+
transform: translateZ(0);
97+
transition: color 0.3s ease;
98+
&:hover, &:focus, &:active {
99+
color: $button-hover-text;
100+
&:before {
101+
transform: scaleX(1);
102+
}
103+
}
104+
}
105+
106+
.button7:before {
107+
@include position-absolute;
108+
background: $button-background-color;
109+
border-radius: 5px;
110+
content: "";
111+
transform: scaleX(0);
112+
transform-origin: 50% 0;
113+
transition: transform 0.3s ease-out;
114+
z-index: -1;
115+
}
116+
117+
.button8 {
118+
position: relative;
119+
transform: translateZ(0);
120+
transition: color 0.3s ease;
121+
&:hover, &:focus, &:active {
122+
color: $button-hover-text;
123+
&:before {
124+
transform: scaleY(1);
125+
}
126+
}
127+
}
128+
129+
.button8:before {
130+
@include position-absolute;
131+
background: $button-background-color;
132+
border-radius: 5px;
133+
content: "";
134+
transform: scaleY(0);
135+
transform-origin: 100% 0;
136+
transition: transform 0.3s ease-out;
137+
z-index: -1;
138+
}
139+
140+
.button9 {
141+
position: relative;
142+
transform: translateZ(0);
143+
transition: color 0.3s ease;
144+
&:hover, &:focus, &:active {
145+
color: $button-hover-text;
146+
&:before {
147+
transform: scaleY(1);
148+
}
149+
}
150+
}
151+
152+
.button9:before {
153+
@include position-absolute;
154+
background: $button-background-color;
155+
border-radius: 5px;
156+
content: "";
157+
transform: scaleY(0);
158+
transform-origin: 0 100%;
159+
transition: transform 0.3s ease-out;
160+
z-index: -1;
161+
}

0 commit comments

Comments
 (0)