纯css实现火车入隧道动画效果代码

代码语言:html

所属分类:动画

代码描述:纯css实现火车入隧道动画效果代码

代码标签: 火车 隧道 动画 效果

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


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

<head>

  <meta charset="UTF-8">
  

  
<style>
body {
  height: 100vh;
  position: relative;
  background-color: #9370db;
  text-align: center;
  overflow: hidden;
}
div {
  position: absolute;
}
div:before,
div:after {
  display: block;
  content: '';
  position: absolute;
}
#train {
  width: 60%;
  height: 100%;
  top: auto;
  left: auto;
  right: 0;
  bottom: 0;
  background-repeat: no-repeat, no-repeat, repeat-x, repeat-x, repeat-x, repeat, repeat, repeat, repeat, repeat, no-repeat;
  background-image: -webkit-gradient(linear, left top, right top, color-stop(11em, #ccc), color-stop(11em, #999), color-stop(12em, #999), color-stop(12em, transparent)), -webkit-gradient(linear, left top, left bottom, color-stop(20%, #dc143c), color-stop(20%, #ffd700), color-stop(40%, #ffd700), color-stop(40%, #20b2aa), color-stop(60%, #20b2aa), color-stop(60%, #1e90ff), color-stop(80%, #1e90ff), color-stop(80%, #da70d6)), -webkit-gradient(linear, right top, left top, color-stop(2%, #aaa), color-stop(2%, #555)), -webkit-gradient(linear, right top, left top, color-stop(2%, #888), color-stop(2%, #333)), -webkit-gradient(linear, right top, left top, color-stop(2%, #444), color-stop(2%, #c0c0c0)), radial-gradient(circle at 40% 20%, rgba(255,255,255,0.4) 0.1em, rgba(255,255,255,0) 0.11em), radial-gradient(circle at 80% 30%, rgba(255,255,255,0.4) 0.1em, rgba(255,255,255,0) 0.11em), radial-gradient(circle at 20% 60%, rgba(255,255,255,0.4) 0.1em, rgba(255,255,255,0) 0.11em), radial-gradient(circle at 60% 50%, rgba(255,255,255,0.8) 0.1em, rgba(255,255,255,0) 0.11em), radial-gradient(circle at 50% 50%, rgba(255,255,255,0.6) 0.1em, rgba(255,255,255,0) 0.11em), -webkit-gradient(linear, left top, left bottom, from(black), to(black));
  background-image: linear-gradient(to right, #ccc 11em, #999 11em, #999 12em, transparent 12em), linear-gradient(to bottom, #dc143c 20%, #ffd700 20%, #ffd700 40%, #20b2aa 40%, #20b2aa 60%, #1e90ff 60%, #1e90ff 80%, #da70d6 80%), linear-gradient(to left, #aaa 2%, #555 2%), linear-gradient(to left, #888 2%, #333 2%), linear-gradient(to left, #444 2%, #c0c0c0 2%), radial-gradient(circle at 40% 20%, rgba(255,255,255,0.4) 0.1em, rgba(255,255,255,0) 0.11em), radial-gradient(circle at 80% 30%, rgba(255,255,255,0.4) 0.1em, rgba(255,255,255,0) 0.11em), radial-gradient(circle at 20% 60%, rgba(255,255,255,0.4) 0.1em, rgba(255,255,255,0) 0.11em), radial-gradient(circle at 60% 50%, rgba(255,255,255,0.8) 0.1em, rgba(255,255,255,0) 0.11em), radial-gradient(circle at 50% 50%, rgba(255,255,255,0.6) 0.1em, rgba(255,255,255,0) 0.11em), linear-gradient(black, black);
  background-size: 100% 100%, 100% 1.5em, 7em 0.5em, 7em 1.3em, 7em 3em, 50% 55%, 50% 60%, 50% 60%, 50% 60%, 90% 100%, 100% 100%;
  background-position: 0 0, right 0 bottom 1.8em, right 2em bottom 5.9em, right 2em bottom 5em, right 2em bottom 3.8em, 9em 0, 9em 0, 9em 0, 9em 0, 9em 0, 0 0;
  -webkit-animation: train-2 1000ms infinite linear;
          animation: train-2 1000ms infinite linear;
}
@media (prefers-reduced-motion) {
  #train {
    -webkit-animation: none;
            animation: none;
  }
}
@media screen and (max-width: 700px) {
  #train {
    font-size: 12px;
  }
}
@media screen and (max-width: 450px) {
  #train {
    width: 70%;
    font-size: 10px;
  }
}
@media screen and (min-width: 950px) and (min-height: 600px) {
  #train {
    font-size: 20px;
  }
}
#train:before {
  width: 8em;
  height: 15em;
  left: 1em;
  bottom: 0;
  background-color: #483d8b;
  border-radius: 5em 5em 0 0;
  box-shadow: inset 1.2em 0 0 rgba(255,255,255,0.2);
}
#train:after {
  width: 120%;
  height: 100%;
  right: 100%;
  margin-right: -9em;
  background-repeat: repeat-x;
  background-image: radial-gradient(circle at 50% 100%, transparent 60%, #8b4513 60.5%), radial-gradient(circle at 50% 100%, transparent 60%, #cd853f 60.5%), linear-gradient(#cd853f, #cd853f), linear-gradient(to left, transparent 20%, #555 20%, #555 30%, transparent 30%, transparent 40%, #555 40%, #555 50%, transparent 50%, transparent 60%, #555 60%, #555 70%, transparent 70%, transparent 80%, #555 80%, #555 90%, transparent 90%), linear-gradient(to left, transparent 20%, #333 20%.........完整代码请登录后点击上方下载按钮下载查看

网友评论0