主体思路参考:
-
- /* 显示加载场景 */
- .loadBackGround{
- position: absolute;
- top: 0px;
- text-align: center;
- width: 100%;
- height: 100vh;
- background-color: #efefef;
- opacity: 0.6;
- }
-
- /* 加载动画 */
- .load{
- position: absolute;
- top: 50vh;
- width: 100px;
- animation-name: loading;
- animation-timing-function:linear;
- animation-duration:1.5s;
- animation-iteration-count:infinite;
- }
-
- @keyframes loading {
- from{
- transform: rotateZ(0deg);
- }
- to{
- transform: rotateZ(360deg);
- }
- }


或者
注意:图片一开始是 不显示的
style="display: none;
当点击按钮后才显示。
-
- <script>
- // 1. 获取元素
- var btn = document.querySelector('#btn');
- var img = document.querySelector('#new');
- var index = 1;
- // 2. 添加事件
- btn.onclick = function() {
- img.style.display = 'block';
- }
- </script>
完成。
