css布局实现天气动画图标icon效果代码

代码语言:html

所属分类:动画

代码描述:css布局实现天气动画图标icon效果代码

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

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


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

<head>

 
<meta charset="UTF-8">
 

 
 
<style>
@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap");
*,
*:before,
*:after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body,
html {
  width: 100%;
  min-height: 100vh;
  background: #212f45;
}

.container {
  width: 100%;
  max-width: 800px;
  min-height: 100vh;
  margin: 5% auto;
  display: flex;
  flex-direction: column;
}
.container h1 {
  color: #fffafa;
  font-family: "Roboto", sans-serif;
  text-align: center;
  padding-left: 2rem;
  padding-right: 2rem;
  margin: 1rem auto;
  text-transform: capitalize;
  letter-spacing: 0.02rem;
}
.container p {
  color: #fffafa;
  font-family: "Roboto", sans-serif;
  text-align: center;
  padding-left: 2rem;
  padding-right: 2rem;
  margin: 1rem auto;
  letter-spacing: 0.05rem;
}
.container a {
  color: #fdac49;
}
.container .showcase {
  flex-grow: 1;
  margin: 1rem auto;
  padding: 10px;
  display: grid;
  grid-gap: 10px;
  grid-template-columns: repeat(auto-fill, 150px);
  grid-auto-rows: 150px;
}
@media all and (min-width: 200px) {
  .container .showcase {
    max-width: 200px;
    grid-gap: 10px;
  }
}
@media all and (min-width: 400px) {
  .container .showcase {
    max-width: 400px;
    grid-gap: 10px;
  }
}
@media all and (min-width: 600px) {
  .container .showcase {
    max-width: 600px;
    grid-gap: 12px;
  }
}
.container .showcase .canvas {
  position: relative;
}
@media all and (max-width: 200px) {
  .container .container {
    display: none;
  }
}

#sunny .sun {
  position: absolute;
  width: 50%;
  height: 50%;
  top: 25%;
  left: 25%;
  background: radial-gradient(#fdac49, #fcd422);
  border-radius: 50%;
  animation: spinSun 20s linear infinite;
}
#sunny .sun:after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0%;
  left: 0%;
  background: inherit;
  border-radius: 50%;
}
#sunny .sun .beam:nth-child(even):before {
  background: #fdac49;
}
#sunny .sun .beam:nth-child(even):after {
  background: #fdac49;
}
#sunny .sun .beam:nth-child(odd):before {
  background: #fcd422;
}
#sunny .sun .beam:nth-child(odd):after {
  background: #fcd422;
}
#sunny .sun .beam:nth-of-type(1) {
  position: absolute;
  width: 15%;
  height: 140%;
  top: -20%;
  left: 42.5%;
  outline: 1px solid #212f45;
}
#sunny .sun .beam:nth-of-type(1):before {
  content: "";
  position: absolute;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
#sunny .sun .beam:nth-of-type(1):after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
#sunny .sun .beam:nth-of-type(2) {
  position: absolute;
  width: 15%;
  height: 140%;
  top: -20%;
  left: 42.5%;
  outline: 1px solid #212f45;
  transform: rotate(22.5deg);
}
#sunny .sun .beam:nth-of-type(2):before {
  content: "";
  position: absolute;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
#sunny .sun .beam:nth-of-type(2):after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
#sunny .sun .beam:nth-of-type(3) {
  position: absolute;
  width: 15%;
  height: 140%;
  top: -20%;
  left: 42.5%;
  outline: 1px solid #212f45;
  transform: rotate(45deg);
}
#sunny .sun .beam:nth-of-type(3):before {
  content: "";
  position: absolute;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
#sunny .sun .beam:nth-of-type(3):after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
#sunny .sun .beam:nth-of-type(4) {
  position: absolute;
  width: 15%;
  height: 140%;
  top: -20%;
  left: 42.5%;
  outline: 1px solid #212f45;
  transform: rotate(67.5deg);
}
#sunny .sun .beam:nth-of-type(4):before {
  content: "";
  position: absolute;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
#sunny .sun .beam:nth-of-type(4):after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
#sunny .sun .beam:nth-of-type(5) {
  position: absolute;
  width: 15%;
  height: 140%;
  top: -20%;
  left: 42.5%;
  outline: 1px solid #212f45;
  transform: rotate(90deg);
}
#sunny .sun .beam:nth-of-type(5):before {
  content: "";
  position: absolute;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
#sunny .sun .beam:nth-of-type(5):after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
#sunny .sun .beam:nth-of-type(6) {
  position: absolute;
  width: 15%;
  height: 140%;
  top: -20%;
  left: 42.5%;
  outline: 1px solid #212f45;
  transform: rotate(112.5deg);
}
#sunny .sun .beam:nth-of-type(6):before {
  content: "";
  position: absolute;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
#sunny .sun .beam:nth-of-type(6):after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
#sunny .sun .beam:nth-of-type(7) {
  position: absolute;
  width: 15%;
  height: 140%;
  top: -20%;
  left: 42.5%;
  outline: 1px solid #212f45;
  transform: rotate(135deg);
}
#sunny .sun .beam:nth-of-type(7):before {
  content: "";
  position: absolute;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
#sunny .sun .beam:nth-of-type(7):after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
#sunny .sun .beam:nth-of-type(8) {
  position: absolute;
  width: 15%;
  height: 140%;
  top: -20%;
  left: 42.5%;
  outline: 1px solid #212f45;
  transform: rotate(157.5deg);
}
#sunny .sun .beam:nth-of-type(8):before {
  content: "";
  position: absolute;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
#sunny .sun .beam:nth-of-type(8):after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
@keyframes spinSun {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

#partially-cloudy .sun {
  position: absolute;
  width: 42%;
  height: 42%;
  top: 10%;
  right: 15%;
  background: radial-gradient(#fdac49, #fcd422);
  border-radius: 50%;
  animation: spinSun 20s linear infinite;
}
#partially-cloudy .sun:after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0%;
  left: 0%;
  background: inherit;
  border-radius: 50%;
}
#partially-cloudy .sun .beam:nth-child(even):before {
  background: #fdac49;
}
#partially-cloudy .sun .beam:nth-child(even):after {
  background: #fdac49;
}
#partially-cloudy .sun .beam:nth-child(odd):before {
  background: #fcd422;
}
#partially-cloudy .sun .beam:nth-child(odd):after {
  background: #fcd422;
}
#partially-cloudy .sun .beam:nth-of-type(1) {
  position: absolute;
  width: 15%;
  height: 140%;
  top: -20%;
  left: 42.5%;
}
#partially-cloudy .sun .beam:nth-of-type(1):before {
  content: "";
  position: absolute;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
#partially-cloudy .sun .beam:nth-of-type(1):after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
#partially-cloudy .sun .beam:nth-of-type(2) {
  position: absolute;
  width: 15%;
  height: 140%;
  top: -20%;
  left: 42.5%;
  transform: rotate(22.5deg);
}
#partially-cloudy .sun .beam:nth-of-type(2):before {
  content: "";
  position: absolute;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
#partially-cloudy .sun .beam:nth-of-type(2):after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 13%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
#partially-cloudy .sun .beam:nth-of-type(3) {
  position: absolute;
  width: 15%;
  height: 140%;
  top: -20%;
  left: 42.5%;
  transform: rotate(45deg);
}
#partially-cloudy .sun .beam:nth-of-type(3):before {
  content: "";
  position: absolute;
  width: 100%;
  height: 13%;
  clip-path: polygon(5.........完整代码请登录后点击上方下载按钮下载查看

网友评论0