forked from davidkpiano/frontend-masters-css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
style.scss
157 lines (128 loc) · 3.62 KB
/
style.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
@import "./styles/base.scss";
// CSS VARIABLES (custom properties)
// -- double dash is to tell CSS that this is a custom element
// var(--my-variable, default-value)
:root {
--primary-color: rgb(191, 191, 191);
--ball-duration: 2s;
--easing-default: cubic-bezier(0.5, 0, 0.5, 1);
}
body {
font-family: "Open Sans", sans-serif;
padding: 5vmin;
background-color: var(--primary-color, rgb(193, 193, 255));
}
a {
color: blue;
}
h1 {
margin: 0;
}
small {
text-transform: uppercase;
font-weight: bold;
}
ul {
margin: 1rem 0;
}
// red ball
.ball {
height: 5vmin;
width: 5vmin;
border-radius: 50%;
// background: radial-gradient(circle at bottom right, #fb2324, #fe932a);
// Lecture work
// --ball-duration and --easing-default are our CSS variable written at the top
animation: slide-right var(--ball-duration) var(--easing-default) infinite;
background-color: red;
// CHOOSE what you want to "transition"
transition-property: background-color, transform; // but not the opacity
// apply all these stuff ONLY on the selected elements/properties
transition-duration: 2s;
transition-timing-function: linear;
}
.ball:hover {
transform: scale(10);
background-color: blue;
opacity: 0.2; // opacity will act immediately (no transition made)
}
// PINK SQUARE
// we can select specific properties in the transition-property
// and based on the position mentioned, we can set the durations, etc.
.square {
width: 50px;
height: 50px;
background-color: rgb(255, 0, 204);
margin-top: 30px;
border-radius: 5px;
transition-property: background-color, transform;
transition-duration: 0.5s, 1.5s, 1s;
transition-timing-function: linear, ease-in-out, ease-in-out;
transform: scale(180deg);
}
.square:hover {
transform: rotate(-180deg);
background-color: rgb(255, 255, 255);
color: black;
// opacity: 0.3;
}
// PURPLE SQUARE -- move transition to other states
.otherSquare {
width: 50px;
height: 50px;
background-color: rgb(66, 26, 152);
margin-top: 30px;
border-radius: 5px;
transition-property: background-color, transform;
transition-timing-function: linear, ease-in-out, ease-in-out;
}
// PUTTIN transition in the :hover state. They will be "activated" only when we are in this state: hovering. See how it immediately changes back to normal state (.squareOther) when we remove our cursor
.otherSquare:hover {
color: black;
transform: rotate(-180deg);
transform: scale(180deg);
background-color: rgb(255, 255, 255);
opacity: 0.3;
transition-duration: 2s;
}
// TRANSITION ALL is just a matter of not being specific and a matter of what we want to animate/transition and what not. That's it. Ohterwise it can be used as a shorthand
// KEYFRAMES GREEN BALL
.ball2 {
height: 5vmin;
margin-top: 10px;
width: 5vmin;
border-radius: 50%;
background-color: greenyellow;
// we can have MULTIPLE animatiosn on an element
animation-name: move-like-a-square, change-color;
animation-duration: 4s;
// ANIMATION-FILL-MODE
// basically keeps the last frame/state of the animation/keyframe stuck.
animation-fill-mode: forwards;
// animation direction
// normal, reverse, alternate etc.
}
// keyframe animations are like a timeline and we are defining "mini states" along this timeline
// 0% -- very beginning
// 100% -- very end
@keyframes move-like-a-square {
0% {
transform: none;
}
// this will happen at 1 second later after the animation started
25% {
opacity: 50%;
transform: translateY(20px);
}
100% {
transform: translateX(150px);
}
}
@keyframes change-color {
from {
background-color: none;
}
to {
background-color: red;
}
}