Flutter Web首次加载时添加动画

前言

现在web上线后首次加载会很慢,要5秒以上,并且在加载的过程中界面是白屏。因此想在白屏的时候放一个加载动画

实现步骤

1.添加以下<style>标签内容到<head>标签中

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| <style> .loading { display: flex; justify-content: center; align-items: center; margin: 0; position: absolute; top: 50%; left: 50%; -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } .loader { border: 16px solid #f3f3f3; border-radius: 50%; border: 15px solid ; border-top: 16px solid blue; border-right: 16px solid white; border-bottom: 16px solid blue; border-left: 16px solid white; width: 120px; height: 120px; -webkit-animation: spin 2s linear infinite; animation: spin 2s linear infinite; } @-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); } } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style> |

2.添加动画到界面

添加以下代码到jjs代码前面

|-----------------------------------------------------------------|
| <div class="loading"> <div class="loader"></div> </div> |

相关推荐
FakeOccupational1 小时前
nodejs 007:错误npm error Error: EPERM: operation not permitted, symlink
前端·npm·node.js
奶糖 肥晨1 小时前
react是什么?
前端·react.js·前端框架
亦舒.1 小时前
JSDelivr & NPM CDN 国内加速节点
前端·npm·node.js
代码搬运媛1 小时前
code eintegrity npm err sha512
前端·npm·node.js
阳光开朗_大男孩儿1 小时前
DBUS属性原理
linux·服务器·前端·数据库·qt
pan_junbiao2 小时前
Vue组件:模板引用ref属性的使用
前端·javascript·vue.js
LvManBa2 小时前
Vue学习记录之四(computed的用法)
前端·vue.js·学习
陶甜也2 小时前
前后端分离,使用MOCK进行数据模拟开发,让前端攻城师独立于后端进行开发
前端·okhttp
_耀北2 小时前
前端分段式渲染较长文章
前端
想退休的搬砖人3 小时前
vue组件的生命周期
前端·javascript·vue.js