2024年6月

先看效果:
PixPin_2024-06-18_08-12-55.gif
HTML代码如下:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>科幻卡片悬停效果</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="container">
      <div class="box" style="--clr: #f00">
        <ion-icon name="brush-outline"></ion-icon>
        <h2>01<br /><small>Design</small></h2>
        <div class="clip">
          <span></span>
          <span></span>
          <span></span>
        </div>
      </div>

      <div class="box" style="--clr: #0f0">
        <ion-icon name="code-slash-outline"></ion-icon>
        <h2>02<br /><small>Code</small></h2>
        <div class="clip">
          <span></span>
          <span></span>
          <span></span>
        </div>
      </div>

      <div class="box" style="--clr: #f0f">
        <ion-icon name="rocket-outline"></ion-icon>
        <h2>03<br /><small>Launch</small></h2>
        <div class="clip">
          <span></span>
          <span></span>
          <span></span>
        </div>
      </div>
    </div>


  </body>
</html>

CSS代码如下:



* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}

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

.container {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 150px;
  flex-wrap: wrap;
}

.container .box {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 240px;
  height: 320px;
  background-color: var(--clr);
  box-shadow: 0 0 0 15px #0009,
    0 25px 55px var(--clr);

}

.container .box h2 {
  position: relative;
  color: #020d1e;
  font-size: 4em;
  text-align: center;
  line-height: 2.5em;
  transform: scale(0);
  transition: .5s;
  transition-delay: 0;
  filter: blur(10px);
}

.container .box h2 small {
  font-size: .35em;
  text-transform: uppercase;
  font-weight: 500;
}

.container .box:hover h2 {
  transform: scale(1);
  filter: blur(0);
}

.container .box ion-icon {
  position: absolute;
  font-size: 4em;
  transition: .5s;
  transition-delay: 0;
  transform: translateY(100px);
  opacity: 0;
}

.container .box:hover ion-icon {
  transition-delay: 1s;
  opacity: 1;
  transform: translateY(0);
}

.container .box .clip {
  position: absolute;
  inset: 20px;
  box-shadow: 0 0 0 18px #020d1e;
}

.container .box .clip span {
  position: absolute;
  inset: 0;
  background-color: #202d1e;
  transition: .25s;
}

.container .box .clip span:nth-child(1) {
  clip-path: polygon(0 0, 50% 40%, 100% 0);
  transition-delay: 0;
}

.container .box:hover .clip span:nth-child(1) {
  clip-path: polygon(0 0, 50% 0, 100% 0);
}

.container .box .clip span:nth-child(2) {
  clip-path: polygon(0 0, 40% 50%, 50% 100%, 0% 100%);
  transition-delay: .25s;
}

.container .box:hover .clip span:nth-child(2) {
  clip-path: polygon(0 0, 0 100%, 50% 100%, 0% 100%);
}


.container .box .clip span:nth-child(3) {
  clip-path: polygon(60% 50%, 100% 0, 100% 100%, 50% 100%);
  transition-delay: .5s;
}

.container .box:hover .clip span:nth-child(3) {
  clip-path: polygon(100% 100%, 100% 0, 100% 100%, 50% 100%);
}

效果:
PixPin_2024-06-16_09-22-21.gif
HTML代码:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>CSS云雨效果</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="container">
      <div class="cloud"></div>
    </div>
    <script>
      function rain() {
        const cloud = document.querySelector(".cloud"),
          e = document.createElement("div"),
          left = Math.floor(Math.random() * 310),
          width = Math.random() * 5,
          height = Math.random() * 50,
          duration = Math.random() * 0.5;

        e.classList.add("drop");
        cloud.appendChild(e);
        e.style.left = left + "px";
        e.style.width = 0.5 + width + "px";
        e.style.height = 0.5 + height + "px";
        e.style.animationDuration = 1 + duration + "s";
        setTimeout(() => {
          cloud.removeChild(e);
        }, 2000);
      }

      setInterval(() => {
        rain();
      }, 20);
    </script>
  </body>
</html>

CSS代码:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #1b1b1b;
}

.container {
  position: relative;
  width: 100%;
  height: 400px;
  display: flex;
  justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.container .cloud {
  position: relative;
  width: 320px;
  height: 100px;
  background-color: #fff;
  border-radius: 100px;
  filter: drop-shadow(8px 8px 0 #0005);
  animation: animateCloud 2s steps(1) infinite;
}

@keyframes animateCloud {
  0% {
    filter: drop-shadow(8px 8px 0 #0001) drop-shadow(0 0 0 #fff) brightness(1);
  }
  95% {
    filter: drop-shadow(8px 8px 0 #0001) drop-shadow(0 0 50px #fff5)
      brightness(10);
  }
}

.container .cloud::before {
  content: "";
  position: absolute;
  top: -50px;
  left: 40px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background-color: #484f59;
  box-shadow: 90px -10px 0 30px #484f59;
}

.container .cloud::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: #484f59;
  border-radius: 100px;
  z-index: 1000;
}

.container .cloud .drop {
  position: absolute;
  top: 40px;
  background-color: #05a2eb;
  width: 2px;
  height: 10px;
  transform-origin: bottom;
  animation: animate 2s linear infinite;
}

@keyframes animate {
  0% {
    transform: translateY(0) scaleY(1);
  }
  70% {
    transform: translateY(360px) scaleY(1);
  }
  80% {
    transform: translateY(360px) scaleY(0.2);
  }
  100% {
    transform: translateY(360px) scaleY(0) scaleX(15);
  }
}

看效果:
PixPin_2024-06-12_11-08-23.gif
THML代码:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>动态数据滚动效果</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <section>
      <h2>Scroll To Reveal</h2>
    </section>
    <div class="container"></div>
    <script>
      for (let i = 0; i <= 60; i++) {
        const box = document.createElement("div");
        box.classList.add("box");
        document.querySelector(".container").appendChild(box);
      }

      const randomColorBlock = document.querySelectorAll(".box");

      function addColor() {
        randomColorBlock.forEach((e) => {
          e.style.background = randomColor();
        });
      }

      function randomColor() {
        const chars = "1234567890abcdef",
          colorLength = 6;
        let color = "";
        for (let i = 1; i <= colorLength; i++) {
          const rondomColors = Math.floor(Math.random() * chars.length);
          color += chars.substring(rondomColors, rondomColors + 1);
        }
        return "#" + color;
      }

      addColor();

      const boxes = document.querySelectorAll(".box");

      function scrollTrigger() {
        boxes.forEach((boxxx) => {
          if (boxxx.offsetTop < window.scrollY) {
            boxxx.classList.add("active");
          } else {
            boxxx.classList.remove("active");
          }
        });
      }

      window.addEventListener("scroll", scrollTrigger);
    </script>
  </body>
</html>

CSS代码:

@import url("https://fonts.googleapis.com/css?family=Poppins:200,300,400,500,600,700,800,900&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  background-color: #111;
  overflow-x: hidden;
}

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

section h2 {
  position: relative;
  color: #fff;
  font-size: 8vw;
  font-weight: 500;
}

.container {
  position: relative;
  top: -200px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  width: 700px;
  grid-gap: 30px;
}

.container .box {
  position: relative;
  top: 50vh;
  width: 200px;
  height: 200px;
  transition: 0.5s;
  background-color: #fff;
  border-radius: 10px;
}

.container .box:nth-child(3n + 1) {
  transform: translate(-400px, 0) scale(0);
}

.container .box:nth-child(3n + 2) {
  transform: translate(0, 400px) scale(0);
}

.container .box:nth-child(3n + 3) {
  transform: translate(400px, 0) scale(0);
}

.container .box.active {
  transform: translate(0, 0) scale(1);
}

先看看效果:
PixPin_2024-06-10_17-57-17.gif
HTML代码:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>CSS带有滑动菜单指示器的导航选项卡</title>
    <link rel="stylesheet" href="style.css" />
    <link
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"
    />
  </head>
  <body>
    <div class="tabs">
      <input type="radio" id="home" name="tabsMenu" checked />
      <input type="radio" id="profile" name="tabsMenu" />
      <input type="radio" id="likes" name="tabsMenu" />
      <input type="radio" id="settings" name="tabsMenu" />
      <input type="radio" id="notifications" name="tabsMenu" />
      <div class="buttons">
        <label for="home"><i class="fa-solid fa-house"></i></label>
        <label for="profile"><i class="fa-solid fa-user"></i></label>
        <label for="likes"><i class="fa-solid fa-heart"></i></label>
        <label for="settings"><i class="fa-sharp fa-solid fa-gear"></i></label>
        <label for="notifications"><i class="fa-solid fa-bell"></i></label>
        <div class="underline"></div>
      </div>
    </div>
  </body>
</html>

CSS代码:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #10202b;
}

.tabs input {
  visibility: hidden;
  display: none;
}

.buttons {
  position: relative;
  display: flex;
  gap: 80px;
  padding: 30px 40px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  background-color: #182d3c;
  overflow: hidden;
  border-radius: 20px;
}

.buttons label {
  width: 20%;
  font-size: 1.75em;
  -webkit-text-stroke: 1px #fff;
  color: transparent;
  opacity: 0.3;
  cursor: pointer;
  transition: 0.5s;
}

.buttons label:hover {
  opacity: 1;
  filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 20px #fff);
}

.tabs input:nth-child(1):checked ~ .buttons label:nth-child(1),
.tabs input:nth-child(2):checked ~ .buttons label:nth-child(2),
.tabs input:nth-child(3):checked ~ .buttons label:nth-child(3),
.tabs input:nth-child(4):checked ~ .buttons label:nth-child(4),
.tabs input:nth-child(5):checked ~ .buttons label:nth-child(5) {
  color: #fff;
  opacity: 1;
  filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 20px #fff);
}

.underline {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 20%;
  height: 5px;
  transition: 0.5s;
}

.underline::before {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  border-radius: 4px;
  height: 100%;
  background-color: #fff;
  filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 20px #fff)
    drop-shadow(0 0 30px #fff) drop-shadow(0 0 50px #fff);
}

.underline::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  border-radius: 4px;
  height: 100%;
  background-color: #fff;
  filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 20px #fff)
    drop-shadow(0 0 30px #fff) drop-shadow(0 0 50px #fff) blur(5px);
}

.tabs input:nth-child(1):checked ~ .buttons .underline {
  left: 0;
}

.tabs input:nth-child(2):checked ~ .buttons .underline {
  left: 20%;
}

.tabs input:nth-child(3):checked ~ .buttons .underline {
  left: 40%;
}

.tabs input:nth-child(4):checked ~ .buttons .underline {
  left: 60%;
}
.tabs input:nth-child(5):checked ~ .buttons .underline {
  left: 80%;
}

看一下效果:
PixPin_2024-06-09_08-43-35.gif

HTML代码:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>手机充电动画</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="container">
      <div class="number">66.6%</div>
      <div class="contrast">
        <div class="circle"></div>
        <ul id="bubbles" class="bubbles"></ul>
      </div>
    </div>
    <script>
      const bubbles = document.getElementById("bubbles");
      for (let i = 0; i < 15; i++) {
        const bubble = document.createElement("li");
        const width = `${15 + 15 * Math.random()}px`;
        const left = `${15 + 70 * Math.random()}px`;
        const duration = `${3 + 6 * Math.random()}s`;
        const delay = `${(5000 * Math.random()) / 1000}s`;
        bubble.style.width = width;
        bubble.style.height = width;
        bubble.style.left = left;
        bubble.style.animation = `moveToTop ${duration} ease-in-out ${delay} infinite`;
        bubbles.appendChild(bubble);
      }
    </script>
  </body>
</html>

CSS代码:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #000;
  overflow: hidden;
}

.container {
  position: relative;
  width: 300px;
  height: 400px;
}

.number {
  position: absolute;
  width: 300px;
  top: 24%;
  text-align: center;
  font-size: 32px;
  color: #fff;
  z-index: 10;
}

.contrast {
  width: 300px;
  height: 400px;
  background-color: #000;
  overflow: hidden;
  filter: contrast(10) hue-rotate(0);
  animation: hueRotate 10s infinite linear;
}

.circle {
  position: relative;
  width: 300px;
  height: 300px;
  filter: blur(8px);
}

.circle::after {
  content: "";
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(0);
  width: 200px;
  height: 200px;
  background-color: #00ff6f;
  border-radius: 42% 38% 62% 49% / 45%;
  animation: rotate 10s infinite linear;
}

.circle::before {
  content: "";
  position: absolute;

  width: 176px;
  height: 176px;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background-color: #000;
  z-index: 10;
}

.bubbles {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100px;
  height: 40px;
  transform: translate(-50%, 0);
  border-radius: 100px 100px 0 0;
  background-color: #00ff6f;
  filter: blur(5px);
}

li {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background-color: #00ff6f;
}

@keyframes rotate {
  50% {
    border-radius: 45% / 42% 38% 58% 49%;
  }
  100% {
    transform: translate(-50%, -50%) rotate(720deg);
  }
}

@keyframes hueRotate {
  100% {
    filter: contrast(15) hue-rotate(360deg);
  }
}

@keyframes moveToTop {
  90% {
    opacity: 1;
  }
  100% {
    opacity: 0.1;
    transform: translate(-50%, -180px);
  }
}