Some simple weather icons and animations made with HTML & CSS.
Created
August 8, 2022 16:13
-
-
Save Vitalik-Hakim/2df1632b16f6441110504c7487881819 to your computer and use it in GitHub Desktop.
CSS weather animations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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: #ecf0f1; | |
| background-image: radial-gradient(#ecf0f1, #bdc3c7); | |
| box-shadow: 0 0 25px rgba(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: #ecf0f1; | |
| background-image: radial-gradient(#ecf0f1, #bdc3c7); | |
| box-shadow: 0 0 25px rgba(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-color: #95a5a6; | |
| background-image: radial-gradient(#95a5a6, #7f8c8d); | |
| } | |
| &:after { | |
| background-color: #95a5a6; | |
| 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-color: #4d5656; | |
| background-image: radial-gradient(#4d5656, #393c3c); | |
| animation: thunder 4s linear .02s infinite alternate; | |
| } | |
| &:after { | |
| background-color: #4d5656; | |
| 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 rgba(0,0,0,.3); } | |
| 49% { box-shadow: 0 0 25px rgba(0,0,0,.3); } | |
| 50% { box-shadow: 0 0 25px #fff; } | |
| 52% { box-shadow: 0 0 25px #f7db6e; } | |
| 53% { box-shadow: 0 0 25px rgba(0,0,0,.3); } | |
| 69% { box-shadow: 0 0 25px rgba(0,0,0,.3); } | |
| 70% { box-shadow: 0 0 25px #fff; } | |
| 71% { box-shadow: 0 0 25px rgba(0,0,0,.3); } | |
| 75% { box-shadow: 0 0 25px rgba(0,0,0,.3); } | |
| 76% { box-shadow: 0 0 25px #fff; } | |
| 77% { box-shadow: 0 0 25px #a8d3f0; } | |
| 78% { box-shadow: 0 0 25px rgba(0,0,0,.3); } | |
| 100% { box-shadow: 0 0 25px rgba(0,0,0,.3); } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment