其他分享
首页 > 其他分享> > css特效

css特效

作者:互联网

本文是笔者写CSS时常用的套路。不论效果再怎么华丽,万变不离其宗。

1、交错动画

body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  background: #222;
}

.loading {
  $colors: #7ef9ff, #89cff0, #4682b4, #0f52ba, #000080;
  display: flex;
  animation-delay: 1s;

  .dot {
    position: relative;
    width: 2em;
    height: 2em;
    margin: 0.8em;
    border-radius: 50%;

    &::before {
      position: absolute;
      content: "";
      width: 100%;
      height: 100%;
      background: inherit;
      border-radius: inherit;
      animation: wave 2s ease-out infinite;
    }

    @for $i from 1 through 5 {
      &:nth-child(#{$i}) {
        background: nth($colors, $i);

        &::before {
          animation-delay: $i * 0.2s;
        }
      }
    }
  }
}

@keyframes wave {
  50%,
  75% {
    transform: scale(2.5);
  }

  80%,
  100% {
    opacity: 0;
  }
}

<div class="loading">
  <div class="dot"></div>
  <div class="dot"></div>
  <div class="dot"></div>
  <div class="dot"></div>
  <div class="dot"></div>
</div>
View Code

有时候,我们需要给多个元素添加同一个动画,播放后,不难发现它们会一起运动,一起结束,这样就会显得很平淡无奇。那么如何将动画变得稍微有趣一点呢?很简单,既然它们都是同一时刻开始运动的,那么让它们不在同一时刻运动不就可以了吗。如何让它们不在同一时刻运动呢?注意到CSS动画有延迟(delay)这一属性。举个栗子,比如有十个元素播放十个动画,将第二个元素的动画播放时间设定为比第一个元素晚0.5秒(也就是将延迟设为0.5秒),其他元素以此类推,这样它们就会错开来,形成一种独特的视觉效果。

这就是所谓的交错动画:通过设置不同的延迟时间,达到动画交错播放的效果。

本demo地址:https://codepen.io/alphardex/pen/XWWWBmQ

<div class="loading">
  <div class="dot"></div>
  <div class="dot"></div>
  <div class="dot"></div>
  <div class="dot"></div>
  <div class="dot"></div>
</div>

body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  background: #222;
}

.loading {
  $colors: #7ef9ff, #89cff0, #4682b4, #0f52ba, #000080;
  display: flex;
  animation-delay: 1s;

  .dot {
    position: relative;
    width: 2em;
    height: 2em;
    margin: 0.8em;
    border-radius: 50%;

    &::before {
      position: absolute;
      content: "";
      width: 100%;
      height: 100%;
      background: inherit;
      border-radius: inherit;
      animation: wave 2s ease-out infinite;
    }

    @for $i from 1 through 5 {
      &:nth-child(#{$i}) {
        background: nth($colors, $i);

        &::before {
          animation-delay: $i * 0.2s;
        }
      }
    }
  }
}

@keyframes wave {
  50%,
  75% {
    transform: scale(2.5);
  }

  80%,
  100% {
    opacity: 0;
  }
}
View Code

 

2、用JS分割文本

还有一种经常用到的玩法:用JS将句子或单词分割成字母,并给每个字母加上不同延时的动画,同样也很华丽。

本demo地址:https://codepen.io/alphardex/full/KKwvKGY

<p class="landIn">Ano hi watashitachi mada shiranai no Fushigi no monogatari desu.</p>


@import url("https://fonts.googleapis.com/css?family=Lora:400,400i,700");
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  justify-content: center;
  align-items: center;
  background-image: linear-gradient(rgba(16, 16, 16, 0.8), rgba(16, 16, 16, 0.8)), url(https://i.loli.net/2019/10/18/buDT4YS6zUMfHst.jpg);
  background-size: cover;
}

p {
  margin: 0 9em;
  font-size: 2em;
  font-weight: 600;
}

.landIn {
  display: flex;
  flex-wrap: wrap;
  line-height: 1.8;
  color: white;
  font-family: Lora, serif;
  white-space: pre;
}
.landIn span {
  animation: landIn 0.8s ease-out both;
}

@keyframes landIn {
  from {
    opacity: 0;
    transform: translateY(-20%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


var landInTexts = document.querySelectorAll(".landIn");
landInTexts.forEach(function (landInText) {
    var letters = landInText.textContent.split("");
    landInText.textContent = "";
    letters.forEach(function (letter, i) {
        var span = document.createElement("span");
        span.textContent = letter;
        span.style.animationDelay = i * 0.05 + "s";
        landInText.append(span);
    });
});
View Code

 

一般我们都是从第一个元素开始交错的。但如果要从中间元素开始交错的话,就要给当前元素的延时各加上一个值,这个值就是中间元素的下标到当前元素的下标的距离(也就是下标之差的绝对值)与步长的乘积,即:delay + Math.abs(i - middle) * step,其中中间元素的下标middle = letters.filter(e => e !== "").length /

 

2本demo地址:https://codepen.io/alphardex/full/eYYMYXJ所有有交错特性的动画都在这儿

3、随机粒子动画

说到随机性,我们可以实现一种更疯狂的效果:给几百个粒子添加交错动画,并且交错时间随机,位置大小也都是随机。如此一来我们就能用纯CSS模拟出下雪的效果。又到了白色相簿的季节呢~为什么你写CSS这么熟练啊?

本demo地址:https://codepen.io/alphardex/full/dyPorwJ

body {
  height: 100vh;
  background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
  overflow: hidden;
  filter: drop-shadow(0 0 10px white);
}

.snow {
  position: absolute;
  width: 10px;
  height: 10px;
  background: white;
  border-radius: 50%;
}
.snow:nth-child(1) {
  opacity: 0.0737;
  transform: translate(20.3505vw, -10px) scale(0.3497);
  animation: fall-1 16s -16s linear infinite;
}
@keyframes fall-1 {
  52.576% {
    transform: translate(21.5588vw, 52.576vh) scale(0.3497);
  }
  to {
    transform: translate(20.95465vw, 100vh) scale(0.3497);
  }
}
.snow:nth-child(2) {
  opacity: 0.555;
  transform: translate(70.6214vw, -10px) scale(0.6697);
  animation: fall-2 26s -5s linear infinite;
}
@keyframes fall-2 {
  66.992% {
    transform: translate(74.5011vw, 66.992vh) scale(0.6697);
  }
  to {
    transform: translate(72.56125vw, 100vh) scale(0.6697);
  }
}
.snow:nth-child(3) {
  opacity: 0.6765;
  transform: translate(17.4472vw, -10px) scale(0.6248);
  animation: fall-3 18s -8s linear infinite;
}
@keyframes fall-3 {
  31.919% {
    transform: translate(21.4926vw, 31.919vh) scale(0.6248);
  }
  to {
    transform: translate(19.4699vw, 100vh) scale(0.6248);
  }
}
.snow:nth-child(4) {
  opacity: 0.8506;
  transform: translate(4.5207vw, -10px) scale(0.9953);
  animation: fall-4 16s -22s linear infinite;
}
@keyframes fall-4 {
  57.365% {
    transform: translate(8.5758vw, 57.365vh) scale(0.9953);
  }
  to {
    transform: translate(6.54825vw, 100vh) scale(0.9953);
  }
}
.snow:nth-child(5) {
  opacity: 0.537;
  transform: translate(76.0682vw, -10px) scale(0.637);
  animation: fall-5 25s -2s linear infinite;
}
@keyframes fall-5 {
  35.563% {
    transform: translate(79.2701vw, 35.563vh) scale(0.637);
  }
  to {
    transform: translate(77.66915vw, 100vh) scale(0.637);
  }
}
.snow:nth-child(6) {
  opacity: 0.5643;
  transform: translate(17.9146vw, -10px) scale(0.7259);
  animation: fall-6 27s -21s linear infinite;
}
@keyframes fall-6 {
  72.372% {
    transform: translate(16.3936vw, 72.372vh) scale(0.7259);
  }
  to {
    transform: translate(17.1541vw, 100vh) scale(0.7259);
  }
}
.snow:nth-child(7) {
  opacity: 0.4084;
  transform: translate(38.674vw, -10px) scale(0.8206);
  animation: fall-7 30s -8s linear infinite;
}
@keyframes fall-7 {
  74.42% {
    transform: translate(34.6651vw, 74.42vh) scale(0.8206);
  }
  to {
    transform: translate(36.66955vw, 100vh) scale(0.8206);
  }
}
.snow:nth-child(8) {
  opacity: 0.8903;
  transform: translate(86.9566vw, -10px) scale(0.6816);
  animation: fall-8 27s -18s linear infinite;
}
@keyframes fall-8 {
  63.169% {
    transform: translate(82.7232vw, 63.169vh) scale(0.6816);
  }
  to {
    transform: translate(84.8399vw, 100vh) scale(0.6816);
  }
}
.snow:nth-child(9) {
  opacity: 0.2204;
  transform: translate(46.8049vw, -10px) scale(0.5587);
  animation: fall-9 19s -5s linear infinite;
}
@keyframes fall-9 {
  48.01% {
    transform: translate(39.8946vw, 48.01vh) scale(0.5587);
  }
  to {
    transform: translate(43.34975vw, 100vh) scale(0.5587);
  }
}
.snow:nth-child(10) {
  opacity: 0.3783;
  transform: translate(29.3545vw, -10px) scale(0.4072);
  animation: fall-10 21s -10s linear infinite;
}
@keyframes fall-10 {
  31.048% {
    transform: translate(29.0383vw, 31.048vh) scale(0.4072);
  }
  to {
    transform: translate(29.1964vw, 100vh) scale(0.4072);
  }
}
.snow:nth-child(11) {
  opacity: 0.5961;
  transform: translate(75.3623vw, -10px) scale(0.7652);
  animation: fall-11 13s -6s linear infinite;
}
@keyframes fall-11 {
  59.401% {
    transform: translate(76.7042vw, 59.401vh) scale(0.7652);
  }
  to {
    transform: translate(76.03325vw, 100vh) scale(0.7652);
  }
}
.snow:nth-child(12) {
  opacity: 0.0235;
  transform: translate(23.1838vw, -10px) scale(0.5747);
  animation: fall-12 19s -2s linear infinite;
}
@keyframes fall-12 {
  62.548% {
    transform: translate(31.9027vw, 62.548vh) scale(0.5747);
  }
  to {
    transform: translate(27.54325vw, 100vh) scale(0.5747);
  }
}
.snow:nth-child(13) {
  opacity: 0.7158;
  transform: translate(42.2669vw, -10px) scale(0.6005);
  animation: fall-13 14s -4s linear infinite;
}
@keyframes fall-13 {
  61.957% {
    transform: translate(50.6008vw, 61.957vh) scale(0.6005);
  }
  to {
    transform: translate(46.43385vw, 100vh) scale(0.6005);
  }
}
.snow:nth-child(14) {
  opacity: 0.9444;
  transform: translate(97.8479vw, -10px) scale(0.0197);
  animation: fall-14 23s -15s linear infinite;
}
@keyframes fall-14 {
  46.55% {
    transform: translate(90.6471vw, 46.55vh) scale(0.0197);
  }
  to {
    transform: translate(94.2475vw, 100vh) scale(0.0197);
  }
}
.snow:nth-child(15) {
  opacity: 0.7349;
  transform: translate(94.7606vw, -10px) scale(0.6356);
  animation: fall-15 18s -3s linear infinite;
}
@keyframes fall-15 {
  51.178% {
    transform: translate(89.2535vw, 51.178vh) scale(0.6356);
  }
  to {
    transform: translate(92.00705vw, 100vh) scale(0.6356);
  }
}
.snow:nth-child(16) {
  opacity: 0.0242;
  transform: translate(56.9409vw, -10px) scale(0.2687);
  animation: fall-16 23s -28s linear infinite;
}
@keyframes fall-16 {
  58.745% {
    transform: translate(49.7148vw, 58.745vh) scale(0.2687);
  }
  to {
    transform: translate(53.32785vw, 100vh) scale(0.2687);
  }
}
.snow:nth-child(17) {
  opacity: 0.5327;
  transform: translate(22.7681vw, -10px) scale(0.5918);
  animation: fall-17 24s -17s linear infinite;
}
@keyframes fall-17 {
  52.565% {
    transform: translate(16.0347vw, 52.565vh) scale(0.5918);
  }
  to {
    transform: translate(19.4014vw, 100vh) scale(0.5918);
  }
}
.snow:nth-child(18) {
  opacity: 0.9008;
  transform: translate(65.9083vw, -10px) scale(0.1905);
  animation: fall-18 23s -11s linear infinite;
}
@keyframes fall-18 {
  46.659% {
    transform: translate(73.2117vw, 46.659vh) scale(0.1905);
  }
  to {
    transform: translate(69.56vw, 100vh) scale(0.1905);
  }
}
.snow:nth-child(19) {
  opacity: 0.5751;
  transform: translate(26.4023vw, -10px) scale(0.8664);
  animation: fall-19 24s -30s linear infinite;
}
@keyframes fall-19 {
  41.042% {
    transform: translate(30.9863vw, 41.042vh) scale(0.8664);
  }
  to {
    transform: translate(28.6943vw, 100vh) scale(0.8664);
  }
}
.snow:nth-child(20) {
  opacity: 0.5059;
  transform: translate(46.1037vw, -10px) scale(0.6626);
  animation: fall-20 25s -11s linear infinite;
}
@keyframes fall-20 {
  75.312% {
    transform: translate(45.541vw, 75.312vh) scale(0.6626);
  }
  to {
    transform: translate(45.82235vw, 100vh) scale(0.6626);
  }
}
.snow:nth-child(21) {
  opacity: 0.1352;
  transform: translate(87.9225vw, -10px) scale(0.7153);
  animation: fall-21 27s -30s linear infinite;
}
@keyframes fall-21 {
  45.805% {
    transform: translate(91.0994vw, 45.805vh) scale(0.7153);
  }
  to {
    transform: translate(89.51095vw, 100vh) scale(0.7153);
  }
}
.snow:nth-child(22) {
  opacity: 0.9779;
  transform: translate(27.4412vw, -10px) scale(0.043);
  animation: fall-22 16s -4s linear infinite;
}
@keyframes fall-22 {
  49.931% {
    transform: translate(25.0224vw, 49.931vh) scale(0.043);
  }
  to {
    transform: translate(26.2318vw, 100vh) scale(0.043);
  }
}
.snow:nth-child(23) {
  opacity: 0.4855;
  transform: translate(31.9569vw, -10px) scale(0.3092);
  animation: fall-23 17s -30s linear infinite;
}
@keyframes fall-23 {
  46.391% {
    transform: translate(25.3455vw, 46.391vh) scale(0.3092);
  }
  to {
    transform: translate(28.6512vw, 100vh) scale(0.3092);
  }
}
.snow:nth-child(24) {
  opacity: 0.837;
  transform: translate(32.5039vw, -10px) scale(0.9193);
  animation: fall-24 23s -9s linear infinite;
}
@keyframes fall-24 {
  50.246% {
    transform: translate(36.4578vw, 50.246vh) scale(0.9193);
  }
  to {
    transform: translate(34.48085vw, 100vh) scale(0.9193);
  }
}
.snow:nth-child(25) {
  opacity: 0.3256;
  transform: translate(22.1626vw, -10px) scale(0.9546);
  animation: fall-25 10s -26s linear infinite;
}
@keyframes fall-25 {
  78.094% {
    transform: translate(26.4543vw, 78.094vh) scale(0.9546);
  }
  to {
    transform: translate(24.30845vw, 100vh) scale(0.9546);
  }
}
.snow:nth-child(26) {
  opacity: 0.7843;
  transform: translate(84.7541vw, -10px) scale(0.6304);
  animation: fall-26 16s -6s linear infinite;
}
@keyframes fall-26 {
  62.572% {
    transform: translate(76.964vw, 62.572vh) scale(0.6304);
  }
  to {
    transform: translate(80.85905vw, 100vh) scale(0.6304);
  }
}
.snow:nth-child(27) {
  opacity: 0.8357;
  transform: translate(78.3888vw, -10px) scale(0.9437);
  animation: fall-27 25s -20s linear infinite;
}
@keyframes fall-27 {
  30.404% {
    transform: translate(78.1522vw, 30.404vh) scale(0.9437);
  }
  to {
    transform: translate(78.2705vw, 100vh) scale(0.9437);
  }
}
.snow:nth-child(28) {
  opacity: 0.3344;
  transform: translate(95.7091vw, -10px) scale(0.9072);
  animation: fall-28 17s -5s linear infinite;
}
@keyframes fall-28 {
  43.341% {
    transform: translate(86.0374vw, 43.341vh) scale(0.9072);
  }
  to {
    transform: translate(90.87325vw, 100vh) scale(0.9072);
  }
}
.snow:nth-child(29) {
  opacity: 0.7767;
  transform: translate(43.7774vw, -10px) scale(0.5682);
  animation: fall-29 13s -24s linear infinite;
}
@keyframes fall-29 {
  51.114% {
    transform: translate(38.8195vw, 51.114vh) scale(0.5682);
  }
  to {
    transform: translate(41.29845vw, 100vh) scale(0.5682);
  }
}
.snow:nth-child(30) {
  opacity: 0.5833;
  transform: translate(73.7685vw, -10px) scale(0.2305);
  animation: fall-30 21s -11s linear infinite;
}
@keyframes fall-30 {
  30.059% {
    transform: translate(80.9363vw, 30.059vh) scale(0.2305);
  }
  to {
    transform: translate(77.3524vw, 100vh) scale(0.2305);
  }
}
.snow:nth-child(31) {
  opacity: 0.9074;
  transform: translate(37.8643vw, -10px) scale(0.178);
  animation: fall-31 15s -25s linear infinite;
}
@keyframes fall-31 {
  35.02% {
    transform: translate(29.777vw, 35.02vh) scale(0.178);
  }
  to {
    transform: translate(33.82065vw, 100vh) scale(0.178);
  }
}
.snow:nth-child(32) {
  opacity: 0.7567;
  transform: translate(26.8279vw, -10px) scale(0.4107);
  animation: fall-32 28s -23s linear infinite;
}
@keyframes fall-32 {
  70.122% {
    transform: translate(22.0106vw, 70.122vh) scale(0.4107);
  }
  to {
    transform: translate(24.41925vw, 100vh) scale(0.4107);
  }
}
.snow:nth-child(33) {
  opacity: 0.6883;
  transform: translate(36.0267vw, -10px) scale(0.4943);
  animation: fall-33 26s -18s linear infinite;
}
@keyframes fall-33 {
  58.355% {
    transform: translate(37.0597vw, 58.355vh) scale(0.4943);
  }
  to {
    transform: translate(36.5432vw, 100vh) scale(0.4943);
  }
}
.snow:nth-child(34) {
  opacity: 0.4509;
  transform: translate(88.9659vw, -10px) scale(0.226);
  animation: fall-34 14s -16s linear infinite;
}
@keyframes fall-34 {
  32.6% {
    transform: translate(81.9713vw, 32.6vh) scale(0.226);
  }
  to {
    transform: translate(85.4686vw, 100vh) scale(0.226);
  }
}
.snow:nth-child(35) {
  opacity: 0.9265;
  transform: translate(26.3457vw, -10px) scale(0.8498);
  animation: fall-35 13s -2s linear infinite;
}
@keyframes fall-35 {
  51.105% {
    transform: translate(35.1244vw, 51.105vh) scale(0.8498);
  }
  to {
    transform: translate(30.73505vw, 100vh) scale(0.8498);
  }
}
.snow:nth-child(36) {
  opacity: 0.4581;
  transform: translate(45.8763vw, -10px) scale(0.2974);
  animation: fall-36 26s -13s linear infinite;
}
@keyframes fall-36 {
  71.002% {
    transform: translate(45.2706vw, 71.002vh) scale(0.2974);
  }
  to {
    transform: translate(45.57345vw, 100vh) scale(0.2974);
  }
}
.snow:nth-child(37) {
  opacity: 0.4801;
  transform: translate(6.599vw, -10px) scale(0.935);
  animation: fall-37 20s -25s linear infinite;
}
@keyframes fall-37 {
  35.269% {
    transform: translate(4.4188vw, 35.269vh) scale(0.935);
  }
  to {
    transform: translate(5.5089vw, 100vh) scale(0.935);
  }
}
.snow:nth-child(38) {
  opacity: 0.5935;
  transform: translate(98.4507vw, -10px) scale(0.4339);
  animation: fall-38 13s -21s linear infinite;
}
@keyframes fall-38 {
  70.513% {
    transform: translate(106.063vw, 70.513vh) scale(0.4339);
  }
  to {
    transform: translate(102.25685vw, 100vh) scale(0.4339);
  }
}
.snow:nth-child(39) {
  opacity: 0.2582;
  transform: translate(52.0078vw, -10px) scale(0.1702);
  animation: fall-39 14s -8s linear infinite;
}
@keyframes fall-39 {
  61.394% {
    transform: translate(57.7227vw, 61.394vh) scale(0.1702);
  }
  to {
    transform: translate(54.86525vw, 100vh) scale(0.1702);
  }
}
.snow:nth-child(40) {
  opacity: 0.7028;
  transform: translate(83.2624vw, -10px) scale(0.9635);
  animation: fall-40 13s -19s linear infinite;
}
@keyframes fall-40 {
  58.067% {
    transform: translate(92.3594vw, 58.067vh) scale(0.9635);
  }
  to {
    transform: translate(87.8109vw, 100vh) scale(0.9635);
  }
}
.snow:nth-child(41) {
  opacity: 0.6514;
  transform: translate(43.8952vw, -10px) scale(0.7891);
  animation: fall-41 28s -8s linear infinite;
}
@keyframes fall-41 {
  78.583% {
    transform: translate(44.7241vw, 78.583vh) scale(0.7891);
  }
  to {
    transform: translate(44.30965vw, 100vh) scale(0.7891);
  }
}
.snow:nth-child(42) {
  opacity: 0.2639;
  transform: translate(12.8965vw, -10px) scale(0.0651);
  animation: fall-42 29s -10s linear infinite;
}
@keyframes fall-42 {
  62.127% {
    transform: translate(14.98vw, 62.127vh) scale(0.0651);
  }
  to {
    transform: translate(13.93825vw, 100vh) scale(0.0651);
  }
}
.snow:nth-child(43) {
  opacity: 0.8538;
  transform: translate(80.8053vw, -10px) scale(0.2095);
  animation: fall-43 28s -28s linear infinite;
}
@keyframes fall-43 {
  57.47% {
    transform: translate(81.2954vw, 57.47vh) scale(0.2095);
  }
  to {
    transform: translate(81.05035vw, 100vh) scale(0.2095);
  }
}
.snow:nth-child(44) {
  opacity: 0.4489;
  transform: translate(48.5041vw, -10px) scale(0.3873);
  animation: fall-44 27s -26s linear infinite;
}
@keyframes fall-44 {
  56.337% {
    transform: translate(40.7566vw, 56.337vh) scale(0.3873);
  }
  to {
    transform: translate(44.63035vw, 100vh) scale(0.3873);
  }
}
.snow:nth-child(45) {
  opacity: 0.3344;
  transform: translate(19.4043vw, -10px) scale(0.4033);
  animation: fall-45 20s -13s linear infinite;
}
@keyframes fall-45 {
  57.562% {
    transform: translate(17.6333vw, 57.562vh) scale(0.4033);
  }
  to {
    transform: translate(18.5188vw, 100vh) scale(0.4033);
  }
}
.snow:nth-child(46) {
  opacity: 0.683;
  transform: translate(43.0709vw, -10px) scale(0.3947);
  animation: fall-46 30s -7s linear infinite;
}
@keyframes fall-46 {
  59.345% {
    transform: translate(52.0201vw, 59.345vh) scale(0.3947);
  }
  to {
    transform: translate(47.5455vw, 100vh) scale(0.3947);
  }
}
.snow:nth-child(47) {
  opacity: 0.3477;
  transform: translate(86.238vw, -10px) scale(0.6882);
  animation: fall-47 30s -15s linear infinite;
}
@keyframes fall-47 {
  31.725% {
    transform: translate(84.1381vw, 31.725vh) scale(0.6882);
  }
  to {
    transform: translate(85.18805vw, 100vh) scale(0.6882);
  }
}
.snow:nth-child(48) {
  opacity: 0.2166;
  transform: translate(30.9875vw, -10px) scale(0.8747);
  animation: fall-48 20s -8s linear infinite;
}
@keyframes fall-48 {
  55.578% {
    transform: translate(36.652vw, 55.578vh) scale(0.8747);
  }
  to {
    transform: translate(33.81975vw, 100vh) scale(0.8747);
  }
}
.snow:nth-child(49) {
  opacity: 0.9991;
  transform: translate(83.2435vw, -10px) scale(0.6511);
  animation: fall-49 21s -19s linear infinite;
}
@keyframes fall-49 {
  63.314% {
    transform: translate(84.7735vw, 63.314vh) scale(0.6511);
  }
  to {
    transform: translate(84.0085vw, 100vh) scale(0.6511);
  }
}
.snow:nth-child(50) {
  opacity: 0.9214;
  transform: translate(93.8313vw, -10px) scale(0.6586);
  animation: fall-50 19s -22s linear infinite;
}
@keyframes fall-50 {
  41.486% {
    transform: translate(83.9766vw, 41.486vh) scale(0.6586);
  }
  to {
    transform: translate(88.90395vw, 100vh) scale(0.6586);
  }
}
.snow:nth-child(51) {
  opacity: 0.8926;
  transform: translate(73.9078vw, -10px) scale(0.8116);
  animation: fall-51 26s -17s linear infinite;
}
@keyframes fall-51 {
  44.571% {
    transform: translate(64.7979vw, 44.571vh) scale(0.8116);
  }
  to {
    transform: translate(69.35285vw, 100vh) scale(0.8116);
  }
}
.snow:nth-child(52) {
  opacity: 0.4767;
  transform: translate(36.2383vw, -10px) scale(0.9744);
  animation: fall-52 25s -17s linear infinite;
}
@keyframes fall-52 {
  34.674% {
    transform: translate(39.9688vw, 34.674vh) scale(0.9744);
  }
  to {
    transform: translate(38.10355vw, 100vh) scale(0.9744);
  }
}
.snow:nth-child(53) {
  opacity: 0.4993;
  transform: translate(26.0842vw, -10px) scale(0.2871);
  animation: fall-53 13s -15s linear infinite;
}
@keyframes fall-53 {
  48.683% {
    transform: translate(27.0333vw, 48.683vh) scale(0.2871);
  }
  to {
    transform: translate(26.55875vw, 100vh) scale(0.2871);
  }
}
.snow:nth-child(54) {
  opacity: 0.6449;
  transform: translate(29.9081vw, -10px) scale(0.7002);
  animation: fall-54 19s -23s linear infinite;
}
@keyframes fall-54 {
  33.57% {
    transform: translate(36.9223vw, 33.57vh) scale(0.7002);
  }
  to {
    transform: translate(33.4152vw, 100vh) scale(0.7002);
  }
}
.snow:nth-child(55) {
  opacity: 0.9938;
  transform: translate(94.4326vw, -10px) scale(0.9518);
  animation: fall-55 19s -18s linear infinite;
}
@keyframes fall-55 {
  62.436% {
    transform: translate(95.5015vw, 62.436vh) scale(0.9518);
  }
  to {
    transform: translate(94.96705vw, 100vh) scale(0.9518);
  }
}
.snow:nth-child(56) {
  opacity: 0.3271;
  transform: translate(62.4778vw, -10px) scale(0.4555);
  animation: fall-56 21s -3s linear infinite;
}
@keyframes fall-56 {
  79.623% {
    transform: translate(55.0367vw, 79.623vh) scale(0.4555);
  }
  to {
    transform: translate(58.75725vw, 100vh) scale(0.4555);
  }
}
.snow:nth-child(57) {
  opacity: 0.1682;
  transform: translate(72.657vw, -10px) scale(0.6043);
  animation: fall-57 30s -6s linear infinite;
}
@keyframes fall-57 {
  54.314% {
    transform: translate(70.3779vw, 54.314vh) scale(0.6043);
  }
  to {
    transform: translate(71.51745vw, 100vh) scale(0.6043);
  }
}
.snow:nth-child(58) {
  opacity: 0.5199;
  transform: translate(82.2139vw, -10px) scale(0.57);
  animation: fall-58 30s -12s linear infinite;
}
@keyframes fall-58 {
  49.943% {
    transform: translate(77.3922vw, 49.943vh) scale(0.57);
  }
  to {
    transform: translate(79.80305vw, 100vh) scale(0.57);
  }
}
.snow:nth-child(59) {
  opacity: 0.0001;
  transform: translate(78.8676vw, -10px) scale(0.3227);
  animation: fall-59 28s -14s linear infinite;
}
@keyframes fall-59 {
  63.509% {
    transform: translate(79.2574vw, 63.509vh) scale(0.3227);
  }
  to {
    transform: translate(79.0625vw, 100vh) scale(0.3227);
  }
}
.snow:nth-child(60) {
  opacity: 0.3454;
  transform: translate(56.9824vw, -10px) scale(0.1095);
  animation: fall-60 19s -11s linear infinite;
}
@keyframes fall-60 {
  78.73% {
    transform: translate(62.5726vw, 78.73vh) scale(0.1095);
  }
  to {
    transform: translate(59.7775vw, 100vh) scale(0.1095);
  }
}
.snow:nth-child(61) {
  opacity: 0.6623;
  transform: translate(24.9686vw, -10px) scale(0.3828);
  animation: fall-61 13s -24s linear infinite;
}
@keyframes fall-61 {
  48.328% {
    transform: translate(22.7052vw, 48.328vh) scale(0.3828);
  }
  to {
    transform: translate(23.8369vw, 100vh) scale(0.3828);
  }
}
.snow:nth-child(62) {
  opacity: 0.2265;
  transform: translate(46.5422vw, -10px) scale(0.8104);
  animation: fall-62 12s -11s linear infinite;
}
@keyframes fall-62 {
  37.195% {
    transform: translate(53.592vw, 37.195vh) scale(0.8104);
  }
  to {
    transform: translate(50.0671vw, 100vh) scale(0.8104);
  }
}
.snow:nth-child(63) {
  opacity: 0.6283;
  transform: translate(28.0166vw, -10px) scale(0.0007);
  animation: fall-63 20s -26s linear infinite;
}
@keyframes fall-63 {
  31.32% {
    transform: translate(36.6847vw, 31.32vh) scale(0.0007);
  }
  to {
    transform: translate(32.35065vw, 100vh) scale(0.0007);
  }
}
.snow:nth-child(64) {
  opacity: 0.2055;
  transform: translate(48.4979vw, -10px) scale(0.5253);
  animation: fall-64 29s -30s linear infinite;
}
@keyframes fall-64 {
  43.404% {
    transform: translate(38.5086vw, 43.404vh) scale(0.5253);
  }
  to {
    transform: translate(43.50325vw, 100vh) scale(0.5253);
  }
}
.snow:nth-child(65) {
  opacity: 0.5231;
  transform: translate(18.4495vw, -10px) scale(0.0009);
  animation: fall-65 28s -22s linear infinite;
}
@keyframes fall-65 {
  31.801% {
    transform: translate(19.9382vw, 31.801vh) scale(0.0009);
  }
  to {
    transform: translate(19.19385vw, 100vh) scale(0.0009);
  }
}
.snow:nth-child(66) {
  opacity: 0.434;
  transform: translate(32.737vw, -10px) scale(0.179);
  animation: fall-66 14s -8s linear infinite;
}
@keyframes fall-66 {
  61.942% {
    transform: translate(31.8866vw, 61.942vh) scale(0.179);
  }
  to {
    transform: translate(32.3118vw, 100vh) scale(0.179);
  }
}
.snow:nth-child(67) {
  opacity: 0.0314;
  transform: translate(48.9145vw, -10px) scale(0.7916);
  animation: fall-67 12s -10s linear infinite;
}
@keyframes fall-67 {
  39.372% {
    transform: translate(56.054vw, 39.372vh) scale(0.7916);
  }
  to {
    transform: translate(52.48425vw, 100vh) scale(0.7916);
  }
}
.snow:nth-child(68) {
  opacity: 0.8353;
  transform: translate(0.3179vw, -10px) scale(0.632);
  animation: fall-68 10s -13s linear infinite;
}
@keyframes fall-68 {
  30.979% {
    transform: translate(1.5342vw, 30.979vh) scale(0.632);
  }
  to {
    transform: translate(0.92605vw, 100vh) scale(0.632);
  }
}
.snow:nth-child(69) {
  opacity: 0.8149;
  transform: translate(92.2967vw, -10px) scale(0.1185);
  animation: fall-69 25s -10s linear infinite;
}
@keyframes fall-69 {
  37.955% {
    transform: translate(97.3661vw, 37.955vh) scale(0.1185);
  }
  to {
    transform: translate(94.8314vw, 100vh) scale(0.1185);
  }
}
.snow:nth-child(70) {
  opacity: 0.0467;
  transform: translate(40.1426vw, -10px) scale(0.494);
  animation: fall-70 22s -24s linear infinite;
}
@keyframes fall-70 {
  79.052% {
    transform: translate(47.7498vw, 79.052vh) scale(0.494);
  }
  to {
    transform: translate(43.9462vw, 100vh) scale(0.494);
  }
}
.snow:nth-child(71) {
  opacity: 0.5488;
  transform: translate(47.3198vw, -10px) scale(0.6936);
  animation: fall-71 17s -10s linear infinite;
}
@keyframes fall-71 {
  73.135% {
    transform: translate(43.9801vw, 73.135vh) scale(0.6936);
  }
  to {
    transform: translate(45.64995vw, 100vh) scale(0.6936);
  }
}
.snow:nth-child(72) {
  opacity: 0.5402;
  transform: translate(64.6305vw, -10px) scale(0.9923);
  animation: fall-72 19s -12s linear infinite;
}
@keyframes fall-72 {
  50.179% {
    transform: translate(55.8855vw, 50.179vh) scale(0.9923);
  }
  to {
    transform: translate(60.258vw, 100vh) scale(0.9923);
  }
}
.snow:nth-child(73) {
  opacity: 0.1245;
  transform: translate(86.0414vw, -10px) scale(0.5987);
  animation: fall-73 24s -13s linear infinite;
}
@keyframes fall-73 {
  41.231% {
    transform: translate(81.4063vw, 41.231vh) scale(0.5987);
  }
  to {
    transform: translate(83.72385vw, 100vh) scale(0.5987);
  }
}
.snow:nth-child(74) {
  opacity: 0.6465;
  transform: translate(95.6806vw, -10px) scale(0.3217);
  animation: fall-74 20s -5s linear infinite;
}
@keyframes fall-74 {
  44.59% {
    transform: translate(105.2735vw, 44.59vh) scale(0.3217);
  }
  to {
    transform: translate(100.47705vw, 100vh) scale(0.3217);
  }
}
.snow:nth-child(75) {
  opacity: 0.5164;
  transform: translate(67.901vw, -10px) scale(0.0921);
  animation: fall-75 20s -15s linear infinite;
}
@keyframes fall-75 {
  63.648% {
    transform: translate(77.0543vw, 63.648vh) scale(0.0921);
  }
  to {
    transform: translate(72.47765vw, 100vh) scale(0.0921);
  }
}
.snow:nth-child(76) {
  opacity: 0.2217;
  transform: translate(16.892vw, -10px) scale(0.3467);
  animation: fall-76 14s -26s linear infinite;
}
@keyframes fall-76 {
  47.65% {
    transform: translate(14.8118vw, 47.65vh) scale(0.3467);
  }
  to {
    transform: translate(15.8519vw, 100vh) scale(0.3467);
  }
}
.snow:nth-child(77) {
  opacity: 0.0871;
  transform: translate(23.7087vw, -10px) scale(0.557);
  animation: fall-77 25s -14s linear infinite;
}
@keyframes fall-77 {
  40.89% {
    transform: translate(24.415vw, 40.89vh) scale(0.557);
  }
  to {
    transform: translate(24.06185vw, 100vh) scale(0.557);
  }
}
.snow:nth-child(78) {
  opacity: 0.7374;
  transform: translate(94.9778vw, -10px) scale(0.3973);
  animation: fall-78 26s -11s linear infinite;
}
@keyframes fall-78 {
  44.819% {
    transform: translate(89.1624vw, 44.819vh) scale(0.3973);
  }
  to {
    transform: translate(92.0701vw, 100vh) scale(0.3973);
  }
}
.snow:nth-child(79) {
  opacity: 0.3147;
  transform: translate(13.9634vw, -10px) scale(0.912);
  animation: fall-79 15s -24s linear infinite;
}
@keyframes fall-79 {
  68.652% {
    transform: translate(4.6482vw, 68.652vh) scale(0.912);
  }
  to {
    transform: translate(9.3058vw, 100vh) scale(0.912);
  }
}
.snow:nth-child(80) {
  opacity: 0.6292;
  transform: translate(89.0728vw, -10px) scale(0.6402);
  animation: fall-80 16s -18s linear infinite;
}
@keyframes fall-80 {
  61.99% {
    transform: translate(84.5655vw, 61.99vh) scale(0.6402);
  }
  to {
    transform: translate(86.81915vw, 100vh) scale(0.6402);
  }
}
.snow:nth-child(81) {
  opacity: 0.1094;
  transform: translate(77.0863vw, -10px) scale(0.0889);
  animation: fall-81 21s -9s linear infinite;
}
@keyframes fall-81 {
  39.825% {
    transform: translate(76.5233vw, 39.825vh) scale(0.0889);
  }
  to {
    transform: translate(76.8048vw, 100vh) scale(0.0889);
  }
}
.snow:nth-child(82) {
  opacity: 0.274;
  transform: translate(25.2541vw, -10px) scale(0.1522);
  animation: fall-82 26s -12s linear infinite;
}
@keyframes fall-82 {
  66.187% {
    transform: translate(19.2541vw, 66.187vh) scale(0.1522);
  }
  to {
    transform: translate(22.2541vw, 100vh) scale(0.1522);
  }
}
.snow:nth-child(83) {
  opacity: 0.5821;
  transform: translate(76.5279vw, -10px) scale(0.1347);
  animation: fall-83 24s -23s linear infinite;
}
@keyframes fall-83 {
  33.072% {
    transform: translate(84.7915vw, 33.072vh) scale(0.1347);
  }
  to {
    transform: translate(80.6597vw, 100vh) scale(0.1347);
  }
}
.snow:nth-child(84) {
  opacity: 0.6462;
  transform: translate(43.4174vw, -10px) scale(0.8859);
  animation: fall-84 11s -21s linear infinite;
}
@keyframes fall-84 {
  57.868% {
    transform: translate(37.4702vw, 57.868vh) scale(0.8859);
  }
  to {
    transform: translate(40.4438vw, 100vh) scale(0.8859);
  }
}
.snow:nth-child(85) {
  opacity: 0.5027;
  transform: translate(20.5231vw, -10px) scale(0.0545);
  animation: fall-85 18s -4s linear infinite;
}
@keyframes fall-85 {
  43.66% {
    transform: translate(15.8884vw, 43.66vh) scale(0.0545);
  }
  to {
    transform: translate(18.20575vw, 100vh) scale(0.0545);
  }
}
.snow:nth-child(86) {
  opacity: 0.4363;
  transform: translate(67.2664vw, -10px) scale(0.5953);
  animation: fall-86 24s -7s linear infinite;
}
@keyframes fall-86 {
  66.61% {
    transform: translate(70.1693vw, 66.61vh) scale(0.5953);
  }
  to {
    transform: translate(68.71785vw, 100vh) scale(0.5953);
  }
}
.snow:nth-child(87) {
  opacity: 0.1166;
  transform: translate(29.7976vw, -10px) scale(0.8371);
  animation: fall-87 15s -17s linear infinite;
}
@keyframes fall-87 {
  31.03% {
    transform: translate(20.4157vw, 31.03vh) scale(0.8371);
  }
  to {
    transform: translate(25.10665vw, 100vh) scale(0.8371);
  }
}
.snow:nth-child(88) {
  opacity: 0.4926;
  transform: translate(49.9485vw, -10px) scale(0.9542);
  animation: fall-88 17s -25s linear infinite;
}
@keyframes fall-88 {
  78.484% {
    transform: translate(42.1456vw, 78.484vh) scale(0.9542);
  }
  to {
    transform: translate(46.04705vw, 100vh) scale(0.9542);
  }
}
.snow:nth-child(89) {
  opacity: 0.1356;
  transform: translate(9.2616vw, -10px) scale(0.2625);
  animation: fall-89 21s -9s linear infinite;
}
@keyframes fall-89 {
  58.489% {
    transform: translate(12.0484vw, 58.489vh) scale(0.2625);
  }
  to {
    transform: translate(10.655vw, 100vh) scale(0.2625);
  }
}
.snow:nth-child(90) {
  opacity: 0.0061;
  transform: translate(14.849vw, -10px) scale(0.2005);
  animation: fall-90 12s -25s linear infinite;
}
@keyframes fall-90 {
  34.863% {
    transform: translate(15.0256vw, 34.863vh) scale(0.2005);
  }
  to {
    transform: translate(14.9373vw, 100vh) scale(0.2005);
  }
}
.snow:nth-child(91) {
  opacity: 0.6196;
  transform: translate(49.3092vw, -10px) scale(0.0661);
  animation: fall-91 16s -6s linear infinite;
}
@keyframes fall-91 {
  67.776% {
    transform: translate(47.9415vw, 67.776vh) scale(0.0661);
  }
  to {
    transform: translate(48.62535vw, 100vh) scale(0.0661);
  }
}
.snow:nth-child(92) {
  opacity: 0.811;
  transform: translate(10.3788vw, -10px) scale(0.1599);
  animation: fall-92 12s -8s linear infinite;
}
@keyframes fall-92 {
  70.273% {
    transform: translate(12.1959vw, 70.273vh) scale(0.1599);
  }
  to {
    transform: translate(11.28735vw, 100vh) scale(0.1599);
  }
}
.snow:nth-child(93) {
  opacity: 0.7252;
  transform: translate(97.2938vw, -10px) scale(0.9982);
  animation: fall-93 14s -29s linear infinite;
}
@keyframes fall-93 {
  34.949% {
    transform: translate(88.1125vw, 34.949vh) scale(0.9982);
  }
  to {
    transform: translate(92.70315vw, 100vh) scale(0.9982);
  }
}
.snow:nth-child(94) {
  opacity: 0.1918;
  transform: translate(44.671vw, -10px) scale(0.4122);
  animation: fall-94 21s -2s linear infinite;
}
@keyframes fall-94 {
  57.176% {
    transform: translate(50.2333vw, 57.176vh) scale(0.4122);
  }
  to {
    transform: translate(47.45215vw, 100vh) scale(0.4122);
  }
}
.snow:nth-child(95) {
  opacity: 0.0744;
  transform: translate(97.7336vw, -10px) scale(0.8572);
  animation: fall-95 29s -11s linear infinite;
}
@keyframes fall-95 {
  47.599% {
    transform: translate(105.1579vw, 47.599vh) scale(0.8572);
  }
  to {
    transform: translate(101.44575vw, 100vh) scale(0.8572);
  }
}
.snow:nth-child(96) {
  opacity: 0.8797;
  transform: translate(15.1075vw, -10px) scale(0.2281);
  animation: fall-96 26s -7s linear infinite;
}
@keyframes fall-96 {
  51.714% {
    transform: translate(11.5983vw, 51.714vh) scale(0.2281);
  }
  to {
    transform: translate(13.3529vw, 100vh) scale(0.2281);
  }
}
.snow:nth-child(97) {
  opacity: 0.476;
  transform: translate(53.3783vw, -10px) scale(0.0475);
  animation: fall-97 13s -14s linear infinite;
}
@keyframes fall-97 {
  64.076% {
    transform: translate(45.6798vw, 64.076vh) scale(0.0475);
  }
  to {
    transform: translate(49.52905vw, 100vh) scale(0.0475);
  }
}
.snow:nth-child(98) {
  opacity: 0.7337;
  transform: translate(29.7579vw, -10px) scale(0.6752);
  animation: fall-98 19s -11s linear infinite;
}
@keyframes fall-98 {
  61.718% {
    transform: translate(20.0404vw, 61.718vh) scale(0.6752);
  }
  to {
    transform: translate(24.89915vw, 100vh) scale(0.6752);
  }
}
.snow:nth-child(99) {
  opacity: 0.0097;
  transform: translate(71.1451vw, -10px) scale(0.1649);
  animation: fall-99 10s -28s linear infinite;
}
@keyframes fall-99 {
  73.106% {
    transform: translate(66.885vw, 73.106vh) scale(0.1649);
  }
  to {
    transform: translate(69.01505vw, 100vh) scale(0.1649);
  }
}
.snow:nth-child(100) {
  opacity: 0.1136;
  transform: translate(0.2411vw, -10px) scale(0.244);
  animation: fall-100 23s -21s linear infinite;
}
@keyframes fall-100 {
  73.096% {
    transform: translate(1.7988vw, 73.096vh) scale(0.244);
  }
  to {
    transform: translate(1.01995vw, 100vh) scale(0.244);
  }
}
.snow:nth-child(101) {
  opacity: 0.2114;
  transform: translate(76.5578vw, -10px) scale(0.5282);
  animation: fall-101 24s -15s linear infinite;
}
@keyframes fall-101 {
  76.234% {
    transform: translate(73.1032vw, 76.234vh) scale(0.5282);
  }
  to {
    transform: translate(74.8305vw, 100vh) scale(0.5282);
  }
}
.snow:nth-child(102) {
  opacity: 0.1182;
  transform: translate(27.5458vw, -10px) scale(0.8915);
  animation: fall-102 16s -8s linear infinite;
}
@keyframes fall-102 {
  45.976% {
    transform: translate(21.7282vw, 45.976vh) scale(0.8915);
  }
  to {
    transform: translate(24.637vw, 100vh) scale(0.8915);
  }
}
.snow:nth-child(103) {
  opacity: 0.0648;
  transform: translate(16.2287vw, -10px) scale(0.8606);
  animation: fall-103 22s -17s linear infinite;
}
@keyframes fall-103 {
  39.588% {
    transform: translate(21.8235vw, 39.588vh) scale(0.8606);
  }
  to {
    transform: translate(19.0261vw, 100vh) scale(0.8606);
  }
}
.snow:nth-child(104) {
  opacity: 0.5116;
  transform: translate(49.9445vw, -10px) scale(0.7511);
  animation: fall-104 20s -16s linear infinite;
}
@keyframes fall-104 {
  56.203% {
    transform: translate(49.3447vw, 56.203vh) scale(0.7511);
  }
  to {
    transform: translate(49.6446vw, 100vh) scale(0.7511);
  }
}
.snow:nth-child(105) {
  opacity: 0.4206;
  transform: translate(52.1982vw, -10px) scale(0.1434);
  animation: fall-105 19s -6s linear infinite;
}
@keyframes fall-105 {
  50.222% {
    transform: translate(50.0925vw, 50.222vh) scale(0.1434);
  }
  to {
    transform: translate(51.14535vw, 100vh) scale(0.1434);
  }
}
.snow:nth-child(106) {
  opacity: 0.1737;
  transform: translate(53.1364vw, -10px) scale(0.3545);
  animation: fall-106 26s -25s linear infinite;
}
@keyframes fall-106 {
  51.014% {
    transform: translate(53.9578vw, 51.014vh) scale(0.3545);
  }
  to {
    transform: translate(53.5471vw, 100vh) scale(0.3545);
  }
}
.snow:nth-child(107) {
  opacity: 0.4856;
  transform: translate(86.0189vw, -10px) scale(0.603);
  animation: fall-107 22s -8s linear infinite;
}
@keyframes fall-107 {
  53.202% {
    transform: translate(85.053vw, 53.202vh) scale(0.603);
  }
  to {
    transform: translate(85.53595vw, 100vh) scale(0.603);
  }
}
.snow:nth-child(108) {
  opacity: 0.5231;
  transform: translate(70.5278vw, -10px) scale(0.4502);
  animation: fall-108 27s -23s linear infinite;
}
@keyframes fall-108 {
  48.564% {
    transform: translate(71.755vw, 48.564vh) scale(0.4502);
  }
  to {
    transform: translate(71.1414vw, 100vh) scale(0.4502);
  }
}
.snow:nth-child(109) {
  opacity: 0.6152;
  transform: translate(70.752vw, -10px) scale(0.7058);
  animation: fall-109 11s -6s linear infinite;
}
@keyframes fall-109 {
  71.333% {
    transform: translate(73.2797vw, 71.333vh) scale(0.7058);
  }
  to {
    transform: translate(72.01585vw, 100vh) scale(0.7058);
  }
}
.snow:nth-child(110) {
  opacity: 0.9014;
  transform: translate(6.9908vw, -10px) scale(0.8813);
  animation: fall-110 20s -21s linear infinite;
}
@keyframes fall-110 {
  46.424% {
    transform: translate(4.9362vw, 46.424vh) scale(0.8813);
  }
  to {
    transform: translate(5.9635vw, 100vh) scale(0.8813);
  }
}
.snow:nth-child(111) {
  opacity: 0.4925;
  transform: translate(82.4703vw, -10px) scale(0.552);
  animation: fall-111 16s -7s linear infinite;
}
@keyframes fall-111 {
  36.016% {
    transform: translate(87.2922vw, 36.016vh) scale(0.552);
  }
  to {
    transform: translate(84.88125vw, 100vh) scale(0.552);
  }
}
.snow:nth-child(112) {
  opacity: 0.2304;
  transform: translate(46.9665vw, -10px) scale(0.5748);
  animation: fall-112 24s -19s linear infinite;
}
@keyframes fall-112 {
  71.269% {
    transform: translate(54.8676vw, 71.269vh) scale(0.5748);
  }
  to {
    transform: translate(50.91705vw, 100vh) scale(0.5748);
  }
}
.snow:nth-child(113) {
  opacity: 0.4241;
  transform: translate(43.9977vw, -10px) scale(0.1124);
  animation: fall-113 27s -29s linear infinite;
}
@keyframes fall-113 {
  56.837% {
    transform: translate(34.3154vw, 56.837vh) scale(0.1124);
  }
  to {
    transform: translate(39.15655vw, 100vh) scale(0.1124);
  }
}
.snow:nth-child(114) {
  opacity: 0.5892;
  transform: translate(58.0742vw, -10px) scale(0.0565);
  animation: fall-114 22s -20s linear infinite;
}
@keyframes fall-114 {
  54.431% {
    transform: translate(59.484vw, 54.431vh) scale(0.0565);
  }
  to {
    transform: translate(58.7791vw, 100vh) scale(0.0565);
  }
}
.snow:nth-child(115) {
  opacity: 0.5748;
  transform: translate(10.0661vw, -10px) scale(0.3866);
  animation: fall-115 28s -6s linear infinite;
}
@keyframes fall-115 {
  66.601% {
    transform: translate(8.1193vw, 66.601vh) scale(0.3866);
  }
  to {
    transform: translate(9.0927vw, 100vh) scale(0.3866);
  }
}
.snow:nth-child(116) {
  opacity: 0.8135;
  transform: translate(80.9438vw, -10px) scale(0.9891);
  animation: fall-116 27s -4s linear infinite;
}
@keyframes fall-116 {
  76.275% {
    transform: translate(72.2325vw, 76.275vh) scale(0.9891);
  }
  to {
    transform: translate(76.58815vw, 100vh) scale(0.9891);
  }
}
.snow:nth-child(117) {
  opacity: 0.979;
  transform: translate(84.6654vw, -10px) scale(0.0581);
  animation: fall-117 27s -7s linear infinite;
}
@keyframes fall-117 {
  38.68% {
    transform: translate(91.209vw, 38.68vh) scale(0.0581);
  }
  to {
    transform: translate(87.9372vw, 100vh) scale(0.0581);
  }
}
.snow:nth-child(118) {
  opacity: 0.6421;
  transform: translate(42.3887vw, -10px) scale(0.8054);
  animation: fall-118 28s -8s linear infinite;
}
@keyframes fall-118 {
  62.931% {
    transform: translate(48.9184vw, 62.931vh) scale(0.8054);
  }
  to {
    transform: translate(45.65355vw, 100vh) scale(0.8054);
  }
}
.snow:nth-child(119) {
  opacity: 0.1884;
  transform: translate(48.5106vw, -10px) scale(0.2989);
  animation: fall-119 17s -15s linear infinite;
}
@keyframes fall-119 {
  50.328% {
    transform: translate(43.084vw, 50.328vh) scale(0.2989);
  }
  to {
    transform: translate(45.7973vw, 100vh) scale(0.2989);
  }
}
.snow:nth-child(120) {
  opacity: 0.9471;
  transform: translate(31.0629vw, -10px) scale(0.3388);
  animation: fall-120 17s -18s linear infinite;
}
@keyframes fall-120 {
  43.297% {
    transform: translate(38.9399vw, 43.297vh) scale(0.3388);
  }
  to {
    transform: translate(35.0014vw, 100vh) scale(0.3388);
  }
}
.snow:nth-child(121) {
  opacity: 0.0264;
  transform: translate(14.9172vw, -10px) scale(0.0517);
  animation: fall-121 29s -24s linear infinite;
}
@keyframes fall-121 {
  74.794% {
    transform: translate(10.4671vw, 74.794vh) scale(0.0517);
  }
  to {
    transform: translate(12.69215vw, 100vh) scale(0.0517);
  }
}
.snow:nth-child(122) {
  opacity: 0.6496;
  transform: translate(32.7121vw, -10px) scale(0.9456);
  animation: fall-122 11s -15s linear infinite;
}
@keyframes fall-122 {
  48.347% {
    transform: translate(25.8181vw, 48.347vh) scale(0.9456);
  }
  to {
    transform: translate(29.2651vw, 100vh) scale(0.9456);
  }
}
.snow:nth-child(123) {
  opacity: 0.1294;
  transform: translate(97.1322vw, -10px) scale(0.1666);
  animation: fall-123 29s -10s linear infinite;
}
@keyframes fall-123 {
  65.764% {
    transform: translate(96.209vw, 65.764vh) scale(0.1666);
  }
  to {
    transform: translate(96.6706vw, 100vh) scale(0.1666);
  }
}
.snow:nth-child(124) {
  opacity: 0.563;
  transform: translate(16.0427vw, -10px) scale(0.2147);
  animation: fall-124 18s -25s linear infinite;
}
@keyframes fall-124 {
  76.542% {
    transform: translate(18.4833vw, 76.542vh) scale(0.2147);
  }
  to {
    transform: translate(17.263vw, 100vh) scale(0.2147);
  }
}
.snow:nth-child(125) {
  opacity: 0.2933;
  transform: translate(6.0185vw, -10px) scale(0.0151);
  animation: fall-125 27s -14s linear infinite;
}
@keyframes fall-125 {
  66.668% {
    transform: translate(12.8024vw, 66.668vh) scale(0.0151);
  }
  to {
    transform: translate(9.41045vw, 100vh) scale(0.0151);
  }
}
.snow:nth-child(126) {
  opacity: 0.9785;
  transform: translate(47.9883vw, -10px) scale(0.6309);
  animation: fall-126 26s -7s linear infinite;
}
@keyframes fall-126 {
  37.146% {
    transform: translate(40.7828vw, 37.146vh) scale(0.6309);
  }
  to {
    transform: translate(44.38555vw, 100vh) scale(0.6309);
  }
}
.snow:nth-child(127) {
  opacity: 0.6904;
  transform: translate(44.9065vw, -10px) scale(0.3339);
  animation: fall-127 15s -20s linear infinite;
}
@keyframes fall-127 {
  70.586% {
    transform: translate(45.3089vw, 70.586vh) scale(0.3339);
  }
  to {
    transform: translate(45.1077vw, 100vh) scale(0.3339);
  }
}
.snow:nth-child(128) {
  opacity: 0.738;
  transform: translate(5.6107vw, -10px) scale(0.2919);
  animation: fall-128 15s -6s linear infinite;
}
@keyframes fall-128 {
  61.312% {
    transform: translate(6.6529vw, 61.312vh) scale(0.2919);
  }
  to {
    transform: translate(6.1318vw, 100vh) scale(0.2919);
  }
}
.snow:nth-child(129) {
  opacity: 0.2272;
  transform: translate(10.9978vw, -10px) scale(0.1356);
  animation: fall-129 26s -5s linear infinite;
}
@keyframes fall-129 {
  73.18% {
    transform: translate(5.3626vw, 73.18vh) scale(0.1356);
  }
  to {
    transform: translate(8.1802vw, 100vh) scale(0.1356);
  }
}
.snow:nth-child(130) {
  opacity: 0.1797;
  transform: translate(60.3986vw, -10px) scale(0.1965);
  animation: fall-130 21s -19s linear infinite;
}
@keyframes fall-130 {
  73.227% {
    transform: translate(61.6807vw, 73.227vh) scale(0.1965);
  }
  to {
    transform: translate(61.03965vw, 100vh) scale(0.1965);
  }
}
.snow:nth-child(131) {
  opacity: 0.1118;
  transform: translate(13.7808vw, -10px) scale(0.8377);
  animation: fall-131 21s -20s linear infinite;
}
@keyframes fall-131 {
  56.762% {
    transform: translate(5.248vw, 56.762vh) scale(0.8377);
  }
  to {
    transform: translate(9.5144vw, 100vh) scale(0.8377);
  }
}
.snow:nth-child(132) {
  opacity: 0.2574;
  transform: translate(40.556vw, -10px) scale(0.9759);
  animation: fall-132 22s -9s linear infinite;
}
@keyframes fall-132 {
  66.795% {
    transform: translate(38.4867vw, 66.795vh) scale(0.9759);
  }
  to {
    transform: translate(39.52135vw, 100vh) scale(0.9759);
  }
}
.snow:nth-child(133) {
  opacity: 0.4077;
  transform: translate(86.7941vw, -10px) scale(0.1684);
  animation: fall-133 12s -22s linear infinite;
}
@keyframes fall-133 {
  41.984% {
    transform: translate(91.3488vw, 41.984vh) scale(0.1684);
  }
  to {
    transform: translate(89.07145vw, 100vh) scale(0.1684);
  }
}
.snow:nth-child(134) {
  opacity: 0.5767;
  transform: translate(20.9224vw, -10px) scale(0.5747);
  animation: fall-134 30s -28s linear infinite;
}
@keyframes fall-134 {
  75.225% {
    transform: translate(12.688vw, 75.225vh) scale(0.5747);
  }
  to {
    transform: translate(16.8052vw, 100vh) scale(0.5747);
  }
}
.snow:nth-child(135) {
  opacity: 0.6653;
  transform: translate(28.5775vw, -10px) scale(0.9363);
  animation: fall-135 25s -28s linear infinite;
}
@keyframes fall-135 {
  64.752% {
    transform: translate(32.3227vw, 64.752vh) scale(0.9363);
  }
  to {
    transform: translate(30.4501vw, 100vh) scale(0.9363);
  }
}
.snow:nth-child(136) {
  opacity: 0.6059;
  transform: translate(59.3208vw, -10px) scale(0.3181);
  animation: fall-136 16s -24s linear infinite;
}
@keyframes fall-136 {
  47.381% {
    transform: translate(49.5767vw, 47.381vh) scale(0.3181);
  }
  to {
    transform: translate(54.44875vw, 100vh) scale(0.3181);
  }
}
.snow:nth-child(137) {
  opacity: 0.4075;
  transform: translate(34.6716vw, -10px) scale(0.6581);
  animation: fall-137 13s -17s linear infinite;
}
@keyframes fall-137 {
  40.703% {
    transform: translate(24.8132vw, 40.703vh) scale(0.6581);
  }
  to {
    transform: translate(29.7424vw, 100vh) scale(0.6581);
  }
}
.snow:nth-child(138) {
  opacity: 0.939;
  transform: translate(78.8959vw, -10px) scale(0.2638);
  animation: fall-138 22s -1s linear infinite;
}
@keyframes fall-138 {
  52.552% {
    transform: translate(73.2266vw, 52.552vh) scale(0.2638);
  }
  to {
    transform: translate(76.06125vw, 100vh) scale(0.2638);
  }
}
.snow:nth-child(139) {
  opacity: 0.7812;
  transform: translate(97.8052vw, -10px) scale(0.9287);
  animation: fall-139 26s -3s linear infinite;
}
@keyframes fall-139 {
  57.199% {
    transform: translate(90.5066vw, 57.199vh) scale(0.9287);
  }
  to {
    transform: translate(94.1559vw, 100vh) scale(0.9287);
  }
}
.snow:nth-child(140) {
  opacity: 0.3559;
  transform: translate(6.9355vw, -10px) scale(0.0839);
  animation: fall-140 12s -28s linear infinite;
}
@keyframes fall-140 {
  48.103% {
    transform: translate(1.3654vw, 48.103vh) scale(0.0839);
  }
  to {
    transform: translate(4.15045vw, 100vh) scale(0.0839);
  }
}
.snow:nth-child(141) {
  opacity: 0.0776;
  transform: translate(68.3434vw, -10px) scale(0.9377);
  animation: fall-141 24s -27s linear infinite;
}
@keyframes fall-141 {
  64.316% {
    transform: translate(61.0892vw, 64.316vh) scale(0.9377);
  }
  to {
    transform: translate(64.7163vw, 100vh) scale(0.9377);
  }
}
.snow:nth-child(142) {
  opacity: 0.4112;
  transform: translate(40.2518vw, -10px) scale(0.3741);
  animation: fall-142 17s -26s linear infinite;
}
@keyframes fall-142 {
  78.67% {
    transform: translate(34.9092vw, 78.67vh) scale(0.3741);
  }
  to {
    transform: translate(37.5805vw, 100vh) scale(0.3741);
  }
}
.snow:nth-child(143) {
  opacity: 0.4772;
  transform: translate(6.1398vw, -10px) scale(0.4434);
  animation: fall-143 24s -18s linear infinite;
}
@keyframes fall-143 {
  37.381% {
    transform: translate(9.668vw, 37.381vh) scale(0.4434);
  }
  to {
    transform: translate(7.9039vw, 100vh) scale(0.4434);
  }
}
.snow:nth-child(144) {
  opacity: 0.7577;
  transform: translate(80.7725vw, -10px) scale(0.043);
  animation: fall-144 22s -8s linear infinite;
}
@keyframes fall-144 {
  75.703% {
    transform: translate(74.7604vw, 75.703vh) scale(0.043);
  }
  to {
    transform: translate(77.76645vw, 100vh) scale(0.043);
  }
}
.snow:nth-child(145) {
  opacity: 0.6914;
  transform: translate(29.7626vw, -10px) scale(0.4205);
  animation: fall-145 23s -5s linear infinite;
}
@keyframes fall-145 {
  77.742% {
    transform: translate(23.7434vw, 77.742vh) scale(0.4205);
  }
  to {
    transform: translate(26.753vw, 100vh) scale(0.4205);
  }
}
.snow:nth-child(146) {
  opacity: 0.122;
  transform: translate(47.8289vw, -10px) scale(0.3646);
  animation: fall-146 14s -13s linear infinite;
}
@keyframes fall-146 {
  73.187% {
    transform: translate(39.6045vw, 73.187vh) scale(0.3646);
  }
  to {
    transform: translate(43.7167vw, 100vh) scale(0.3646);
  }
}
.snow:nth-child(147) {
  opacity: 0.8895;
  transform: translate(41.8595vw, -10px) scale(0.1336);
  animation: fall-147 15s -13s linear infinite;
}
@keyframes fall-147 {
  43.438% {
    transform: translate(37.8206vw, 43.438vh) scale(0.1336);
  }
  to {
    transform: translate(39.84005vw, 100vh) scale(0.1336);
  }
}
.snow:nth-child(148) {
  opacity: 0.4587;
  transform: translate(8.0893vw, -10px) scale(0.3173);
  animation: fall-148 25s -6s linear infinite;
}
@keyframes fall-148 {
  57.893% {
    transform: translate(1.0931vw, 57.893vh) scale(0.3173);
  }
  to {
    transform: translate(4.5912vw, 100vh) scale(0.3173);
  }
}
.snow:nth-child(149) {
  opacity: 0.9986;
  transform: translate(39.8108vw, -10px) scale(0.9834);
  animation: fall-149 15s -22s linear infinite;
}
@keyframes fall-149 {
  68.941% {
    transform: translate(44.9434vw, 68.941vh) scale(0.9834);
  }
  to {
    transform: translate(42.3771vw, 100vh) scale(0.9834);
  }
}
.snow:nth-child(150) {
  opacity: 0.9782;
  transform: translate(59.274vw, -10px) scale(0.4336);
  animation: fall-150 20s -23s linear infinite;
}
@keyframes fall-150 {
  34.81% {
    transform: translate(54.6651vw, 34.81vh) scale(0.4336);
  }
  to {
    transform: translate(56.96955vw, 100vh) scale(0.4336);
  }
}
.snow:nth-child(151) {
  opacity: 0.1002;
  transform: translate(12.931vw, -10px) scale(0.6809);
  animation: fall-151 21s -21s linear infinite;
}
@keyframes fall-151 {
  64.046% {
    transform: translate(3.7202vw, 64.046vh) scale(0.6809);
  }
  to {
    transform: translate(8.3256vw, 100vh) scale(0.6809);
  }
}
.snow:nth-child(152) {
  opacity: 0.1694;
  transform: translate(7.0692vw, -10px) scale(0.6625);
  animation: fall-152 17s -11s linear infinite;
}
@keyframes fall-152 {
  76.898% {
    transform: translate(1.6876vw, 76.898vh) scale(0.6625);
  }
  to {
    transform: translate(4.3784vw, 100vh) scale(0.6625);
  }
}
.snow:nth-child(153) {
  opacity: 0.4454;
  transform: translate(60.1349vw, -10px) scale(0.9714);
  animation: fall-153 27s -22s linear infinite;
}
@keyframes fall-153 {
  73.522% {
    transform: translate(53.7885vw, 73.522vh) scale(0.9714);
  }
  to {
    transform: translate(56.9617vw, 100vh) scale(0.9714);
  }
}
.snow:nth-child(154) {
  opacity: 0.2933;
  transform: translate(28.5145vw, -10px) scale(0.3446);
  animation: fall-154 22s -13s linear infinite;
}
@keyframes fall-154 {
  55.164% {
    transform: translate(34.8852vw, 55.164vh) scale(0.3446);
  }
  to {
    transform: translate(31.69985vw, 100vh) scale(0.3446);
  }
}
.snow:nth-child(155) {
  opacity: 0.247;
  transform: translate(28.2763vw, -10px) scale(0.8954);
  animation: fall-155 19s -21s linear infinite;
}
@keyframes fall-155 {
  52.58% {
    transform: translate(37.1576vw, 52.58vh) scale(0.8954);
  }
  to {
    transform: translate(32.71695vw, 100vh) scale(0.8954);
  }
}
.snow:nth-child(156) {
  opacity: 0.0898;
  transform: translate(39.6267vw, -10px) scale(0.7387);
  animation: fall-156 28s -28s linear infinite;
}
@keyframes fall-156 {
  42.258% {
    transform: translate(31.1205vw, 42.258vh) scale(0.7387);
  }
  to {
    transform: translate(35.3736vw, 100vh) scale(0.7387);
  }
}
.snow:nth-child(157) {
  opacity: 0.7208;
  transform: translate(46.039vw, -10px) scale(0.6495);
  animation: fall-157 15s -24s linear infinite;
}
@keyframes fall-157 {
  40.316% {
    transform: translate(52.9592vw, 40.316vh) scale(0.6495);
  }
  to {
    transform: translate(49.4991vw, 100vh) scale(0.6495);
  }
}
.snow:nth-child(158) {
  opacity: 0.2556;
  transform: translate(75.046vw, -10px) scale(0.3374);
  animation: fall-158 12s -9s linear infinite;
}
@keyframes fall-158 {
  49.384% {
    transform: translate(83.1399vw, 49.384vh) scale(0.3374);
  }
  to {
    transform: translate(79.09295vw, 100vh) scale(0.3374);
  }
}
.snow:nth-child(159) {
  opacity: 0.5302;
  transform: translate(35.4627vw, -10px) scale(0.4821);
  animation: fall-159 13s -13s linear infinite;
}
@keyframes fall-159 {
  78.51% {
    transform: translate(44.7904vw, 78.51vh) scale(0.4821);
  }
  to {
    transform: translate(40.12655vw, 100vh) scale(0.4821);
  }
}
.snow:nth-child(160) {
  opacity: 0.7771;
  transform: translate(28.2984vw, -10px) scale(0.0107);
  animation: fall-160 25s -24s linear infinite;
}
@keyframes fall-160 {
  58.162% {
    transform: translate(34.2529vw, 58.162vh) scale(0.0107);
  }
  to {
    transform: translate(31.27565vw, 100vh) scale(0.0107);
  }
}
.snow:nth-child(161) {
  opacity: 0.7386;
  transform: translate(92.9415vw, -10px) scale(0.2917);
  animation: fall-161 19s -12s linear infinite;
}
@keyframes fall-161 {
  56.449% {
    transform: translate(94.8063vw, 56.449vh) scale(0.2917);
  }
  to {
    transform: translate(93.8739vw, 100vh) scale(0.2917);
  }
}
.snow:nth-child(162) {
  opacity: 0.9178;
  transform: translate(48.9694vw, -10px) scale(0.1207);
  animation: fall-162 13s -25s linear infinite;
}
@keyframes fall-162 {
  38.58% {
    transform: translate(53.6883vw, 38.58vh) scale(0.1207);
  }
  to {
    transform: translate(51.32885vw, 100vh) scale(0.1207);
  }
}
.snow:nth-child(163) {
  opacity: 0.5063;
  transform: translate(28.0139vw, -10px) scale(0.0036);
  animation: fall-163 13s -20s linear infinite;
}
@keyframes fall-163 {
  39.783% {
    transform: translate(22.3761vw, 39.783vh) scale(0.0036);
  }
  to {
    transform: translate(25.195vw, 100vh) scale(0.0036);
  }
}
.snow:nth-child(164) {
  opacity: 0.3266;
  transform: translate(70.861vw, -10px) scale(0.6415);
  animation: fall-164 30s -13s linear infinite;
}
@keyframes fall-164 {
  50.978% {
    transform: translate(64.6717vw, 50.978vh) scale(0.6415);
  }
  to {
    transform: translate(67.76635vw, 100vh) scale(0.6415);
  }
}
.snow:nth-child(165) {
  opacity: 0.1338;
  transform: translate(59.0929vw, -10px) scale(0.457);
  animation: fall-165 18s -11s linear infinite;
}
@keyframes fall-165 {
  39.307% {
    transform: translate(66.9329vw, 39.307vh) scale(0.457);
  }
  to {
    transform: translate(63.0129vw, 100vh) scale(0.457);
  }
}
.snow:nth-child(166) {
  opacity: 0.6805;
  transform: translate(99.9282vw, -10px) scale(0.3818);
  animation: fall-166 10s -2s linear infinite;
}
@keyframes fall-166 {
  31.38% {
    transform: translate(100.0994vw, 31.38vh) scale(0.3818);
  }
  to {
    transform: translate(100.0138vw, 100vh) scale(0.3818);
  }
}
.snow:nth-child(167) {
  opacity: 0.491;
  transform: translate(42.7335vw, -10px) scale(0.3187);
  animation: fall-167 16s -10s linear infinite;
}
@keyframes fall-167 {
  69.592% {
    transform: translate(39.5844vw, 69.592vh) scale(0.3187);
  }
  to {
    transform: translate(41.15895vw, 100vh) scale(0.3187);
  }
}
.snow:nth-child(168) {
  opacity: 0.02;
  transform: translate(12.3555vw, -10px) scale(0.308);
  animation: fall-168 19s -25s linear infinite;
}
@keyframes fall-168 {
  37.681% {
    transform: translate(4.1195vw, 37.681vh) scale(0.308);
  }
  to {
    transform: translate(8.2375vw, 100vh) scale(0.308);
  }
}
.snow:nth-child(169) {
  opacity: 0.5136;
  transform: translate(10.6619vw, -10px) scale(0.3683);
  animation: fall-169 21s -15s linear infinite;
}
@keyframes fall-169 {
  56.754% {
    transform: translate(8.5025vw, 56.754vh) scale(0.3683);
  }
  to {
    transform: translate(9.5822vw, 100vh) scale(0.3683);
  }
}
.snow:nth-child(170) {
  opacity: 0.279;
  transform: translate(5.1339vw, -10px) scale(0.4139);
  animation: fall-170 12s -24s linear infinite;
}
@keyframes fall-170 {
  48.268% {
    transform: translate(5.5486vw, 48.268vh) scale(0.4139);
  }
  to {
    transform: translate(5.34125vw, 100vh) scale(0.4139);
  }
}
.snow:nth-child(171) {
  opacity: 0.4455;
  transform: translate(72.3448vw, -10px) scale(0.5109);
  animation: fall-171 14s -7s linear infinite;
}
@keyframes fall-171 {
  40.325% {
    transform: translate(67.3048vw, 40.325vh) scale(0.5109);
  }
  to {
    transform: translate(69.8248vw, 100vh) scale(0.5109);
  }
}
.snow:nth-child(172) {
  opacity: 0.5805;
  transform: translate(26.3957vw, -10px) scale(0.0289);
  animation: fall-172 24s -17s linear infinite;
}
@keyframes fall-172 {
  64.347% {
    transform: translate(28.5975vw, 64.347vh) scale(0.0289);
  }
  to {
    transform: translate(27.4966vw, 100vh) scale(0.0289);
  }
}
.snow:nth-child(173) {
  opacity: 0.0573;
  transform: translate(25.5983vw, -10px) scale(0.7341);
  animation: fall-173 13s -5s linear infinite;
}
@keyframes fall-173 {
  50.116% {
    transform: translate(21.5403vw, 50.116vh) scale(0.7341);
  }
  to {
    transform: translate(23.5693vw, 100vh) scale(0.7341);
  }
}
.snow:nth-child(174) {
  opacity: 0.0813;
  transform: translate(58.2599vw, -10px) scale(0.7208);
  animation: fall-174 21s -29s linear infinite;
}
@keyframes fall-174 {
  79.37% {
    transform: translate(60.8312vw, 79.37vh) scale(0.7208);
  }
  to {
    transform: translate(59.54555vw, 100vh) scale(0.7208);
  }
}
.snow:nth-child(175) {
  opacity: 0.4489;
  transform: translate(50.4955vw, -10px) scale(0.4301);
  animation: fall-175 17s -2s linear infinite;
}
@keyframes fall-175 {
  73.874% {
    transform: translate(56.2469vw, 73.874vh) scale(0.4301);
  }
  to {
    transform: translate(53.3712vw, 100vh) scale(0.4301);
  }
}
.snow:nth-child(176) {
  opacity: 0.8586;
  transform: translate(35.9686vw, -10px) scale(0.4642);
  animation: fall-176 10s -5s linear infinite;
}
@keyframes fall-176 {
  40.522% {
    transform: translate(27.7346vw, 40.522vh) scale(0.4642);
  }
  to {
    transform: translate(31.8516vw, 100vh) scale(0.4642);
  }
}
.snow:nth-child(177) {
  opacity: 0.7733;
  transform: translate(87.1894vw, -10px) scale(0.8977);
  animation: fall-177 27s -26s linear infinite;
}
@keyframes fall-177 {
  66.783% {
    transform: translate(79.6909vw, 66.783vh) scale(0.8977);
  }
  to {
    transform: translate(83.44015vw, 100vh) scale(0.8977);
  }
}
.snow:nth-child(178) {
  opacity: 0.2075;
  transform: translate(29.794vw, -10px) scale(0.1986);
  animation: fall-178 26s -28s linear infinite;
}
@keyframes fall-178 {
  39.09% {
    transform: translate(30.7362vw, 39.09vh) scale(0.1986);
  }
  to {
    transform: translate(30.2651vw, 100vh) scale(0.1986);
  }
}
.snow:nth-child(179) {
  opacity: 0.4705;
  transform: translate(47.8769vw, -10px) scale(0.8885);
  animation: fall-179 17s -25s linear infinite;
}
@keyframes fall-179 {
  31.176% {
    transform: translate(40.3125vw, 31.176vh) scale(0.8885);
  }
  to {
    transform: translate(44.0947vw, 100vh) scale(0.8885);
  }
}
.snow:nth-child(180) {
  opacity: 0.9698;
  transform: translate(94.8122vw, -10px) scale(0.9575);
  animation: fall-180 21s -25s linear infinite;
}
@keyframes fall-180 {
  36.835% {
    transform: translate(88.5697vw, 36.835vh) scale(0.9575);
  }
  to {
    transform: translate(91.69095vw, 100vh) scale(0.9575);
  }
}
.snow:nth-child(181) {
  opacity: 0.0245;
  transform: translate(74.321vw, -10px) scale(0.1686);
  animation: fall-181 25s -21s linear infinite;
}
@keyframes fall-181 {
  37.172% {
    transform: translate(72.3466vw, 37.172vh) scale(0.1686);
  }
  to {
    transform: translate(73.3338vw, 100vh) scale(0.1686);
  }
}
.snow:nth-child(182) {
  opacity: 0.907;
  transform: translate(28.2385vw, -10px) scale(0.2887);
  animation: fall-182 25s -7s linear infinite;
}
@keyframes fall-182 {
  78.306% {
    transform: translate(32.6814vw, 78.306vh) scale(0.2887);
  }
  to {
    transform: translate(30.45995vw, 100vh) scale(0.2887);
  }
}
.snow:nth-child(183) {
  opacity: 0.6162;
  transform: translate(24.7507vw, -10px) scale(0.5302);
  animation: fall-183 11s -20s linear infinite;
}
@keyframes fall-183 {
  45.071% {
    transform: translate(32.1221vw, 45.071vh) scale(0.5302);
  }
  to {
    transform: translate(28.4364vw, 100vh) scale(0.5302);
  }
}
.snow:nth-child(184) {
  opacity: 0.6763;
  transform: translate(86.2551vw, -10px) scale(0.8253);
  animation: fall-184 20s -26s linear infinite;
}
@keyframes fall-184 {
  61.531% {
    transform: translate(76.5172vw, 61.531vh) scale(0.8253);
  }
  to {
    transform: translate(81.38615vw, 100vh) scale(0.8253);
  }
}
.snow:nth-child(185) {
  opacity: 0.0726;
  transform: translate(49.343vw, -10px) scale(0.5117);
  animation: fall-185 30s -29s linear infinite;
}
@keyframes fall-185 {
  41.839% {
    transform: translate(55.295vw, 41.839vh) scale(0.5117);
  }
  to {
    transform: translate(52.319vw, 100vh) scale(0.5117);
  }
}
.snow:nth-child(186) {
  opacity: 0.2272;
  transform: translate(82.4333vw, -10px) scale(0.4776);
  animation: fall-186 14s -10s linear infinite;
}
@keyframes fall-186 {
  43.058% {
    transform: translate(77.7393vw, 43.058vh) scale(0.4776);
  }
  to {
    transform: translate(80.0863vw, 100vh) scale(0.4776);
  }
}
.snow:nth-child(187) {
  opacity: 0.6189;
  transform: translate(5.9571vw, -10px) scale(0.0538);
  animation: fall-187 23s -17s linear infinite;
}
@keyframes fall-187 {
  52.819% {
    transform: translate(5.8494vw, 52.819vh) scale(0.0538);
  }
  to {
    transform: translate(5.90325vw, 100vh) scale(0.0538);
  }
}
.snow:nth-child(188) {
  opacity: 0.2433;
  transform: translate(83.0242vw, -10px) scale(0.8082);
  animation: fall-188 11s -13s linear infinite;
}
@keyframes fall-188 {
  79.432% {
    transform: translate(77.0357vw, 79.432vh) scale(0.8082);
  }
  to {
    transform: translate(80.02995vw, 100vh) scale(0.8082);
  }
}
.snow:nth-child(189) {
  opacity: 0.6428;
  transform: translate(22.3476vw, -10px) scale(0.3487);
  animation: fall-189 16s -1s linear infinite;
}
@keyframes fall-189 {
  77.486% {
    transform: translate(23.3344vw, 77.486vh) scale(0.3487);
  }
  to {
    transform: translate(22.841vw, 100vh) scale(0.3487);
  }
}
.snow:nth-child(190) {
  opacity: 0.98;
  transform: translate(73.601vw, -10px) scale(0.4815);
  animation: fall-190 27s -11s linear infinite;
}
@keyframes fall-190 {
  76.583% {
    transform: translate(76.6617vw, 76.583vh) scale(0.4815);
  }
  to {
    transform: translate(75.13135vw, 100vh) scale(0.4815);
  }
}
.snow:nth-child(191) {
  opacity: 0.6998;
  transform: translate(32.1245vw, -10px) scale(0.9431);
  animation: fall-191 11s -22s linear infinite;
}
@keyframes fall-191 {
  51.858% {
    transform: translate(23.3973vw, 51.858vh) scale(0.9431);
  }
  to {
    transform: translate(27.7609vw, 100vh) scale(0.9431);
  }
}
.snow:nth-child(192) {
  opacity: 0.1725;
  transform: translate(59.8201vw, -10px) scale(0.7429);
  animation: fall-192 14s -4s linear infinite;
}
@keyframes fall-192 {
  33.603% {
    transform: translate(59.0064vw, 33.603vh) scale(0.7429);
  }
  to {
    transform: translate(59.41325vw, 100vh) scale(0.7429);
  }
}
.snow:nth-child(193) {
  opacity: 0.9639;
  transform: translate(95.5813vw, -10px) scale(0.9539);
  animation: fall-193 18s -19s linear infinite;
}
@keyframes fall-193 {
  39.712% {
    transform: translate(95.5039vw, 39.712vh) scale(0.9539);
  }
  to {
    transform: translate(95.5426vw, 100vh) scale(0.9539);
  }
}
.snow:nth-child(194) {
  opacity: 0.7254;
  transform: translate(94.1152vw, -10px) scale(0.6177);
  animation: fall-194 17s -9s linear infinite;
}
@keyframes fall-194 {
  63.514% {
    transform: translate(94.0846vw, 63.514vh) scale(0.6177);
  }
  to {
    transform: translate(94.0999vw, 100vh) scale(0.6177);
  }
}
.snow:nth-child(195) {
  opacity: 0.6646;
  transform: translate(90.7053vw, -10px) scale(0.5837);
  animation: fall-195 28s -28s linear infinite;
}
@keyframes fall-195 {
  42.823% {
    transform: translate(85.2157vw, 42.823vh) scale(0.5837);
  }
  to {
    transform: translate(87.9605vw, 100vh) scale(0.5837);
  }
}
.snow:nth-child(196) {
  opacity: 0.8927;
  transform: translate(43.4361vw, -10px) scale(0.3556);
  animation: fall-196 23s -18s linear infinite;
}
@keyframes fall-196 {
  35.511% {
    transform: translate(43.213vw, 35.511vh) scale(0.3556);
  }
  to {
    transform: translate(43.32455vw, 100vh) scale(0.3556);
  }
}
.snow:nth-child(197) {
  opacity: 0.2296;
  transform: translate(57.9599vw, -10px) scale(0.1946);
  animation: fall-197 17s -3s linear infinite;
}
@keyframes fall-197 {
  42.569% {
    transform: translate(60.2494vw, 42.569vh) scale(0.1946);
  }
  to {
    transform: translate(59.10465vw, 100vh) scale(0.1946);
  }
}
.snow:nth-child(198) {
  opacity: 0.235;
  transform: translate(58.5547vw, -10px) scale(0.4313);
  animation: fall-198 18s -9s linear infinite;
}
@keyframes fall-198 {
  56.986% {
    transform: translate(55.1781vw, 56.986vh) scale(0.4313);
  }
  to {
    transform: translate(56.8664vw, 100vh) scale(0.4313);
  }
}
.snow:nth-child(199) {
  opacity: 0.4135;
  transform: translate(51.3332vw, -10px) scale(0.9363);
  animation: fall-199 12s -4s linear infinite;
}
@keyframes fall-199 {
  75.677% {
    transform: translate(49.254vw, 75.677vh) scale(0.9363);
  }
  to {
    transform: translate(50.2936vw, 100vh) scale(0.9363);
  }
}
.snow:nth-child(200) {
  opacity: 0.4737;
  transform: translate(6.6595vw, -10px) scale(0.7336);
  animation: fall-200 18s -1s linear infinite;
}
@keyframes fall-200 {
  64.819% {
    transform: translate(-0.8796vw, 64.819vh) scale(0.7336);
  }
  to {
    transform: translate(2.88995vw, 100vh) scale(0.7336);
  }
}




<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
<div class="snow"></div>
View Code

 

伪类和伪元素

4、伪类

HTML元素的状态是可以动态变化的。举个栗子,当你的鼠标悬浮到一个按钮上时,按钮就会变成“悬浮”状态,这时我们就可以利用伪类:hover来选中这一状态的按钮,并对其样式进行改变。:hover是笔者最最常用的一个伪类。还有一个很常用的伪类是:nth-child,用于选中元素的某一个子元素。其他的类似:focus:focus-within等也有一定的使用。

body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: #222;
}

.btn {
  --hue: 190;
  --ease-in-duration: 0.25s;
  --ease-out-duration: 0.65s;
  --ease-out-delay: var(--ease-in-duration);
  position: relative;
  padding: 1rem 3rem;
  font-size: 1rem;
  line-height: 1.5;
  color: white;
  text-decoration: none;
  background-color: hsl(var(--hue), 100%, 41%);
  border: 1px solid hsl(var(--hue), 100%, 41%);
  outline: transparent;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: 0.25s;

  &:hover {
    background: hsl(var(--hue), 100%, 31%);
  }

  &-primary {
    --hue: 171;
  }

  &-ghost {
    color: hsl(var(--hue), 100%, 41%);
    background-color: transparent;
    border-color: hsl(var(--hue), 100%, 41%);
    
    &:hover {
      color: white;
    }
  }

  &-border-stroke {
    border-color: hsla(var(--hue), 100%, 41%, 0.35);

    .btn-borders {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;

      .border-top {
        position: absolute;
        top: 0;
        width: 100%;
        height: 1px;
        background: hsl(var(--hue), 100%, 41%);
        transform: scaleX(0);
        transform-origin: left;
      }

      .border-right {
        position: absolute;
        right: 0;
        width: 1px;
        height: 100%;
        background: hsl(var(--hue), 100%, 41%);
        transform: scaleY(0);
        transform-origin: bottom;
      }

      .border-bottom {
        position: absolute;
        bottom: 0;
        width: 100%;
        height: 1px;
        background: hsl(var(--hue), 100%, 41%);
        transform: scaleX(0);
        transform-origin: left;
      }

      .border-left {
        position: absolute;
        left: 0;
        width: 1px;
        height: 100%;
        background: hsl(var(--hue), 100%, 41%);
        transform: scaleY(0);
        transform-origin: bottom;
      }

      // when unhover, ease-in top, right; ease-out bottom, left

      .border-left {
        transition: var(--ease-out-duration) var(--ease-out-delay)
          cubic-bezier(0.2, 1, 0.2, 1);
      }
      .border-bottom {
        transition: var(--ease-out-duration) var(--ease-out-delay)
          cubic-bezier(0.2, 1, 0.2, 1);
      }

      .border-right {
        transition: var(--ease-in-duration) cubic-bezier(1, 0, 0.8, 0);
      }
      .border-top {
        transition: var(--ease-in-duration) cubic-bezier(1, 0, 0.8, 0);
      }
    }

    &:hover {
      color: hsl(var(--hue), 100%, 41%);
      background: transparent;

      .border-top,
      .border-bottom {
        transform: scaleX(1);
      }
      .border-left,
      .border-right {
        transform: scaleY(1);
      }

      // when hover, ease-in bottom, left; ease-out top, right

      .border-left {
        transition: var(--ease-in-duration) cubic-bezier(1, 0, 0.8, 0);
      }
      .border-bottom {
        transition: var(--ease-in-duration) cubic-bezier(1, 0, 0.8, 0);
      }

      .border-right {
        transition: var(--ease-out-duration) var(--ease-out-delay)
          cubic-bezier(0.2, 1, 0.2, 1);
      }
      .border-top {
        transition: var(--ease-out-duration) var(--ease-out-delay)
          cubic-bezier(0.2, 1, 0.2, 1);
      }
    }
  }

  &-text-float-up {
    &::after {
      position: absolute;
      content: attr(data-text);
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      opacity: 0;
      transform: translateY(35%);
      transition: 0.25s ease-out;
    }

    // when hover, ease-in top-text; ease-out bottom-text

    .btn-text {
      display: block;
      transition: 0.75s 0.1s cubic-bezier(0.2, 1, 0.2, 1);
    }

    &:hover {
      // when hover, ease-in bottom-text; ease-out top-text

      .btn-text {
        opacity: 0;
        transform: translateY(-25%);
        transition: 0.25s ease-out;
      }

      &::after {
        opacity: 1;
        transform: translateY(0);
        transition: 0.75s 0.1s cubic-bezier(0.2, 1, 0.2, 1);
      }
    }
  }
}


<button
  data-text="Start"
  class="btn btn-primary btn-ghost btn-border-stroke  btn-text-float-up"
>
  <div class="btn-borders">
    <div class="border-top"></div>
    <div class="border-right"></div>
    <div class="border-bottom"></div>
    <div class="border-left"></div>
  </div>
  <span class="btn-text">Start</span>
</button>
View Code

 

本demo地址:https://codepen.io/alphardex/pen/pooYKVa

5、绝对定位实现多重边框

谁规定按钮只能有一套边框的?利用绝对定位和padding,我们可以给按钮做出3套大小不一的边框来,这样效果更炫了。

@import url(https://fonts.googleapis.com/css?family=Lato);
body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: #222;
}

.btn {
  --hue: 190;
  --ease-in-duration: 0.25s;
  --ease-out-duration: 0.65s;
  --ease-out-delay: var(--ease-in-duration);
  position: relative;
  padding: 1rem 3rem;
  font-size: 1rem;
  line-height: 1.5;
  color: white;
  text-decoration: none;
  background-color: hsl(var(--hue), 100%, 41%);
  border: 1px solid hsl(var(--hue), 100%, 41%);
  outline: transparent;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: 0.25s;
}
.btn:hover {
  background: hsl(var(--hue), 100%, 31%);
}
.btn-primary {
  --hue: 171;
}
.btn-ghost {
  color: hsl(var(--hue), 100%, 41%);
  background-color: transparent;
  border-color: hsl(var(--hue), 100%, 41%);
}
.btn-ghost:hover {
  color: white;
}
.btn-multiple-border-stroke {
  border-color: transparent;
}
.btn-multiple-border-stroke .btn-borders-group {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  border: 1px solid hsla(var(--hue), 100%, 41%, 0.35);
}
.btn-multiple-border-stroke .btn-borders-group:nth-child(1) {
  left: -8px;
  padding: 0 8px;
}
.btn-multiple-border-stroke .btn-borders-group:nth-child(2) {
  top: -8px;
  padding: 8px 0;
}
.btn-multiple-border-stroke .btn-borders-group:nth-child(3) {
  top: -4px;
  left: -4px;
  padding: 4px;
}
.btn-multiple-border-stroke .btn-borders-group .border-top {
  position: absolute;
  top: 0;
  width: 100%;
  height: 1px;
  background: hsl(var(--hue), 100%, 41%);
  transform: scaleX(0);
  transform-origin: left;
}
.btn-multiple-border-stroke .btn-borders-group .border-right {
  position: absolute;
  right: 0;
  width: 1px;
  height: 100%;
  background: hsl(var(--hue), 100%, 41%);
  transform: scaleY(0);
  transform-origin: bottom;
}
.btn-multiple-border-stroke .btn-borders-group .border-bottom {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: hsl(var(--hue), 100%, 41%);
  transform: scaleX(0);
  transform-origin: left;
}
.btn-multiple-border-stroke .btn-borders-group .border-left {
  position: absolute;
  left: 0;
  width: 1px;
  height: 100%;
  background: hsl(var(--hue), 100%, 41%);
  transform: scaleY(0);
  transform-origin: bottom;
}
.btn-multiple-border-stroke .btn-borders-group .border-left {
  transition: var(--ease-out-duration) var(--ease-out-delay) cubic-bezier(0.2, 1, 0.2, 1);
}
.btn-multiple-border-stroke .btn-borders-group .border-bottom {
  transition: var(--ease-out-duration) var(--ease-out-delay) cubic-bezier(0.2, 1, 0.2, 1);
}
.btn-multiple-border-stroke .btn-borders-group .border-right {
  transition: var(--ease-in-duration) cubic-bezier(1, 0, 0.8, 0);
}
.btn-multiple-border-stroke .btn-borders-group .border-top {
  transition: var(--ease-in-duration) cubic-bezier(1, 0, 0.8, 0);
}
.btn-multiple-border-stroke:hover {
  color: hsl(var(--hue), 100%, 41%);
  background: transparent;
}
.btn-multiple-border-stroke:hover .border-top,
.btn-multiple-border-stroke:hover .border-bottom {
  transform: scaleX(1);
}
.btn-multiple-border-stroke:hover .border-left,
.btn-multiple-border-stroke:hover .border-right {
  transform: scaleY(1);
}
.btn-multiple-border-stroke:hover .border-left {
  transition: var(--ease-in-duration) cubic-bezier(1, 0, 0.8, 0);
}
.btn-multiple-border-stroke:hover .border-bottom {
  transition: var(--ease-in-duration) cubic-bezier(1, 0, 0.8, 0);
}
.btn-multiple-border-stroke:hover .border-right {
  transition: var(--ease-out-duration) var(--ease-out-delay) cubic-bezier(0.2, 1, 0.2, 1);
}
.btn-multiple-border-stroke:hover .border-top {
  transition: var(--ease-out-duration) var(--ease-out-delay) cubic-bezier(0.2, 1, 0.2, 1);
}


<button class="btn btn-primary btn-ghost btn-multiple-border-stroke">
  <div class="btn-borders-group">
    <div class="border-top"></div>
    <div class="border-right"></div>
    <div class="border-bottom"></div>
    <div class="border-left"></div>
  </div>
  <div class="btn-borders-group">
    <div class="border-top"></div>
    <div class="border-right"></div>
    <div class="border-bottom"></div>
    <div class="border-left"></div>
  </div>
  <div class="btn-borders-group">
    <div class="border-top"></div>
    <div class="border-right"></div>
    <div class="border-bottom"></div>
    <div class="border-left"></div>
  </div>
  <span class="btn-text">Start</span>
</button>
View Code

本demo地址:https://codepen.io/alphardex/full/ZEYXomW

6、伪元素

 

<header>
  <h1 class="title">I'm alphardex.</h1>
  <p class="subtitle">A CSS Wizard</p>
</header>


// palette: https://www.materialpalette.com/light-blue/pink

@import url("https://fonts.googleapis.com/css?family=Lato");
@import url("https://fonts.googleapis.com/css?family=Lora:400,400i,700");

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #222;
}

header {
  .title,
  .subtitle {
    position: relative;
    width: 250px;
    height: 30px;
    color: transparent;
    animation: fadeIn 2s 1.6s forwards;

    &::before {
      position: absolute;
      content: "";
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      transform: scaleX(0);
      transform-origin: left;
      animation: slideRight 2s cubic-bezier(0.75, 0, 0, 1) forwards;
    }
  }

  .title {
    margin: 0;
    font-family: Lora, serif;
    font-size: 32px;
    line-height: 30px;

    &::before {
      background: #FF4081;
    }
  }

  .subtitle {
    margin: 10px 0 0 0;
    font-family: Lato, sans-serif;
    font-size: 12px;
    line-height: 30px;
    letter-spacing: 5px;
    text-transform: uppercase;
    animation-delay: 3.2s;

    &::before {
      background: #03A9F4;
      animation-delay: 2s;
    }
  }
}

@keyframes fadeIn {
  to {
    color: white;
  }
}

@keyframes slideRight {
  50% {
    transform: scaleX(1);
    transform-origin: left;
  }

  50.1% {
    transform-origin: right;
  }

  to {
    transform-origin: right;
  }
}
View Code

 

简而言之,伪元素就是在原先的元素基础上插入额外的元素,而且这个元素不充当HTML的标签,这样就能保持HTML结构的整洁。我们知道每个元素都有::before::after这两个伪元素,也就是说每个元素都提供了3个矩形(元素本身1个,伪元素2个)来供我们进行形状的绘制。现在又有了clip-path这个属性,几乎任意的形状都可以被绘制出来,全凭你的想象力上面的动图是条子划过文本的动画,条子就是每个文本所对应的伪元素,对每个文本和其伪元素应用动画,就能达到上图的效果了

 

本demo地址:https://codepen.io/alphardex/pen/jOEOEzZ

7、attr()生成文本内容

元素可以有自定义的属性值,它的命名格式通常为data-*attr()用于获取元素的这种自定义属性值,并赋值给其伪元素的content作为其生成的内容利用这个函数,我们可以用伪元素在原先文本的基础上“复制”出另一个文本,如下图所示看上去有点乱糟糟的对吧?没事,给它加上overflow: hidden,把多余的文本遮住。通过JS分割文本并应用交错动画,就得到了如下的效果,这也是接下来本文要讲的overflow障眼法。

本demo地址:https://codepen.io/alphardex/full/wvBeXjd

@import url(https://fonts.googleapis.com/css?family=Lato);
body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: black;
}

.float-text-menu {
  display: flex;
  flex-direction: column;
  list-style-type: none;
}
.float-text-menu li a {
  display: flex;
  padding: 6px;
  color: white;
  font-family: Lato, sans-serif;
  text-decoration: none;
  overflow: hidden;
}
.float-text-menu li a span {
  position: relative;
  transition: 0.3s;
}
.float-text-menu li a span::before {
  position: absolute;
  content: attr(data-text);
  transform: translateY(130%);
}
.float-text-menu li a:hover span {
  transform: translateY(-130%);
}



<ul class="float-text-menu">
  <li><a href="#" data-text="Home">Home</a></li>
  <li><a href="#" data-text="Archives">Archives</a></li>
  <li><a href="#" data-text="Tags">Tags</a></li>
  <li><a href="#" data-text="Categories">Categories</a></li>
  <li><a href="#" data-text="About">About</a></li>
</ul>


var floatTextMenuLinks = document.querySelectorAll(".float-text-menu li a");
floatTextMenuLinks.forEach(function (link) {
    var letters = link.textContent.split("");
    link.textContent = "";
    letters.forEach(function (letter, i) {
        var span = document.createElement("span");
        span.textContent = letter;
        span.style.transitionDelay = i / 20 + "s";
        span.dataset.text = letter;
        link.append(span);
    });
});
View Code

 

8、overflow障眼法

之前有做过闪光按钮的效果:鼠标悬浮按钮上时一道光从左到右划过去。笔者就用渐变来模拟那道光,通过transform: translateX()将其平移至右边。但这样明显不对啊,这光为啥能被看见呢?不应该把它给“挡”起来吗?于是乎,给按钮加上overflow: hidden,光在按钮外的位置时就被隐藏起来了。这就是障眼法的力量:

 

 

本demo地址:

https://codepen.io/alphardex/pen/eYYzXBZ更多障眼法可以看看这个作品,一次性看个够XD

@import url(https://fonts.googleapis.com/css?family=Lato);

body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  background: #222;
}

.btn {
  --hue: 190;
  position: relative;
  padding: 1rem 3rem;
  font-size: 1rem;
  line-height: 1.5;
  color: white;
  text-decoration: none;
  text-transform: uppercase;
  background-color: hsl(var(--hue), 100%, 41%);
  border: 1px solid hsl(var(--hue), 100%, 41%);
  outline: transparent;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: 0.25s;

  &:hover {
    background: hsl(var(--hue), 100%, 31%);
  }

  &-primary {
    --hue: 187;
  }

  &-ghost {
    color: hsl(var(--hue), 100%, 41%);
    background-color: transparent;
    border-color: hsl(var(--hue), 100%, 41%);

    &:hover {
      color: white;
    }
  }

  &-shine {
    color: white;

    &::before {
      position: absolute;
      content: "";
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(
        120deg,
        transparent,
        hsla(var(--hue), 100%, 41%, 0.5),
        transparent
      );
      transform: translateX(-100%);
      transition: 0.6s;
    }

    &:hover {
      background: transparent;
      box-shadow: 0 0 20px 10px hsla(var(--hue), 100%, 41%, 0.5);
    }

    &:hover::before {
      transform: translateX(100%);
    }
  }
}

<button class="btn btn-primary btn-ghost btn-shine">
  hover me
</button>
View Code

 

9、兄弟选择符定制表单元素

提示:这里最好将input作为label的子元素,这样用户点击label时就能传到input上默认的input太丑怎么办?那就把它先抹掉,用appearance: noneopacity: 0都可以然后,利用兄弟选择符~来定制和input相邻的所有元素(+号也行,只不过只能选中最近的元素),例如可以用伪元素生成一个新的方框代替原先的input,利用伪类:checked和动画来表示它被勾选后的状态,本质上还是障眼法哦~

@import url("https://fonts.googleapis.com/css?family=Lato:400,400i,700");
body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #0b1420;
}

.todo-list {
  display: flex;
  flex-direction: column;
  padding: 0 75px 10px 30px;
  background: #162740;
  border: transparent;
}
.todo-list .todo-list__title {
  padding: 3px 6px;
  color: #f1faee;
  background-color: #264456;
}
.todo-list .todo-list__label {
  display: flex;
  align-items: center;
  margin: 40px 0;
  font-size: 24px;
  font-family: Lato, sans-serif;
  color: #f1faee;
  cursor: pointer;
}
.todo-list .todo-list__label input[type="checkbox"] {
  opacity: 0;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
}
.todo-list .todo-list__label input[type="checkbox"] + .check {
  position: absolute;
  width: 25px;
  height: 25px;
  border: 2px solid #f1faee;
  transition: 0.2s;
}
.todo-list .todo-list__label input[type="checkbox"]:checked + .check {
  width: 25px;
  height: 15px;
  border-top: transparent;
  border-right: transparent;
  -webkit-transform: rotate(-45deg);
          transform: rotate(-45deg);
}
.todo-list .todo-list__label input[type="checkbox"] ~ span {
  position: relative;
  left: 40px;
  white-space: nowrap;
  transition: 0.5s;
}
.todo-list .todo-list__label input[type="checkbox"] ~ span::before {
  position: absolute;
  content: "";
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  background: #f1faee;
  -webkit-transform: scaleX(0);
          transform: scaleX(0);
  -webkit-transform-origin: right;
          transform-origin: right;
  transition: -webkit-transform 0.5s;
  transition: transform 0.5s;
  transition: transform 0.5s, -webkit-transform 0.5s;
}
.todo-list .todo-list__label input[type="checkbox"]:checked ~ span {
  color: #585b57;
}
.todo-list .todo-list__label input[type="checkbox"]:checked ~ span::before {
  -webkit-transform: scaleX(1);
          transform: scaleX(1);
  -webkit-transform-origin: left;
          transform-origin: left;
}

<form>
  <fieldset class="todo-list">
    <legend class="todo-list__title">My Special Todo List</legend>
    <label class="todo-list__label">
      <input type="checkbox" name="" id="" />
      <i class="check"></i>
      <span>Make awesome CSS animation</span>
    </label>
    <label class="todo-list__label">
      <input type="checkbox" name="" id="" />
      <i class="check"></i>
      <span>Watch awesome bangumi</span>
    </label>
    <label class="todo-list__label">
      <input type="checkbox" name="" id="" />
      <i class="check"></i>
      <span>Encounter awesome people</span>
    </label>
    <label class="todo-list__label">
      <input type="checkbox" name="" id="" />
      <i class="check"></i>
      <span>Be an awesome man</span>
    </label>
  </fieldset>
</form>
View Code

 

本demo地址:https://codepen.io/alphardex/full/rNNPQwa

CSS特性

善用某些CSS特性,也可以为你的作品增色不少哦

10、animation

此处包括transitiontransformCSS动画可以说是利用CSS设计炫酷特效的最强法器,它几乎贯穿了我的所有作品有人问我为什么我能想出这么多的动画?笔者阅番百部,对常用的动画技巧了如指掌,同样那些酷炫的网站只要细心观察,也会给笔者带来很多设计上的灵感。一言以蔽之:只有多欣赏动画,才能写出好的动画。

11、border-radius

为盒子添加圆角,经常用来美化按钮等组件如果设定为50%则是圆形,也很常用

不规则的曲边形状

var navtab = document.querySelector("nav.navtab");
var navtabItems = document.querySelectorAll("li.navtab-item");
navtabItems.forEach(function (navtabItem, activeIndex) {
    return navtabItem.addEventListener("click", function () {
        navtabItems.forEach(function (navtabItem) { return navtabItem.classList.remove("active"); });
        navtabItem.classList.add("active");
        navtab.style.setProperty("--active-index", "" + activeIndex);
    });
});


@import url(https://fonts.googleapis.com/css?family=Lato);
body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  font-family: Lato, sans-serif;
  background: #03a9f4;
}

.navtab {
  --navtab-width: 600px;
  --navtab-item-width: calc(var(--navtab-width) / 4 - 20px);
  --navtab-overlay-width: calc(var(--navtab-item-width) + 80px);
  --active-index: 0;
  position: relative;
  width: var(--navtab-width);
  height: 150px;
  background: white;
  border: 1em solid white;
  border-radius: 5% 5% 15% 15% / 15% 15% 50% 50%;
  overflow: hidden;
}
.navtab ul {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  list-style-type: none;
}
.navtab ul li.navtab-item {
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
  flex-direction: column;
  width: var(--navtab-item-width);
  height: 100%;
  color: #0288d1;
  cursor: pointer;
  transition: 0.5s ease;
}
.navtab ul li.navtab-item i {
  font-size: 2em;
  transition: 0.5s ease;
}
.navtab ul li.navtab-item span {
  font-size: 20px;
  user-select: none;
  opacity: 0;
  transition: 0.5s ease;
}
.navtab ul li.navtab-item.active {
  width: var(--navtab-overlay-width);
}
.navtab ul li.navtab-item.active i {
  transform: translateY(-10px);
}
.navtab ul li.navtab-item.active span {
  opacity: 1;
}
.navtab::after {
  position: absolute;
  content: "";
  top: 0;
  left: 0;
  height: 100%;
  width: var(--navtab-overlay-width);
  background: #b3e5fc;
  border-radius: 20px;
  transform: translateX(calc(var(--navtab-item-width) * var(--active-index)));
  transition: 0.5s ease;
}

<nav class="navtab">
  <ul>
    <li class="navtab-item active">
      <i class="fas fa-home"></i>
      <span>Home</span>
    </li>
    <li class="navtab-item">
      <i class="fas fa-compass"></i>
      <span>Explore</span>
    </li>
    <li class="navtab-item">
      <i class="fas fa-bell"></i>
      <span>Notification</span>
    </li>
    <li class="navtab-item">
      <i class="fas fa-user"></i>
      <span>Profile</span>
    </li>
  </ul>
</nav>
View Code

 

调整多个顶点的border-radius可以做出不规则的曲边形状本demo地址:https://codepen.io/alphardex/full/abbWOPR

12、box-shadow

为盒子添加阴影,增加盒子的立体感,可以多层叠加,并且会使阴影更加丝滑

本demo地址:https://codepen.io/alphardex/full/QWwwwpp

13、遮罩

如果给box-shadow的扩张半径设定足够大的值,可以用它来遮住背景,而无需额外的div元素

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
}

#burger-toggle {
  appearance: none;
  opacity: 0;
}
#burger-toggle:checked ~ .overlay {
  opacity: 1;
  transform: scale(160);
}
#burger-toggle:checked ~ .burger-menu .line:nth-child(1) {
  transform: translateY(calc(var(--burger-menu-radius) / 5)) rotate(45deg);
}
#burger-toggle:checked ~ .burger-menu .line:nth-child(2) {
  transform: scaleX(0);
}
#burger-toggle:checked ~ .burger-menu .line:nth-child(3) {
  transform: translateY(calc(var(--burger-menu-radius) / -5)) rotate(-45deg);
}

.burger-menu {
  --burger-menu-radius: 10em;
  position: fixed;
  top: 40vh;
  left: 40vw;
  z-index: 100;
  display: block;
  width: var(--burger-menu-radius);
  height: var(--burger-menu-radius);
  background: white;
  border: solid 2px rgba(149, 166, 167, 0.4);
  border-radius: 50%;
  outline: none;
  cursor: pointer;
  transition: 0.5s ease-in-out;
}
.burger-menu .line {
  position: absolute;
  left: 25%;
  width: 50%;
  height: 3px;
  background: rgba(43, 61, 79, 0.3);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.5s ease;
}
.burger-menu .line:nth-child(1) {
  top: 30%;
}
.burger-menu .line:nth-child(2) {
  top: 50%;
}
.burger-menu .line:nth-child(3) {
  top: 70%;
}
.burger-menu .line::after {
  position: absolute;
  content: "";
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #2980b9;
  transform: translateX(-100%);
  transition: all 0.25s ease;
}
.burger-menu .line:nth-child(2)::after {
  transition-delay: 0.1s;
}
.burger-menu .line:nth-child(3)::after {
  transition-delay: 0.2s;
}
.burger-menu:hover {
  box-shadow: 0.4px 0.4px 0.8px rgba(0, 0, 0, 0.042), 1px 1px 2px rgba(0, 0, 0, 0.061), 1.9px 1.9px 3.8px rgba(0, 0, 0, 0.075), 3.4px 3.4px 6.7px rgba(0, 0, 0, 0.089), 6.3px 6.3px 12.5px rgba(0, 0, 0, 0.108), 15px 15px 30px rgba(0, 0, 0, 0.15);
}
.burger-menu:hover .line::after {
  transform: translateX(0);
}

.overlay {
  position: fixed;
  top: 55vh;
  left: 45vw;
  width: 2em;
  height: 2em;
  background: rgba(40, 127, 184, 0.9);
  border-radius: 50%;
  opacity: 0;
  transition: 0.5s ease-in-out;
  will-change: transform;
}

<input type="checkbox" id="burger-toggle">
<label for="burger-toggle" class="burger-menu">
  <div class="line"></div>
  <div class="line"></div>
  <div class="line"></div>
</label>
<div class="overlay"></div>
View Code

 

demo地址:https://codepen.io/alphardex/full/BaaKvVZ

14、内发光

注意到box-shadow还有个inset,用于盒子内部发光利用这个特性我们可以在盒子内部的某个范围内设定颜色,做出一个新月形

再加点动画和滤镜效果,“猩红之月”闪亮登场!

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: black;
}

.loading {
  position: relative;
  width: 8em;
  height: 8em;
  background: black;
  border-radius: 50%;
  box-shadow: inset 0.5em -0.5em crimson;
  animation: spin 2s linear infinite;
}
.loading::before, .loading::after {
  position: absolute;
  content: "";
  width: 100%;
  height: 100%;
  background: inherit;
  border-radius: inherit;
  box-shadow: inherit;
}
.loading::before {
  filter: blur(5px);
}
.loading::after {
  filter: blur(10px);
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

<div class="loading"></div>
View Code

 

本demo地址:https://codepen.io/alphardex/full/eYmGEGp

text-shadow

文本阴影,本质上和box-shadow相同,只不过是相对于文本而言,常用于文本发光,也可通过多层叠加来制作霓虹文本和伪3D文本等效果

15、发光文本

本demo地址:https://codepen.io/alphardex/full/Exxodoq

var glowInTexts = document.querySelectorAll(".glowIn");
glowInTexts.forEach(function (glowInText) {
    var letters = glowInText.textContent.split("");
    glowInText.textContent = "";
    letters.forEach(function (letter, i) {
        var span = document.createElement("span");
        span.textContent = letter;
        span.style.animationDelay = i * 0.05 + "s";
        glowInText.append(span);
    });
});

@import url("https://fonts.googleapis.com/css?family=Lora:400,400i,700");
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  justify-content: center;
  align-items: center;
  background-image: linear-gradient(rgba(16, 16, 16, 0.8), rgba(16, 16, 16, 0.8)), url(https://i.loli.net/2019/11/03/RtVq2wxQYySDb8L.jpg);
  background-size: cover;
}

p {
  margin: 0em 5em 4em 5em;
}

.glowIn {
  text-align: left;
  line-height: 1.8;
  color: white;
  font-family: Lora, serif;
}
.glowIn span {
  animation: glowIn 0.8s ease both;
}

@keyframes glowIn {
  from {
    opacity: 0;
  }
  65% {
    opacity: 1;
    text-shadow: 0 0 25px white;
  }
  75% {
    opacity: 1;
  }
  to {
    opacity: 0.7;
  }
}

<h1 class="glowIn">Hello World</h1>
<p class="glowIn">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Mattis pellentesque id nibh tortor. Suspendisse ultrices gravida dictum fusce ut placerat orci nulla. A lacus vestibulum sed arcu.</p>
View Code

16、霓虹文本

 

 

@import url(https://fonts.googleapis.com/css?family=Pacifico);
body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: black;
}

.neon {
  color: #cce7f8;
  font-size: 2.5rem;
  font-family: 'Pacifico', cursive;
  text-transform: uppercase;
  -webkit-animation: shining 0.1s alternate infinite;
          animation: shining 0.1s alternate infinite;
}

@-webkit-keyframes shining {
  from {
    text-shadow: 0 0 6px rgba(182, 211, 207, 0.9), 0 0 30px rgba(182, 211, 207, 0.3), 0 0 12px rgba(15, 115, 223, 0.5), 0 0 21px rgba(15, 115, 223, 0.9), 0 0 34px rgba(15, 115, 223, 0.8), 0 0 54px rgba(15, 115, 223, 0.9);
  }
  to {
    text-shadow: 0 0 6px #b6d3cf, 0 0 30px rgba(182, 211, 207, 0.4), 0 0 12px rgba(15, 115, 223, 0.6), 0 0 22px rgba(15, 115, 223, 0.8), 0 0 38px rgba(15, 115, 223, 0.9), 0 0 60px #0f73df;
  }
}

@keyframes shining {
  from {
    text-shadow: 0 0 6px rgba(182, 211, 207, 0.9), 0 0 30px rgba(182, 211, 207, 0.3), 0 0 12px rgba(15, 115, 223, 0.5), 0 0 21px rgba(15, 115, 223, 0.9), 0 0 34px rgba(15, 115, 223, 0.8), 0 0 54px rgba(15, 115, 223, 0.9);
  }
  to {
    text-shadow: 0 0 6px #b6d3cf, 0 0 30px rgba(182, 211, 207, 0.4), 0 0 12px rgba(15, 115, 223, 0.6), 0 0 22px rgba(15, 115, 223, 0.8), 0 0 38px rgba(15, 115, 223, 0.9), 0 0 60px #0f73df;
  }
}


<div class="neon">fushigi no monogatari</div>
View Code

 

本demo地址:https://codepen.io/alphardex/full/rNNwmZz

17、伪3D文本

@import url("https://fonts.googleapis.com/css?family=Baloo+Bhaijaan&display=swap");
body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: #2980b9;
}

.loading {
  display: flex;
  color: white;
  font-size: 5em;
  font-family: "Baloo Bhaijaan", cursive;
  text-transform: uppercase;
}
.loading span {
  text-shadow: 0 1px #bbb, 0 2px #bbb, 0 3px #bbb, 0 4px #bbb, 0 5px #bbb, 0 6px transparent, 0 7px transparent, 0 8px transparent, 0 9px transparent, 0 10px 10px rgba(0, 0, 0, 0.4);
  transform: translateY(20px);
  animation: bounce 0.3s ease infinite alternate;
}

@keyframes bounce {
  to {
    text-shadow: 0 1px #bbb, 0 2px #bbb, 0 3px #bbb, 0 4px #bbb, 0 5px #bbb, 0 6px #bbb, 0 7px #bbb, 0 8px #bbb, 0 9px #bbb, 0 50px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(-20px);
  }
}


let loading = document.querySelector(".loading");
let letters = loading.textContent.split("");
loading.textContent = "";
letters.forEach((letter, i) => {
  let span = document.createElement("span");
  span.textContent = letter;
  span.style.animationDelay = `${i / 10}s`;
  loading.append(span);
});


<div class="loading">Loading</div>
View Code

 

本demo地址:https://codepen.io/alphardex/full/QWWavvx

18、background-clip:text

能将背景裁剪成文字的前景色,常用来和color: transparent配合生成渐变文本

本demo地址:https://codepen.io/alphardex/full/QWwveZG

@import url("https://fonts.googleapis.com/css?family=Raleway:400,400i,700");
body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: #222;
}

ul {
  display: flex;
  flex-direction: column;
  align-items: start;
  list-style-type: none;
}
ul li {
  padding: 6px 0;
}
ul li a {
  --fill-color: #198CE6;
  position: relative;
  display: block;
  padding: 4px 0;
  font-family: Raleway, sans-serif;
  font-size: 3em;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  -webkit-text-stroke: 2px var(--fill-color);
  background: linear-gradient(90deg, var(--fill-color) 0%, var(--fill-color) 100%);
  background-size: 0;
  background-position: left;
  background-repeat: no-repeat;
  color: transparent;
  -webkit-background-clip: text;
          background-clip: text;
  transition: 0.5s linear;
}
ul li a:hover {
  background-size: 100%;
}

<ul>
  <li><a href="#">home</a></li>
  <li><a href="#">archives</a></li>
  <li><a href="#">tags</a></li>
  <li><a href="#">categories</a></li>
  <li><a href="#">about</a></li>
</ul>
View Code

gradient

渐变可以作为背景图片的一种,具有很强的色彩效果,甚至可以用来模拟光

19、linear-gradient

线性渐变是笔者最常用的渐变这个作品用到了HTML的dialog标签,渐变背景,动画以及overflow障眼法,细心的你看出来了吗:)

<dialog id="confirm-modal" class="modal">
  <div class="modal-content">
    <svg t="1574164208713" class="model-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5819" width="63" height="63"><path d="M512 0C230.4 0 0 230.4 0 512s230.4 512 512 512 512-230.4 512-512S793.6 0 512 0zM512 877.714286c-40.228571 0-73.142857-32.914286-73.142857-73.142857s32.914286-73.142857 73.142857-73.142857 73.142857 32.914286 73.142857 73.142857S552.228571 877.714286 512 877.714286zM585.142857 512c0 40.228571-32.914286 73.142857-73.142857 73.142857s-73.142857-32.914286-73.142857-73.142857L438.857143 219.428571c0-40.228571 32.914286-73.142857 73.142857-73.142857s73.142857 32.914286 73.142857 73.142857L585.142857 512z" p-id="5820" fill="white"></path></svg>
    <h2 class="modal-title">Are you sure?</h2>
    <p class="modal-description">
      You can't undo this action.
    </p>
    <div class="modal-options">
      <button
        class="btn btn-round btn-fill btn-fill-left option confirm"
        data-text="Yes"
        onclick="document.querySelector('#confirm-modal').close()"
      ></button>
      <button
        class="btn btn-round btn-fill btn-fill-right option cancel"
        data-text="No"
        onclick="document.querySelector('#confirm-modal').close()"
      ></button>
    </div>
  </div>
</dialog>
<form action="javascript:void(0);">
  <button
    class="btn btn-danger"
    onclick="document.querySelector('#confirm-modal').showModal()"
  >
    Delete history
  </button>
</form>

@import url(https://fonts.googleapis.com/css?family=Lato);
:root {
  --primary-color: hsl(171, 100%, 41%);
  --success-color: hsl(141, 53%, 53%);
  --danger-color: hsl(348, 86%, 61%);
}

body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  font-family: Lato, sans-serif;
}

.btn {
  position: relative;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #212121;
  text-decoration: none;
  background-color: white;
  border: transparent;
  border-radius: 3px;
  outline: transparent;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  white-space: nowrap;
  transition: 0.25s;
}
.btn-danger {
  color: white;
  background-color: var(--danger-color);
}
.btn-danger:hover {
  background-color: #ee2049;
}
.btn-round {
  border-radius: 30px;
}
.btn-fill {
  overflow: hidden;
}
.btn-fill-left::before {
  -webkit-transform: translateX(100%);
          transform: translateX(100%);
}
.btn-fill-right::before {
  -webkit-transform: translateX(-100%);
          transform: translateX(-100%);
}
.btn-fill::before {
  position: absolute;
  content: "";
  top: 0px;
  left: 0px;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: 0.4s cubic-bezier(0.75, 0, 0.25, 1);
}
.btn-fill::after {
  position: relative;
  content: attr(data-text);
  transition: 0.4s ease;
}
.btn-fill:hover::before {
  -webkit-transform: translateX(0);
          transform: translateX(0);
}
.btn-fill:hover::after {
  color: white !important;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  z-index: 999;
  color: white;
  background-image: linear-gradient(to right, #0acffe 0%, #495aff 100%);
  border: transparent;
  border-radius: 12px;
  box-shadow: 0 2.8px 2.2px rgba(0, 0, 0, 0.02), 0 6.7px 5.3px rgba(0, 0, 0, 0.028), 0 12.5px 10px rgba(0, 0, 0, 0.035), 0 22.3px 17.9px rgba(0, 0, 0, 0.042), 0 41.8px 33.4px rgba(0, 0, 0, 0.05), 0 100px 80px rgba(0, 0, 0, 0.07);
  -webkit-animation: show-modal 0.5s ease forwards;
          animation: show-modal 0.5s ease forwards;
}
.modal::-webkit-backdrop {
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(3px);
          backdrop-filter: blur(3px);
}
.modal::backdrop {
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(3px);
          backdrop-filter: blur(3px);
}
.modal .model-icon {
  margin-bottom: 1.25rem;
  opacity: 0;
  -webkit-animation: show-modal-icon 0.5s ease 0.2s forwards;
          animation: show-modal-icon 0.5s ease 0.2s forwards;
}
.modal .modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 300px;
  padding: 1em;
}
.modal .modal-content .modal-title {
  margin-top: 0;
  margin-bottom: 1.2rem;
  opacity: 0;
  -webkit-animation: show-modal-text 0.5s ease 0.35s forwards;
          animation: show-modal-text 0.5s ease 0.35s forwards;
}
.modal .modal-content .modal-description {
  margin: 0;
  opacity: 0;
  -webkit-animation: show-modal-text 1s ease 0.5s forwards;
          animation: show-modal-text 1s ease 0.5s forwards;
}
.modal .modal-content .modal-options {
  margin-top: 1rem;
  display: flex;
  justify-content: space-around;
}
.modal .modal-content .modal-options .option {
  padding: 0 2em;
  margin: 0.3em;
  font-size: 20px;
  font-weight: 700;
  line-height: 2;
}
.modal .modal-content .modal-options .confirm {
  opacity: 0;
  -webkit-animation: show-modal-option 0.5s ease 0.65s forwards;
          animation: show-modal-option 0.5s ease 0.65s forwards;
}
.modal .modal-content .modal-options .confirm::before {
  background: var(--success-color);
}
.modal .modal-content .modal-options .confirm::after {
  color: var(--success-color);
}
.modal .modal-content .modal-options .cancel {
  opacity: 0;
  -webkit-animation: show-modal-option 0.5s ease 0.8s forwards;
          animation: show-modal-option 0.5s ease 0.8s forwards;
}
.modal .modal-content .modal-options .cancel::before {
  background: var(--danger-color);
}
.modal .modal-content .modal-options .cancel::after {
  color: var(--danger-color);
}

@-webkit-keyframes show-modal {
  from {
    -webkit-transform: scale(0.8);
            transform: scale(0.8);
  }
  50% {
    -webkit-transform: scale(1.1);
            transform: scale(1.1);
    opacity: 1;
  }
  to {
    -webkit-transform: scale(1);
            transform: scale(1);
    opacity: 1;
  }
}

@keyframes show-modal {
  from {
    -webkit-transform: scale(0.8);
            transform: scale(0.8);
  }
  50% {
    -webkit-transform: scale(1.1);
            transform: scale(1.1);
    opacity: 1;
  }
  to {
    -webkit-transform: scale(1);
            transform: scale(1);
    opacity: 1;
  }
}
@-webkit-keyframes show-modal-icon {
  from {
    -webkit-transform: scale(0.4);
            transform: scale(0.4);
  }
  50% {
    -webkit-transform: scale(1.2);
            transform: scale(1.2);
    opacity: 1;
  }
  to {
    -webkit-transform: scale(1);
            transform: scale(1);
    opacity: 1;
  }
}
@keyframes show-modal-icon {
  from {
    -webkit-transform: scale(0.4);
            transform: scale(0.4);
  }
  50% {
    -webkit-transform: scale(1.2);
            transform: scale(1.2);
    opacity: 1;
  }
  to {
    -webkit-transform: scale(1);
            transform: scale(1);
    opacity: 1;
  }
}
@-webkit-keyframes show-modal-text {
  from {
    -webkit-transform: scale(0.6);
            transform: scale(0.6);
  }
  50% {
    -webkit-transform: scale(1.2);
            transform: scale(1.2);
    opacity: 1;
  }
  to {
    -webkit-transform: scale(1);
            transform: scale(1);
    opacity: 1;
  }
}
@keyframes show-modal-text {
  from {
    -webkit-transform: scale(0.6);
            transform: scale(0.6);
  }
  50% {
    -webkit-transform: scale(1.2);
            transform: scale(1.2);
    opacity: 1;
  }
  to {
    -webkit-transform: scale(1);
            transform: scale(1);
    opacity: 1;
  }
}
@-webkit-keyframes show-modal-option {
  from {
    -webkit-transform: scale(0.4);
            transform: scale(0.4);
  }
  50% {
    -webkit-transform: scale(1.2);
            transform: scale(1.2);
    opacity: 1;
  }
  to {
    -webkit-transform: scale(1);
            transform: scale(1);
    opacity: 1;
  }
}
@keyframes show-modal-option {
  from {
    -webkit-transform: scale(0.4);
            transform: scale(0.4);
  }
  50% {
    -webkit-transform: scale(1.2);
            transform: scale(1.2);
    opacity: 1;
  }
  to {
    -webkit-transform: scale(1);
            transform: scale(1);
    opacity: 1;
  }
}
View Code

 

本demo地址:https://codepen.io/alphardex/full/eYYxzBm

20、radial-gradient

径向渐变常用于生成圆形背景,上面例子中Snow的背景就是一个椭圆形的径向渐变此外,由于背景可以叠加,我们可以叠加多个不同位置大小的径向渐变来生成圆点群,再加上动画就产生了一种微粒效果,无需多余的div元素。

@import url(https://fonts.googleapis.com/css?family=Lato);
body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
}

.btn {
  --hue: 190;
  --btn-bg-color: hsl(var(--hue), 100%, 50%);
  --btn-bg-color-darker: hsl(var(--hue), 100%, 45%);
  position: relative;
  padding: 0.75rem 1.5rem;
  margin: 1rem;
  font-size: 1rem;
  font-family: Lato, sans-serif;
  line-height: 1.5;
  color: white;
  text-decoration: none;
  background-color: var(--btn-bg-color);
  border: 1px solid var(--btn-bg-color);
  border-radius: 4px;
  box-shadow: 0 0.1px 0.7px rgba(233, 30, 99, 0.141), 0 0.1px 1.7px rgba(233, 30, 99, 0.202), 0 0.3px 3.1px rgba(233, 30, 99, 0.25), 0 0.4px 5.6px rgba(233, 30, 99, 0.298), 0 0.8px 10.4px rgba(233, 30, 99, 0.359), 0 2px 25px rgba(233, 30, 99, 0.5);
  outline: transparent;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: 0.25s;
}
.btn-pink {
  --hue: 330;
}
.btn-bubbles {
  overflow: visible;
  transition: transform ease-in 0.1s, background-color ease-in 0.1s, box-shadow ease-in 0.25s;
}
.btn-bubbles::before {
  position: absolute;
  content: "";
  left: -2em;
  right: -2em;
  top: -2em;
  bottom: -2em;
  transition: ease-in-out 0.5s;
  background-repeat: no-repeat;
  background-image: radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%), radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%), radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%), radial-gradient(circle, var(--btn-bg-color) 20%, transparent 20%), radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%), radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%), radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%), radial-gradient(circle, var(--btn-bg-color) 20%, transparent 20%), radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%), radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%), radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%), radial-gradient(circle, var(--btn-bg-color) 20%, transparent 20%), radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%), radial-gradient(circle, var(--btn-bg-color) 20%, transparent 20%), radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%), radial-gradient(circle, transparent 20%, var(--btn-bg-color) 20%, transparent 30%);
  background-size: 13% 17%, 10% 19%, 19% 19%, 18% 18%, 16% 15%, 20% 11%, 15% 18%, 12% 11%, 19% 10%, 14% 11%, 10% 14%, 16% 16%, 14% 20%, 17% 13%, 17% 20%, 16% 17%;
  background-position: 18% 40%, 20% 31%, 30% 30%, 40% 30%, 50% 30%, 57% 30%, 65% 30%, 80% 32%, 15% 60%, 83% 60%, 18% 70%, 25% 70%, 41% 70%, 50% 70%, 64% 70%, 80% 71%;
  animation: bubbles ease-in-out 0.75s forwards;
}
.btn-bubbles:active {
  transform: scale(0.95);
  background: var(--btn-bg-color-darker);
}
.btn-bubbles:active::before {
  animation: none;
  background-size: 0;
}

@keyframes bubbles {
  0% {
    background-position: 18% 40%, 20% 31%, 30% 30%, 40% 30%, 50% 30%, 57% 30%, 65% 30%, 80% 32%, 15% 60%, 83% 60%, 18% 70%, 25% 70%, 41% 70%, 50% 70%, 64% 70%, 80% 71%;
  }
  50% {
    background-position: 10% 44%, 0% 20%, 15% 5%, 30% 0%, 42% 0%, 62% -2%, 75% 0%, 95% -2%, 0% 80%, 95% 55%, 7% 100%, 24% 100%, 41% 100%, 55% 95%, 68% 96%, 95% 100%;
  }
  100% {
    background-position: 5% 44%, -5% 20%, 7% 5%, 23% 0%, 37% 0, 58% -2%, 80% 0%, 100% -2%, -5% 80%, 100% 55%, 2% 100%, 23% 100%, 42% 100%, 60% 95%, 70% 96%, 100% 100%;
    background-size: 0% 0%;
  }
}


<button class="btn btn-pink btn-bubbles">Click2 Me</button>
View Code

 

本demo地址:https://codepen.io/alphardex/full/OJPvMGx

21、conic-gradient

圆锥渐变可以用于制作饼图

 

 

 

用一个伪元素叠在饼图上面,并将content设为某个值(这个值通过CSS变量计算出来),就能制作出度量计的效果,障眼法又一次完成了它的使命。

@import url("https://fonts.googleapis.com/css?family=Lato");
body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  background: #222;
}

ul {
  display: flex;
  list-style-type: none;
}
ul .circle-gauge {
  --gauge-max-value: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1em;
}
ul .circle-gauge:nth-child(1) a {
  --percentage: calc(var(--gauge-value) / var(--gauge-max-value) * 100%);
  background: conic-gradient(#e74c3c var(--percentage), #111 0);
}
ul .circle-gauge:nth-child(2) a {
  --percentage: calc(var(--gauge-value) / var(--gauge-max-value) * 100%);
  background: conic-gradient(#3498db var(--percentage), #111 0);
}
ul .circle-gauge:nth-child(3) a {
  --percentage: calc(var(--gauge-value) / var(--gauge-max-value) * 100%);
  background: conic-gradient(#2ecc71 var(--percentage), #111 0);
}
ul .circle-gauge:nth-child(4) a {
  --percentage: calc(var(--gauge-value) / var(--gauge-max-value) * 100%);
  background: conic-gradient(#f1c40f var(--percentage), #111 0);
}
ul .circle-gauge a {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 5em;
  height: 5em;
  font-family: Lato, sans-serif;
  text-decoration: none;
  color: white;
  background: transparent;
  border-radius: 50%;
  counter-reset: value var(--gauge-value);
}
ul .circle-gauge a::before {
  position: absolute;
  content: counter(value);
  display: flex;
  justify-content: center;
  align-items: center;
  width: 90%;
  height: 90%;
  background: #222;
  border-radius: inherit;
}
ul span {
  padding-top: 10px;
  font-size: 12px;
  font-weight: 300;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: white;
}

<ul>
  <li class="circle-gauge"><a href="#" style="--gauge-value:900;"></a><span>design</span></li>
  <li class="circle-gauge"><a href="#" style="--gauge-value:744"></a><span>creativity</span></li>
  <li class="circle-gauge"><a href="#" style="--gauge-value:666"></a><span>accessbility</span></li>
  <li class="circle-gauge"><a href="#" style="--gauge-value:800"></a><span>content</span></li>
</ul>
View Code

 

本demo地址:https://codepen.io/alphardex/full/BaydVvQ

filter

PS里的滤镜,玩过的都懂,blur最常用

22、backdrop-filter

对背景应用滤镜,产生毛玻璃的效果

@import url("https://fonts.googleapis.com/css?family=Lato:200");
body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: url(https://i.loli.net/2019/11/17/GAYyzeKsiWjP5qO.jpg);
  background-size: cover;
  background-position: center;
}

.frosted-glass {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 72vw;
  height: 36vh;
  box-shadow: 0 0.3px 0.7px rgba(0, 0, 0, 0.126), 0 0.9px 1.7px rgba(0, 0, 0, 0.179), 0 1.8px 3.5px rgba(0, 0, 0, 0.224), 0 3.7px 7.3px rgba(0, 0, 0, 0.277), 0 10px 20px rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(20px);
          backdrop-filter: blur(20px);
  transition: 0.5s ease;
}
.frosted-glass:hover {
  box-shadow: 0 0.7px 1px rgba(0, 0, 0, 0.157), 0 1.7px 2.6px rgba(0, 0, 0, 0.224), 0 3.5px 5.3px rgba(0, 0, 0, 0.28), 0 7.3px 11px rgba(0, 0, 0, 0.346), 0 20px 30px rgba(0, 0, 0, 0.5);
}
.frosted-glass .title {
  padding-left: 0.375em;
  font-size: 3.6em;
  font-family: Lato, sans-serif;
  font-weight: 200;
  letter-spacing: 0.75em;
  color: white;
}
@media (max-width: 640px) {
  .frosted-glass .title {
    font-size: 2em;
  }
}

<div class="frosted-glass">
  <h1 class="title">sakura</h1>
</div>
View Code

 

本demo地址:https://codepen.io/alphardex/full/pooQMVp

23、mix-blend-mode

PS里的混合模式,常用于文本在背景下的特殊效果以下利用滤色模式(screen)实现文本视频蒙版效果

@font-face {
  font-family: Biko;
  src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/biko-black.woff");
}
body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

video,
h1 {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
}

video {
  -o-object-fit: cover;
     object-fit: cover;
}

h1 {
  font-size: 20vw;
  font-family: Biko, sans-serif;
  font-weight: 700;
  line-height: 100vh;
  text-transform: uppercase;
  text-align: center;
  background: white;
  mix-blend-mode: screen;
}


<video autoplay muted loop preload poster="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/oceanshot.jpg">
  <source src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/ocean-small.webm" />
  <source src="http://thenewcode.com/assets/videos/ocean-small.mp4" />
</video>
<h1>ocean</h1>
View Code

本demo地址:https://codepen.io/alphardex/full/wvvLYpV

24、clip-path

PS里的裁切,可以制作各种不规则形状。如果和动画结合也会相当有意思。

@import url(https://fonts.googleapis.com/css?family=Lato);
body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  font-family: Lato, sans-serif;
  background: #fafafa;
}

.shadow {
  -webkit-filter: drop-shadow(-2px 2px 8px rgba(50, 50, 0, 0.5));
          filter: drop-shadow(-2px 2px 8px rgba(50, 50, 0, 0.5));
}

.card {
  -webkit-clip-path: inset(0 0 70% 0);
          clip-path: inset(0 0 70% 0);
  -webkit-transform: translateY(30%);
          transform: translateY(30%);
  transition: 0.5s ease;
}
.card .card-header {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 400px;
  height: 100px;
  font-size: 2em;
  color: white;
  background-color: #2979ff;
  -webkit-clip-path: inset(0 19% 0 19%);
          clip-path: inset(0 19% 0 19%);
  transition: 0.5s ease;
}
.card .card-body {
  box-sizing: border-box;
  padding: 1.25em;
  width: 400px;
  height: 225px;
  font-size: 1.5em;
  background: white;
  -webkit-clip-path: inset(0 19% 0 19%);
          clip-path: inset(0 19% 0 19%);
  transition: 0.5s ease;
}
.card .card-body dl {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  margin: 0;
}
.card .card-body span {
  opacity: 0;
  -webkit-transform: translateY(100%);
          transform: translateY(100%);
  transition: 0.5s ease-in;
}
.card .card-body span:nth-child(1) {
  transition-delay: 0.1s;
}
.card .card-body span:nth-child(2) {
  transition-delay: 0.2s;
}
.card .card-body span:nth-child(3) {
  transition-delay: 0.3s;
}
.card .card-body span dt,
.card .card-body span dd {
  display: inline;
  margin: 0;
}
.card .card-body span dt i,
.card .card-body span dd i {
  margin-right: 0.3em;
  color: #4289ff;
}
.card:hover {
  -webkit-transform: translateY(0);
          transform: translateY(0);
  -webkit-clip-path: inset(0 0 0 0);
          clip-path: inset(0 0 0 0);
}
.card:hover .card-header,
.card:hover .card-body {
  -webkit-clip-path: inset(0 0 0 0);
          clip-path: inset(0 0 0 0);
}
.card:hover span {
  opacity: 1;
  -webkit-transform: translateY(0);
          transform: translateY(0);
}

<div class="shadow">
  <div class="card">
    <div class="card-header">Contact</div>
    <div class="card-body">
      <dl>
        <span>
                <dt><a href="https://github.com/alphardex" target="_blank"><i class="fab fa-github"></i></a></dt>
                <dd>alphardex</dd>
            </span>
        <span>
                <dt><a href="mailto:2582347430@qq.com"><i class="fas fa-envelope"></i></a></dt>
                <dd>2582347430@qq.com</dd>
            </span>
        <span>
                <dt><a href="tel:+8613063509980"><i class="fas fa-phone"></i></a></dt>
                <dd>(+86)13063509980</dd>
            </span>
      </dl>
    </div>
  </div>
</div>
View Code

 

本demo地址:https://codepen.io/alphardex/full/ZEEBRrq

25、-webkit-box-reflect

投影效果,不怎么常用,适合立体感强的作品。

<div class="scene">
  <div class="card">
    <div class="card__face card__face--front">
      <img src="https://i.loli.net/2019/11/23/cnKl1Ykd5rZCVwm.jpg" />
    </div>
    <div class="card__face card__face--back">
      <img src="https://i.loli.net/2019/11/16/cqyJiYlRwnTeHmj.jpg" />
    </div>
  </div>
  <div class="card">
    <div class="card__face card__face--front">
      <img src="https://i.loli.net/2019/11/16/FLnzi5Kq4tkRZSm.jpg" />
    </div>
    <div class="card__face card__face--back">
      <img src="https://i.loli.net/2019/10/18/buDT4YS6zUMfHst.jpg" />
    </div>
  </div>
  <div class="card">
    <div class="card__face card__face--front">
      <img src="https://i.loli.net/2019/10/18/uXF1Kx7lzELB6wf.jpg" />
    </div>
    <div class="card__face card__face--back">
      <img src="https://i.loli.net/2019/11/03/RtVq2wxQYySDb8L.jpg" />
    </div>
  </div>
</div>

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: black;
}

.scene {
  width: 1000px;
  display: flex;
  justify-content: space-between;
  -webkit-perspective: 800px;
          perspective: 800px;
}
.scene .card {
  position: relative;
  width: 240px;
  height: 300px;
  color: white;
  cursor: pointer;
  transition: 1s ease-in-out;
  -webkit-transform-style: preserve-3d;
          transform-style: preserve-3d;
}
.scene .card:hover {
  -webkit-transform: rotateY(0.5turn);
          transform: rotateY(0.5turn);
}
.scene .card .card__face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
  transition: 1s ease-in-out;
  -webkit-box-reflect: below 0 linear-gradient(transparent, transparent, rgba(0, 0, 0, 0.4));
}
.scene .card .card__face img {
  width: 240px;
  height: 300px;
  -o-object-fit: cover;
     object-fit: cover;
}
.scene .card .card__face--back {
  -webkit-transform: rotateY(0.5turn);
          transform: rotateY(0.5turn);
}
View Code

 

本demo地址:https://codepen.io/alphardex/full/ExaZgxp

26、web animations

虽然这并不是一个CSS特性,但是它经常用于完成那些CSS所做不到的事情那么何时用它呢?当CSS动画中有属性无法从CSS中获取时,自然就会使用到它了

跟踪鼠标的位置

目前CSS还尚未有获取鼠标位置的API,因此考虑用JS来进行通过查阅相关的DOM API,发现在监听鼠标事件的API中,可通过e.clientXe.clientY来获得鼠标当前的位置既然能够获取鼠标的位置,那么跟踪鼠标的位置也就不是什么难事了:通过监听mouseentermouseleave事件,来获取鼠标出入一个元素时的位置,并用此坐标来当作鼠标的位移距离,监听mousemove事件,来获取鼠标在元素上移动时的位置,同样地用此坐标来当作鼠标的位移距离,这样一个跟踪鼠标的效果就实现了。

<ul class="menu-hover-image">
  <li class="menu-item">
    <a href="#">
      <h1>Home</h1>
      <span>alphardex</span>
    </a>
  </li>
  <li class="menu-item">
    <a href="#">
      <h1>Projects</h1>
      <span>CSS Creations</span>
    </a>
  </li>
  <li class="menu-item">
    <a href="#">
      <h1>Blogs</h1>
      <span>Memories</span>
    </a>
  </li>
  <li class="menu-item">
    <a href="#">
      <h1>About</h1>
      <span>CSS Wizard</span>
    </a>
  </li>
  <div class="cursor"></div>
</ul>



@import url("https://fonts.googleapis.com/css?family=Lora:400,400i,700");
body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #121212;
}

.menu-hover-image {
  position: relative;
  width: 50rem;
  font-family: Lora, serif;
  list-style-type: none;
}
.menu-hover-image .cursor {
  position: absolute;
  top: -50%;
  left: -25%;
  z-index: -1;
  width: 600px;
  height: 400px;
  background-image: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
  background-position: 50% 50%;
  background-size: cover;
  opacity: 0;
}
.menu-hover-image .menu-item:nth-child(1):hover ~ .cursor {
  background-image: url("https://i.loli.net/2019/10/18/buDT4YS6zUMfHst.jpg");
}
.menu-hover-image .menu-item:nth-child(2):hover ~ .cursor {
  background-image: url("https://i.loli.net/2019/10/18/uXF1Kx7lzELB6wf.jpg");
}
.menu-hover-image .menu-item:nth-child(3):hover ~ .cursor {
  background-image: url("https://i.loli.net/2019/11/23/cnKl1Ykd5rZCVwm.jpg");
}
.menu-hover-image .menu-item:nth-child(4):hover ~ .cursor {
  background-image: url("https://i.loli.net/2019/11/03/RtVq2wxQYySDb8L.jpg");
}
.menu-hover-image .menu-item a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-decoration: none;
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  mix-blend-mode: difference;
  -webkit-transform: translate3d(0, 0, 0);
          transform: translate3d(0, 0, 0);
}

var menuItems = document.querySelectorAll(".menu-hover-image .menu-item");
var cursor = document.querySelector(".menu-hover-image .cursor");
var getXY = function (e) { return [
    e.clientX,
    e.clientY
]; };
menuItems.forEach(function (menuItem) {
    // use mouseenter and mouseleave to toggle cursor since they won't bubble!
    menuItem.addEventListener("mouseenter", function (e) {
        var _a = getXY(e), x = _a[0], y = _a[1];
        cursor.animate([
            {
                opacity: 0,
                transform: "translate(" + x + "px, " + y + "px) scale(0)"
            },
            {
                opacity: 1,
                transform: "translate(" + x + "px, " + y + "px) scale(1)"
            }
        ], { duration: 300, fill: "forwards" });
        menuItem.addEventListener("mouseleave", function (e) {
            var _a = getXY(e), x = _a[0], y = _a[1];
            cursor.animate([
                {
                    opacity: 1,
                    transform: "translate(" + x + "px, " + y + "px) scale(1)"
                },
                {
                    opacity: 0,
                    transform: "translate(" + x + "px, " + y + "px) scale(0)"
                }
            ], { duration: 300, fill: "forwards" });
        });
    });
    // move the cursor when mouse moves.
    menuItem.addEventListener("mousemove", function (e) {
        var _a = getXY(e), x = _a[0], y = _a[1];
        cursor.animate([
            {
                transform: "translate(" + x + "px, " + y + "px)"
            }
        ], { duration: 500, delay: 50, fill: "forwards" });
    });
});
View Code

 

本demo地址:https://codepen.io/alphardex/full/OJPmQGz

CSS Houdini

CSS Houdini是CSS的底层API,它使我们能够通过这套接口来扩展CSS的功能

让渐变动起来

目前来说,我们无法直接给渐变添加动画,因为浏览器不理解要改变的值是什么类型这时,我们就可以利用CSS.registerProperty()来注册我们的自定义变量,并声明其语法类型(syntax)为颜色类型<color>,这样浏览器就能理解并对颜色应用插值方法来进行动画还记得上文提到的圆锥渐变conic-gradient()吗?既然它可以用来制作饼图,那么我们能不能让饼图动起来呢?答案是肯定的,定义三个变量:--color1--color2--pos,其中--pos的语法类型为长度百分比<length-percentage>,将其从0变为100%,饼图就会顺时针旋转出现。

 

利用绝对定位和层叠上下文,我们可以叠加多个从小到大的饼图,再给它们设置不同的颜色,应用交错动画,就有了下面这个炫丽的效果。

<div class="mawaru">
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
</div>

body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  background: #b3e5fc;
}

.mawaru {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}
.mawaru .circle {
  position: absolute;
  background: conic-gradient(var(--color1) var(--pos), var(--color2) 0);
  border-radius: 50%;
}
.mawaru .circle:nth-child(1) {
  --color1: #50514F;
  z-index: 7;
  width: 4em;
  height: 4em;
  animation: pos 0.6s linear, color1 1.2s step-end, color2-1 1.2s step-end;
  animation-iteration-count: 2;
  animation-delay: 0.4s;
}
@keyframes color2-1 {
  50% {
    --color2: #50514F;
  }
}
.mawaru .circle:nth-child(2) {
  --color1: #F25F5C;
  z-index: 6;
  width: 8em;
  height: 8em;
  animation: pos 0.6s linear, color1 1.2s step-end, color2-2 1.2s step-end;
  animation-iteration-count: 2;
  animation-delay: 0.8s;
}
@keyframes color2-2 {
  50% {
    --color2: #F25F5C;
  }
}
.mawaru .circle:nth-child(3) {
  --color1: #FFE066;
  z-index: 5;
  width: 12em;
  height: 12em;
  animation: pos 0.6s linear, color1 1.2s step-end, color2-3 1.2s step-end;
  animation-iteration-count: 2;
  animation-delay: 1.2s;
}
@keyframes color2-3 {
  50% {
    --color2: #FFE066;
  }
}
.mawaru .circle:nth-child(4) {
  --color1: #247BA0;
  z-index: 4;
  width: 16em;
  height: 16em;
  animation: pos 0.6s linear, color1 1.2s step-end, color2-4 1.2s step-end;
  animation-iteration-count: 2;
  animation-delay: 1.6s;
}
@keyframes color2-4 {
  50% {
    --color2: #247BA0;
  }
}
.mawaru .circle:nth-child(5) {
  --color1: #70C1B3;
  z-index: 3;
  width: 20em;
  height: 20em;
  animation: pos 0.6s linear, color1 1.2s step-end, color2-5 1.2s step-end;
  animation-iteration-count: 2;
  animation-delay: 2s;
}
@keyframes color2-5 {
  50% {
    --color2: #70C1B3;
  }
}
.mawaru .circle:nth-child(6) {
  --color1: #1D3557;
  z-index: 2;
  width: 24em;
  height: 24em;
  animation: pos 0.6s linear, color1 1.2s step-end, color2-6 1.2s step-end;
  animation-iteration-count: 2;
  animation-delay: 2.4s;
}
@keyframes color2-6 {
  50% {
    --color2: #1D3557;
  }
}
.mawaru .circle:nth-child(7) {
  --color1: #88ABC0;
  z-index: 1;
  width: 28em;
  height: 28em;
  animation: pos 0.6s linear, color1 1.2s step-end, color2-7 1.2s step-end;
  animation-iteration-count: 2;
  animation-delay: 2.8s;
}
@keyframes color2-7 {
  50% {
    --color2: #88ABC0;
  }
}
.mawaru .circle:nth-child(8) {
  --color1: #FFCDB2;
  z-index: 0;
  width: 32em;
  height: 32em;
  animation: pos 0.6s linear, color1 1.2s step-end, color2-8 1.2s step-end;
  animation-iteration-count: 2;
  animation-delay: 3.2s;
}
@keyframes color2-8 {
  50% {
    --color2: #FFCDB2;
  }
}
@keyframes pos {
  to {
    --pos: 100%;
  }
}
@keyframes color1 {
  50% {
    --color1: transparent;
  }
}


CSS.registerProperty({
    name: '--color1',
    syntax: '<color>',
    initialValue: 'transparent',
    inherits: true
});
CSS.registerProperty({
    name: '--color2',
    syntax: '<color>',
    initialValue: 'transparent',
    inherits: true
});
CSS.registerProperty({
    name: '--pos',
    syntax: '<length-percentage>',
    initialValue: '0',
    inherits: true
});
View Code

 

本demo地址:https://codepen.io/alphardex/full/RwNxpXQ

 

27、彩蛋

var shinchouMenuLinks = document.querySelectorAll(".shinchou-menu li a");
shinchouMenuLinks.forEach(function (link) {
    var letters = link.textContent.split("");
    link.textContent = "";
    letters.forEach(function (letter, i) {
        var span = document.createElement("span");
        span.textContent = letter;
        if (i < 2) {
            span.className = "highlight";
        }
        span.style.transitionDelay = i / 10 + "s";
        link.append(span);
    });
});

<ul class="shinchou-menu">
  <li><a href="#">ニュース</a></li>
  <li><a href="#">ストーリー</a></li>
  <li><a href="#">スターフ&キャスト</a></li>
  <li><a href="#">キャラクター</a></li>
  <li><a href="#">放送·配信情報</a></li>
</ul>

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #fafafa;
}

.shinchou-menu {
  --highlight-text-color: #00ACF0;
  display: flex;
  flex-direction: column;
  list-style-type: none;
}
.shinchou-menu li {
  margin: 6px;
}
.shinchou-menu li a {
  position: relative;
  display: inline-flex;
  padding: 6px 2px 6px 2px;
  color: black;
  font-size: 1.6em;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  overflow: hidden;
}
.shinchou-menu li a::before {
  position: absolute;
  content: '';
  top: 0;
  left: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  background: black;
}
.shinchou-menu li a:hover span {
  color: white !important;
  text-shadow: 0 0 10px var(--highlight-text-color);
}
.shinchou-menu li a span {
  position: relative;
  margin: 0 5px 0 4px;
  transition: 0.3s;
}
.shinchou-menu li a span.highlight::before {
  position: absolute;
  content: '';
  top: -3px;
  left: -3px;
  bottom: -3px;
  right: -3px;
  z-index: -1;
  background: var(--highlight-text-color);
}
.shinchou-menu li a span:not(.highlight) {
  color: var(--highlight-text-color);
}
View Code

 

将交错动画和伪类伪元素结合起来写出来的慎重勇者风格的菜单

本demo地址:https://codepen.io/alphardex/full/ExavZdV

标签:特效,scale,fall,transform,animation,vw,translate,css
来源: https://www.cnblogs.com/chenzxl/p/12204746.html