HTML+CSS+JS实现 ❤️夜晚云层动画特效❤️
生活随笔
收集整理的這篇文章主要介紹了
HTML+CSS+JS实现 ❤️夜晚云层动画特效❤️
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
???效果演示:
基于css3 keyframes 屬性制作烏云密布云層動畫,夜晚云層飄過動畫特效。可用于網頁動態云層背景特效。利用animation 和png云圖片制作完成。?
???代碼目錄:
?
主要代碼實現:
css樣式:
html, body {width: 100%;height: 100%;overflow: hidden; }body {background: #000;text-align: center;@keyframes clouds-loop-1 {to {background-position: -1000px 0;} }.clouds-1 {background-image: url("../img/clouds_2.webp");animation: clouds-loop-1 20s infinite linear; }@keyframes clouds-loop-2 {to {background-position: -1000px 0;} }.clouds-2 {background-image: url("../img/clouds_1.webp");animation: clouds-loop-2 15s infinite linear; }@keyframes clouds-loop-3 {to {background-position: -1579px 0;} }.clouds-3 {background-image: url("../img/clouds_3.webp");animation: clouds-loop-3 17s infinite linear; }html, body {font-family: sans-serif;height: 100%;padding: 0;margin: 0; }body {background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzMzMzMzMyIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==');background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #333333), color-stop(100%, #000000));background: -moz-linear-gradient(#333333, #000000);background: -webkit-linear-gradient(#333333, #000000);background: linear-gradient(#333333, #000000); }body, body a {color: #cccccc; }h1.quote {-moz-transform: translate(-50%, -50%);-ms-transform: translate(-50%, -50%);-webkit-transform: translate(-50%, -50%);transform: translate(-50%, -50%);display: inline-block;vertical-align: middle;*vertical-align: auto;*zoom: 1;*display: inline;text-align: right;text-decoration: none;font-family: 'Oswald', sans-serif;font-weight: normal;position: absolute;top: 50%;left: 50%;font-size: 1.5em;line-height: 1.5em;margin: 0;text-shadow: 0 -1px 0 #ffffff, 0 2px 3px #000000; }h1.quote span {display: block; }.clouds {filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=40);opacity: 0.4;pointer-events: none;position: absolute;overflow: hidden;top: 0;left: 0;right: 0;height: 100%; }.clouds-1, .clouds-2, .clouds-3 {background-repeat: repeat-x;position: absolute;top: 0;right: 0;left: 0;height: 500px; } }body::before {content: "";display: inline-block;height: 100%;vertical-align: middle; }.scene {position: relative;display: inline-block;vertical-align: middle;perspective: 15px;perspective-origin: 50% 50%; }.wrap {position: absolute;width: 1000px;height: 1000px;left: -500px;top: -500px;transform-style: preserve-3d;animation: move 12s infinite linear;animation-fill-mode: forwards; }.wrap:nth-child(2) {animation: move 12s infinite linear;animation-delay: 6s; }.wall {width: 100%;height: 100%;position: absolute;background: url(../img/sg.jpg);background-size: cover;opacity: 0;animation: fade 12s infinite linear; }.wrap:nth-child(2) .wall {animation-delay: 6s; }.wall-right {transform: rotateY(90deg) translateZ(500px); }.wall-left {transform: rotateY(-90deg) translateZ(500px); }.wall-top {transform: rotateX(90deg) translateZ(500px); }.wall-bottom {transform: rotateX(-90deg) translateZ(500px); }.wall-back {transform: rotateX(180deg) translateZ(500px); }@keyframes fade {0% {opacity: 0;}25% {opacity: 1;}75% {opacity: 1;}100% {opacity: 0;} }@keyframes move {0% {transform: translateZ(-500px) rotate(0deg);}100% {transform: translateZ(500px) rotate(0deg);} }html代碼 :
<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><title>What do you have to be scared of?</title><link rel="stylesheet" href="css/style.css"><script src="js/prefixfree.min.js"></script></head><body><h1 class='quote'><span>你是個鬼魂,駕駛著一具用星塵做成的肉骨架。</span><span>... 你害怕什么?</span></h1><div class='clouds'><div class='clouds-1'></div><div class='clouds-2'></div><div class='clouds-3'></div></div></body></html>需要把JS引入進來、圖片也可以替換成自己喜歡的樣子。
源碼獲取
精彩推薦更新中:
HTML5大作業實戰100套
??打卡 文章 更新? 36??/? 100天
大家可以點贊、收藏、關注、評論我啦 、需要完整文件隨時聯系我或交流喲~!
總結
以上是生活随笔為你收集整理的HTML+CSS+JS实现 ❤️夜晚云层动画特效❤️的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HTML+CSS+JS实现 ❤️酷炫彩虹
- 下一篇: [INS-30131] 执行安装程序验证