346 字
2 分钟
给网站添加一个原神启动特效
NOTE在css文件里添加如下代码!
#splashScreen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #fff; /* 背景色,可根据需要调整 */ display: flex; justify-content: center; align-items: center; z-index: 9999; /* 确保在最上层 */ animation: fadeOut 1s forwards 1.5s; /* 3秒后开始淡出,持续2秒,总共5秒后消失 */}
@keyframes spinAndScale { 0% { transform: rotate(0deg) scale(0.5); opacity: 0; } 50% { transform: rotate(180deg) scale(1.2); opacity: 1; } 100% { transform: rotate(360deg) scale(1); opacity: 1; }}
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; visibility: hidden; }}NOTE然后在index等核心页面的html的body标签最前面中添加如下层
<div id="splashScreen"> <img src="images/genshin.jpg" alt="原神启动"></div>NOTE最后在images中添加原神图片就可以了
备选方案: 可将图片替换成别的 这里还有一种旋转特效的 在css中换成如下内容即可!
#splashScreen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #fff; /* 背景色,可根据需要调整 */ display: flex; justify-content: center; align-items: center; z-index: 9999; /* 确保在最上层 */ animation: fadeOut 1s forwards 1.5s; /* 3秒后开始淡出,持续2秒,总共5秒后消失 */}
/* 旋转动画,同时可以加上缩放 */#splashScreen img { animation: spinAndScale 3s ease-in-out;}
@keyframes spinAndScale { 0% { transform: rotate(0deg) scale(0.5); opacity: 0; } 50% { transform: rotate(180deg) scale(1.2); opacity: 1; } 100% { transform: rotate(360deg) scale(1); opacity: 1; }}
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; visibility: hidden; }}本文将在后续进行完善,感谢支持!(/(°∞°))
给网站添加一个原神启动特效
https://lachsmcblog.netlify.app/posts/post-2/ 部分信息可能已经过时