En muchos sitios ya es costumbre publicar un pequeño widget con la información relevante sobre el estado del tiempo, si bien muchos de estos widgets son estandarizados, siempre se le puede añadir “algo más” para hacerlo más vistoso de cara al usuario, este es el caso del ejemplo que vamos a exponer.

 

Definiendo los <div> para nuestro Widget

1
2
3
4
5
6
7
8
9
10
11
12
<div class="weather-wrapper">
<div class="weather-card madrid">
<div class="weather-icon sun"></div>
<h1>26º</h1>
<p>Madrid</p>
</div>
<div class="weather-card london">
<div class="weather-icon cloud"></div>
<h1>14º</h1>
<p>London</p>
</div>
</div>

 

Ahora definimos el estilo

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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
@import url(http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900);
*, *:before, *:after {
box-sizing: border-box;
}

.weather-wrapper {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}

.weather-card {
margin: 20px 20px;
border-radius: 20px;
position: relative;
overflow: hidden;
width: 270px;
height: 270px;
background-color: white;
box-shadow: 0px 0px 25px 1px rgba(50, 50, 50, 0.1);
-webkit-animation: appear 500ms ease-out forwards;
animation: appear 500ms ease-out forwards;
}
.weather-card h1 {
position: absolute;
font-family: 'Lato', sans-serif;
font-weight: 300;
font-size: 80px;
color: #B8B8B8;
bottom: 0;
left: 35px;
opacity: 0;
-webkit-transform: translateX(150px);
-ms-transform: translateX(150px);
transform: translateX(150px);
-webkit-animation: title-appear 500ms ease-out 500ms forwards;
animation: title-appear 500ms ease-out 500ms forwards;
}
.weather-card p {
position: absolute;
font-family: 'Lato', sans-serif;
font-weight: 300;
font-size: 28px;
color: #d2d2d2;
bottom: 0;
left: 35px;
-webkit-animation: title-appear 1s ease-out 500ms forwards;
animation: title-appear 1s ease-out 500ms forwards;
}

.weather-icon {
position: relative;
width: 50px;
height: 50px;
top: 0;
float: right;
margin: 40px 40px 0 0;
-webkit-animation: weather-icon-move 5s ease-in-out infinite;
animation: weather-icon-move 5s ease-in-out infinite;
}

.sun {
background: #FFCD41;
border-radius: 50%;
box-shadow: rgba(255, 255, 0, 0.1) 0 0 0 4px;
-webkit-animation: light 800ms ease-in-out infinite alternate, weather-icon-move 5s ease-in-out infinite;
animation: light 800ms ease-in-out infinite alternate, weather-icon-move 5s ease-in-out infinite;
}

@-webkit-keyframes light {
from {
box-shadow: rgba(255, 255, 0, 0.2) 0 0 0 10px;
}
to {
box-shadow: rgba(255, 255, 0, 0.2) 0 0 0 17px;
}
}

@keyframes light {
from {
box-shadow: rgba(255, 255, 0, 0.2) 0 0 0 10px;
}
to {
box-shadow: rgba(255, 255, 0, 0.2) 0 0 0 17px;
}
}
.cloud {
margin-right: 60px;
background: #e1e1e1;
border-radius: 20px;
width: 25px;
height: 25px;
box-shadow: #e1e1e1 24px -6px 0 2px, #e1e1e1 10px 5px 0 5px, #e1e1e1 30px 5px 0 2px, #e1e1e1 11px -8px 0 -3px, #e1e1e1 25px 11px 0 -1px;
}
.cloud:after {
content: "";
position: absolute;
border-radius: 10px;
background-color: transparent;
width: 4px;
height: 12px;
left: 0;
top: 31px;
-webkit-transform: rotate(30deg);
-ms-transform: rotate(30deg);
transform: rotate(30deg);
-webkit-animation: rain 800ms ease-in-out infinite alternate;
animation: rain 800ms ease-in-out infinite alternate;
}

@-webkit-keyframes rain {
from {
box-shadow: #2092A9 8px 0px, #2092A9 32px -6px, #2092A9 20px 0px;
}
to {
box-shadow: #2092A9 8px 6px, #2092A9 32px 0px, #2092A9 20px 6px;
}
}

@keyframes rain {
from {
box-shadow: #2092A9 8px 0px, #2092A9 32px -6px, #2092A9 20px 0px;
}
to {
box-shadow: #2092A9 8px 6px, #2092A9 32px 0px, #2092A9 20px 6px;
}
}
@-webkit-keyframes weather-icon-move {
50% {
-webkit-transform: translateY(-8px);
transform: translateY(-8px);
}
}
@keyframes weather-icon-move {
50% {
-webkit-transform: translateY(-8px);
transform: translateY(-8px);
}
}
.inspiration {
color: #aeaeae;
font-family: 'Lato', sans-serif;
font-weight: 300;
font-size: 24px;
text-align: center;
}
.inspiration a {
color: #FA565F;
font-weight: 400;
-webkit-animation: all 300ms ease-in-out;
animation: all 300ms ease-in-out;
}

@-webkit-keyframes appear {
0% {
-webkit-transform: scale(0);
transform: scale(0);
}
50% {
-webkit-transform: scale(1.05);
transform: scale(1.05);
}
75% {
-webkit-transform: scale(0.95);
transform: scale(0.95);
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
}
}

@keyframes appear {
0% {
-webkit-transform: scale(0);
transform: scale(0);
}
50% {
-webkit-transform: scale(1.05);
transform: scale(1.05);
}
75% {
-webkit-transform: scale(0.95);
transform: scale(0.95);
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
@-webkit-keyframes title-appear {
from {
opacity: 0;
-webkit-transform: translateX(150px);
transform: translateX(150px);
}
to {
opacity: 1;
-webkit-transform: translateX(0px);
transform: translateX(0px);
}
}
@keyframes title-appear {
from {
opacity: 0;
-webkit-transform: translateX(150px);
transform: translateX(150px);
}
to {
opacity: 1;
-webkit-transform: translateX(0px);
transform: translateX(0px);
}
}

 

¡Pruebalo! ¡Pruebalo!

 

Te Puede Interesar:

Construyendo un notificador de elementos “unread notifier” con CSS
Un sencillo tooltip con CSS
Creando un calendario con CSS

Fuente

(Visited 313 times, 1 visits today)