<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>pure CSS twinkling stars background</title> <style> @keyframes move-background { from { -webkit-transform: translate3d(0px, 0px, 0px); } to { -webkit-transform: translate3d(1000px, 0px, 0px); } } @-webkit-keyframes move-background { from { -webkit-transform: translate3d(0px, 0px, 0px); } to { -webkit-transform: translate3d(1000px, 0px, 0px); } } @-moz-keyframes move-background { from { -webkit-transform: translate3d(0px, 0px, 0px); } to { -webkit-transform: translate3d(1000px, 0px, 0px); } } @-webkit-keyframes move-background { from { -webkit-transform: translate3d(0px, 0px, 0px); } to { -webkit-transform: translate3d(1000px, 0px, 0px); } } .background-container { position: fixed; top: 0; left: 0; bottom: 0; right: 0; } .stars { background: black url("stars.png") repeat; position: absolute; top: 0; bottom: 0; left: 0; right: 0; display: block; z-index: 0; } .twinkling { width: 10000px; height: 100%; background: transparent url("twinkling.png") repeat; background-size: 1000px 1000px; position: absolute; right: 0; top: 0; bottom: 0; z-index: 2; -moz-animation: move-background 70s linear infinite; -ms-animation: move-background 70s linear infinite; -o-animation: move-background 70s linear infinite; -webkit-animation: move-background 70s linear infinite; animation: move-background 70s linear infinite; } .clouds { width: 10000px; height: 100%; background: transparent url("clouds_repeat.png") repeat; background-size: 1000px 1000px; position: absolute; right: 0; top: 0; bottom: 0; z-index: 3; -moz-animation: move-background 150s linear infinite; -ms-animation: move-background 150s linear infinite; -o-animation: move-background 150s linear infinite; -webkit-animation: move-background 150s linear infinite; animation: move-background 150s linear infinite; } img { height: 70vh; width: 70vh; position: absolute; z-index: 3; right: 20px; } </style> </head> <body translate="no" > <div class="background-container"> <img src="moon2.png" alt=""> <div class="stars"></div> <div class="twinkling"></div> <div class="clouds"></div> </body> </html> <!-- 文章来源:5款CSS动画背景(滑动对角线/图案无限滚动/灰度三角形/闪烁星星) http://www.webkaka.com/tutorial/html/2021/1020190/ //-->
卡卡测速网
>
html技术
>
5款CSS动画背景(滑动对角线/图案无限滚动/灰度三角形/闪烁星星)
添加收藏
下载源代码
|
运行结果
demo.html
运行代码
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX