Skip to content

Instantly share code, notes, and snippets.

@CodeMyUI
Created July 18, 2017 23:38
Show Gist options
  • Save CodeMyUI/2a08facda6b6b4172c6477a05423a498 to your computer and use it in GitHub Desktop.
Save CodeMyUI/2a08facda6b6b4172c6477a05423a498 to your computer and use it in GitHub Desktop.
Weather animations
<div class="sunny"></div>
<h2>Sunny</h2>
<div class="partly_cloudy">
<div class="partly_cloudy__sun"></div>
<div class="partly_cloudy__cloud"></div>
</div>
<h2>Partly cloudy</h2>
<div class="cloudy"></div>
<h2>Cloudy</h2>
<div class="rainy">
<div class="rainy__cloud"></div>
<div class="rainy__rain"></div>
</div>
<h2>Rainy</h2>
<div class="thundery">
<div class="thundery__cloud"></div>
<div class="thundery__rain"></div>
</div>
<h2>Thundery</h2>
// Somewhat relevant stuff
* {
box-sizing: border-box;
}
html {
height: 100%;
margin: 0;
padding: 0;
font-size: 18px;
font-family: Arial, sans-serif;
}
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100%;
margin: 0;
padding: 0;
color: #8f90a3;
background-color: #232435;
background-image: linear-gradient(45deg, #232435, #35415f);
background-attachment: fixed;
}
h2 {
margin-bottom: 4rem;
font-size: 1rem;
text-transform: uppercase;
}
// Directly relevant stuff
.sunny {
position: relative;
width: 5rem;
height: 5rem;
margin-top: 4rem;
}
.sunny,
.partly_cloudy__sun {
&:before {
content: "";
position: absolute;
height: 80%;
width: 80%;
top: 10%;
right: 10%;
border-radius: 50%;
z-index: 2;
background-color: #f1c40f;
background-image: radial-gradient(#f1c40f, #f39c12);
box-shadow: 0 0 25px #917508;
}
&:after {
content: "";
position: absolute;
height: 100%;
width: 100%;
border-radius: 50%;
z-index: 1;
background-color: #f39c12;
will-change: opacity, transform;
animation: fadeIn 2s linear infinite reverse,
scaleDown 2s linear infinite reverse;
}
}
.cloudy {
position: relative;
width: 5rem;
height: 5rem;
}
.cloudy,
.partly_cloudy__cloud,
.rainy__cloud,
.thundery__cloud {
&:before {
content: "";
position: absolute;
height: 40%;
width: 40%;
top: 30%;
right: 0%;
border-radius: 50%;
border-bottom-left-radius: 0;
z-index: 2;
background-color: #f1c40f;
background-image: radial-gradient(#ecf0f1, #bdc3c7);
box-shadow: 0 0 25px rgba(0,0,0,0.3);
}
&:after {
content: "";
position: absolute;
height: 60%;
width: 70%;
top: 10%;
right: 30%;
border-radius: 50%;
border-bottom-right-radius: 0;
z-index: 1;
background-color: #f39c12;
background-image: radial-gradient(#ecf0f1, #bdc3c7);
box-shadow: 0 0 25px rgba(0,0,0,0.3);
}
}
.partly_cloudy {
position: relative;
width: 5rem;
height: 5rem;
&__sun {
position: absolute;
width: 100%;
height: 100%;
z-index: 1;
}
&__cloud {
position: absolute;
width: 60%;
height: 60%;
top: 40%;
z-index: 2;
will-change: transform;
animation: translateUp 2s linear infinite alternate;
}
}
.rainy,
.thundery {
position: relative;
width: 5rem;
height: 5rem;
&__cloud {
position: absolute;
height: 100%;
width: 100%;
z-index: 2;
&:before {
background-image: radial-gradient(#95a5a6, #7f8c8d);
}
&:after {
background-image: radial-gradient(#95a5a6, #7f8c8d);
}
}
&__rain {
position: absolute;
height: 100%;
width: 100%;
z-index: 1;
overflow: hidden;
&:before {
content: "";
position: absolute;
height: 80%;
width: 20%;
top: 20%;
right: 50%;
z-index: 1;
background-image: linear-gradient(transparent, #94cdd1);
will-change: opacity, transform;
animation: fadeIn 1s ease-out infinite reverse,
scaleUp 1s ease-out infinite;
}
&:after {
content: "";
position: absolute;
height: 60%;
width: 20%;
top: 40%;
right: 20%;
z-index: 1;
opacity: 0;
background-image: linear-gradient(transparent, #94cdd1);
will-change: opacity, transform;
animation: fadeIn 2s ease-out .4s infinite reverse,
scaleUp 2s ease-out .4s infinite;
}
}
}
.thundery {
&__cloud {
&:before {
background-image: radial-gradient(#4d5656, #393c3c);
animation: thunder 4s linear .02s infinite alternate;
}
&:after {
background-image: radial-gradient(#4d5656, #393c3c);
animation: thunder 4s linear infinite alternate;
}
}
&__rain {
&:before {
animation: fadeIn .5s ease-out infinite reverse,
scaleUp .5s ease-out infinite;
}
&:after {
animation: fadeIn .75s ease-out .2s infinite reverse,
scaleUp .75s ease-out .2s infinite;
}
}
}
// Animations
@keyframes fadeIn {
0% { opacity: 0; }
100% { opacity: 1; }
}
@keyframes scaleDown {
0% { transform: scale(1); }
100% { transform: scale(.8); }
}
@keyframes translateUp {
0% { transform: translatey(15%); }
100% { transform: translatey(0); }
}
@keyframes scaleUp {
0% { transform: scaley(0); }
100% { transform: scaley(1); }
}
@keyframes thunder {
0% { box-shadow: 0 0 25px #fff; }
2% { box-shadow: 0 0 25px #303636; }
49% { box-shadow: 0 0 25px #303636; }
50% { box-shadow: 0 0 25px #fff; }
52% { box-shadow: 0 0 25px #f7db6e; }
53% { box-shadow: 0 0 25px #303636; }
69% { box-shadow: 0 0 25px #303636; }
70% { box-shadow: 0 0 25px #fff; }
71% { box-shadow: 0 0 25px #303636; }
75% { box-shadow: 0 0 25px #303636; }
76% { box-shadow: 0 0 25px #fff; }
77% { box-shadow: 0 0 25px #a8d3f0; }
78% { box-shadow: 0 0 25px #303636; }
100% { box-shadow: 0 0 25px #303636; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment