css实现各种天气状况图标动画效果代码

代码语言:html

所属分类:布局界面

代码描述:css实现各种天气状况图标动画效果代码

代码标签: 天气状况 图标 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  
  
  
  
<style>
@import url('https://fonts.googleapis.com/css?family=Work+Sans:200');

:root {
  --shadow: #fd6f21;
  --ring: currentColor;
  --blend1: #fc5830;
  --blend2: #f98c24;
  --blend-from: 0%;
  --blend-to: 100%;
  --blend-dir: top right;
}

[icon] {
  -webkit-box-flex: 0;
          flex: none;
  display: none;
  position: relative;
  font-size: calc(10em + 1vmin);
  width: 1em;
  height: 1em;
  margin: .3em;
  border-radius: 100%;
  box-shadow: 0 0 0 .05em var(--ring) inset, 0 0 .3em -.03em var(--shadow);
  background: -webkit-gradient( linear, , from(var(--blend1)), to(var(--blend2)));
  background: linear-gradient( to var(--blend-dir), var(--blend1) var(--blend-from), var(--blend2) var(--blend-to));
/*   filter: saturate(0); */
}
/* [icon]:hover {
  filter: saturate(1);
} */
[icon]::after {
  content: attr(data-label);
  position: absolute;
  top: calc(100% + 1vmin);
  left: 50%;
  -webkit-transform: translateX(-50%);
          transform: translateX(-50%);
  font: inherit;
  font-size: .15em;
}
[icon='sunny'] {
  --shadow: #fd6f21;
  --blend1: #fc5830;
  --blend2: #f98c24;
  --blend-to: 65%;
}
[icon='cloudy'] {
  --shadow: #1378bb;
  --blend1: #1b9ce2;
  --blend2: #1378bb;
  --shadow: #c9e8de;
  --blend1: #758595;
  --blend2: #e0e2e5;
  --blend1: #1b9ce2;
  --blend-to: 65%;
  --blend-to: 90%;
}
[icon='snowy'] {
  --shadow: #c9e8de;
  --blend1: #758595;
  --blend2: #e0e2e5;
  --blend-to: 90%;
  --blend-dir: bottom left;
}
[icon='stormy'] {
  --shadow: #34c6d8;
  --blend1: #4b9cc2;
  --blend2: #9adbd9;
}
[icon='supermoon'] {
  --shadow: #5133a5;
  --blend1: #4054b2;
  --blend2: #aa4cba;
  --blend-to: 65%;
  --blend-dir: bottom right;
}

/* SUNNY */
/* --------------------- */
.sun {
  position: absolute;
  top: 20%;
  left: 80%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
  width: 40%;
  height: 40%;
  border-radius: 100%;
  background: #ffeb3b;
  box-shadow: 0 0 0 .02em var(--ring) inset, 0 0 .3em -.03em var(--shadow);
  -webkit-transform-origin: .1em .1em;
          transform-origin: .1em .1em;
}
.sun::after {
  content: '';
  position: absolute;
  top: .1em;
  left: 0;
  will-change: transform;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
  width: .1em;
  height: .1em;
  border-radius: 100%;
  background: rgba(255, 255, 255, .1);
  box-shadow: 0 0 .1em 0 rgba(255, 255, 255, .3) inset, -.1em -.1em 0 .2em rgba(255, 255, 255, .1);
  -webkit-animation: flare 12000ms infinite alternate linear;
          animation: flare 12000ms infinite alternate linear;
}

/* CLOUDY */
/* --------------------- */
.cloud { 
  position: absolute;
  top: .1em;
  left: 65%;
  width: .37em;
  height: .13em;
  border-radius: .1em;
  background-color: #fff;
  box-shadow: 0 0 .1em .02em var(--ring) inset, 0 0 .3em -.03em var(--shadow);
  -webkit-animation: move 3000ms infinite ease-in-out;
          animation: move 3000ms infinite ease-in-out;
}
.cloud + .cloud {
  top: 25%;
  left: 40%;
  -webkit-animation: move 3700ms infinite linear;
          animation: move 3700ms infinite linear;
}
.cloud::before,
.cloud::after {
  content: '';
  position: inherit;
  border-radius: inherit;
  background-color: inherit;
  box-shadow: inherit;
  bottom: 30%;
}
.cloud::before {
  left: .05em;
  width: .2em;
  height: .2em;
}
.cloud::after {
  left: .15em;
  width: .15em;
  height: .15em;
}

/* SNOWY */
/* --------------------- */
[icon='snowy'] ul {
  position: absolute;
  list-style: none;
  top: 0%;
  left: 10%;
  right: 0%;
  height: 100%;
  margin: 0;
  padding: 0;  
}
[icon='snowy'] li::before,
[icon='snowy'] li::after {
  content: '';
  position: absolute;
  list-style: none;
  width: .015em;
  height: .01em;
  border-radius: 100%;
  background-color: var(--ring);
  will-change: transform, opacity;
  -webkit-animation: snow 3700ms infinite ease-out;
          animation: snow 3700ms infinite ease-out;
  opacity: 0;
}
[icon='snowy'] li:nth-child(2n+1)::before,
[icon='snowy'] li:nth-child(13n+11)::after {
  top: -7%;
  left: 40%;
}
[icon='snowy'] li:nth-child(3n+2)::before,
[icon='snowy'] li:nth-child(11n+7)::after {
  top: 5%;
  left: 90%;
  -webkit-animation-delay: 1000ms;
          animation-delay: 1000ms;
}
[icon='snowy'] li:nth-child(5n+3)::before,
[icon='snowy'] li:nth-child(7n+5)::after {
  top: -10%;
  left: 80%;
  -webkit-animation-delay: 2000ms;
          animation-delay: 2000ms;
}
[icon='snowy'] li:nth-child(7n+5)::before,
[icon='snowy'] li:nth-child(5n+3)::after {
  top: 10%;
  left: 10%;
  -webkit-animation-delay: 1300ms;
          animation-delay: 1300ms;
}
[icon='snowy'] li:nth-child(11n+7)::before,
[icon='snowy'] li:nth-child(3n+2)::after {
  top: 20%;
  left: 70%;
  -webkit-animation-delay: 1500ms;
          animation-delay: 1500ms;
}
[icon='snowy'] li:nth-child(13n+11)::before,
[icon='snowy'] li:nth-child(2n+1)::after {
  top: 35%;
  left: 20%;
  -webkit-animation-delay: 500ms;
          animation-delay: 500ms;
}
.snowman {
  position: absolute;
  bottom: 30%;
  left: 40%;
  width: .15em;
  height: .15em;
  opacity: .9;
  background: var(--ring);
  border-radius: 100%;
}
.snowman::after {
  content: '';
  position: absolute;
  top: 90%;
  left: 30%;
  -webkit-transform: translate(-50%, 0%);
          transform: translate(-50%, 0%);
  width: .275em;
  height: .3em;
  border-radius: inherit;
  background-color: var(--ring);
}
.snowman::before {
  content: '';
  position: absolute;
  top: 0%;
  left: 50%;
  -webkit-transform: translate(-55%, -50%);
          transform: translate(-55%, -50%);
  width: .45em;
  height: .4em;
  border-radius: 60%;
  border: .02em solid transparent;
  border-bottom-color: var(--blend1);
  will-change: border-radius;
  -webkit-animation: snowman 9000ms infinite ease-in;
          animation: snowman 9000ms infinite ease-in;
}

/* STORMY */
/* --------------------- */
[icon='stormy']::before {
  --shadow: rgba(255, 255, 255, 0);
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: .05em;
  border-radius: 100%;
  opacity: .4;
  will-change: background-color;
  -webkit-animation: flash 2300ms infinite linear 80ms;
          animation: flash 2300ms infinite linear 80ms;
}
[icon='stormy'] .cloud {
  --shadow: #c9e8de;
  --ring: #f0f2f0;
  background-color: var(--shadow);
  font-size: 1.3em;
  left: 50%;
  will-change: background-color, transform, opacity;
  -webkit-animation: flash 2300ms infinite linear, move 3700ms infinite linear;
          animation: flash 2300ms infinite linear, move 3700ms infinite linear;
}
[icon='stormy'] ul {
  position: absolute;
  list-style: none;
  top: 0%;
  left: 70%;
  right: 0%;
  height: 100%;
  margin: 0;
  padding: 0;  
}
[icon='stormy'] li,
[icon='stormy'] li::before,
[icon='stormy'] li::after {
  position: absolute;
  width: .005em;
  height: .02em;
  border-radius: 10%;
  background-color: #eee;
  opacity: 0;
  will-change: transform, opacity;
  -webkit-animation: rain 2000ms infinite linear;
          animation: rain 2000ms infinite linear;
  -webkit-transform: rotate(25deg);
          transform: rotate(.........完整代码请登录后点击上方下载按钮下载查看

网友评论0