纯css实现夜晚的列车驶入效果

代码语言:html

所属分类:布局界面

代码描述:纯css实现夜晚的列车驶入效果

代码标签: 夜晚 列车 驶入 效果

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


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
* {
  outline: none;
  box-sizing: border-box;
}

:root {
  --body-color: #dedddf;
  --night-color: #1f1c1f;
}

html {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  background-color: var(--body-color);
  display: -webkit-box;
  display: flex;
  -webkit-box-align: center;
          align-items: center;
  height: 100vh;
  -webkit-box-pack: center;
          justify-content: center;
}

.container {
  position: relative;
  width: 500px;
  height: 456px;
  display: -webkit-box;
  display: flex;
  -webkit-box-pack: center;
          justify-content: center;
  -webkit-box-align: center;
          align-items: center;
}

.container-wrapper {
  position: absolute;
  -webkit-clip-path: polygon(37% 0, 65% 0, 100% 100%, 0% 100%);
          clip-path: polygon(37% 0, 65% 0, 100% 100%, 0% 100%);
  width: 500px;
  height: 450px;
  background-color: var(--night-color);
}

.star-container {
  width: 100%;
  height: 100%;
  display: -webkit-box;
  display: flex;
  position: absolute;
  z-index: 1;
}

.stars {
  flex-shrink: 0;
  width: 100%;
  height: 100%;
  position: relative;
  will-change: transform;
  -webkit-animation: infinity-loop 5s infinite linear .1s both;
          animation: infinity-loop 5s infinite linear .1s both;
}

.moon {
  position: absolute;
  width: 45px;
  height: 45px;
  background-color: var(--night-color);
  top: 100px;
  left: 180px;
  border-radius: 50%;
  box-shadow: -11px -11px 0 0 var(--body-color) inset;
  -webkit-animation: moon 20s infinite linear .1s both;
          animation: moon 20s infinite linear .1s both;
  z-index: 2;
}

.star {
  position: absolute;
  background-color: var(--body-color);
  z-index: 9;
}
.star:nth-child(1) {
  right: 200px;
  top: 60px;
  border-radius: 50%;
  width: 5px;
  height: 5px;
}
.star:nth-child(2) {
  right: 90px;
  top: 40px;
  border-left: 1px solid var(--body-c.........完整代码请登录后点击上方下载按钮下载查看

网友评论0