loading--加载转圈圈效果

vue–loading–加载转圈圈效果
哈哈哈哈哈,固定的就很糟糕,使用的时候需要自己改,还好我自己不需要
分为:large(大) medium(中) small(小);由于我暂时不需要,large没写

使用:

<!-- 默认中等大小的圈圈,需要使用小一点的,在组件上面加类名 class='loading-small' 即可 -->
<loading><loading>

HTML:

<template>
    <div class="loading-medium">
        <span v-for="item in 8"></span>
    </div>
</template>

CSS:

<style scoped>
/* 动画 */
@keyframes load {
    0% {
        transform: scale(1);
        background-color: #efefef;
    }
    50% {
        transform: scale(1.2);
        background-color: #ff6f19;
    }
    100% {
        transform: scale(1);
        background-color: #efefef;
    }
}
/* 
    小:.loading-small
    中:.loading-medium
    大:.loading-large
*/
.loading-medium {
    width: 35px;
    height: 35px;
    position: relative;
}
.loading-medium.loading-small {
    width: 25px;
    height: 25px;
}

.loading-medium span {
    position: absolute;
    width: 5px;
    height: 5px;
    background-color: #efefef;
    border-radius: 50%;
    animation: load 1s linear infinite;
}
.loading-medium.loading-small span {
    width: 4px;
    height: 4px;
}

/* 每个圈圈的位置设置,和动画执行的时间 */
.loading-medium span:first-child {
    top: 0;
    left: 50%;
    margin-left: -2.5px;
    margin-top: -2.5px;
    animation-delay: 0s;
}

.loading-medium span:nth-child(2) {
    top: 25%;
    left: 25%;
    margin-top: -6.5px;
    margin-left: -7px;
    animation-delay: 0.125s;
}
.loading-medium.loading-small span:nth-child(2) {
    margin-top: -5px;
    margin-left: -5px;
}

.loading-medium span:nth-child(3) {
    top: 50%;
    left: 0;
    margin-top: -2.5px;
    margin-left: -2.5px;
    animation-delay: 0.25s;
}

.loading-medium span:nth-child(4) {
    bottom: 25%;
    left: 25%;
    margin-left: -7px;
    margin-bottom: -6.5px;
    animation-delay: 0.375s;
}
.loading-medium.loading-small span:nth-child(4) {
    margin-bottom: -5px;
    margin-left: -5px;
}

.loading-medium span:nth-child(5) {
    bottom: 0;
    left: 50%;
    margin-left: -2.5px;
    margin-bottom: -2.5px;
    animation-delay: 0.5s;
}

.loading-medium span:nth-child(6) {
    bottom: 25%;
    right: 25%;
    margin-bottom: -6.5px;
    margin-right: -7px;
    animation-delay: 0.625s;
}
.loading-medium.loading-small span:nth-child(6) {
    margin-bottom: -5px;
    margin-right: -5px;
}

.loading-medium span:nth-child(7) {
    top: 50%;
    right: 0;
    margin-top: -2.5px;
    margin-right: -2.5px;
    animation-delay: 0.75s;
}

.loading-medium span:last-child {
    top: 25%;
    right: 25%;
    margin-top: -6.5px;
    margin-right: -7px;
    animation-delay: 0.875s;
}
.loading-medium.loading-small span:last-child {
    margin-top: -5px;
    margin-right: -5px;
}
</style>

父组件调用:默认是medium大小

import loading from “@/components/loading.vue”;

<!-- 默认--medium大小 -->
<loading></loading>
<!-- 显示小loading -->
<loading :small="true"></loading>

效果展示图:
small:
在这里插入图片描述
medium:
在这里插入图片描述
在这里插入图片描述

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue.js是一个流行的JavaScript框架,用于构建用户界面。Three.js是一个用于创建WebGL渲染的JavaScript库,用于在浏览器创建3D图形和动画。 要在Vue.js使用Three.js特效,你可以按照以下步骤进行操作: 1. 安装Three.js库:可以通过npm或者直接引入CDN来安装Three.js库。 2. 创建Vue组件:在Vue项目创建一个组件,在这个组件引入Three.js库。 3. 初始化Three.js场景:在组件的mounted生命周期钩子函数,创建一个Three.js场景并设置相机、渲染器等基本元素。 4. 创建Three.js特效:使用Three.js的API创建所需的特效,比如创建3D模型、光源、材质等。 5. 更新场景:在组件的updated生命周期钩子函数,更新场景的物体状态,例如旋转、平移等。 6. 渲染场景:使用渲染器将场景渲染到Canvas或者其他HTML元素。 下面是一个简单的例子,展示了如何在Vue.js使用Three.js来创建一个旋转的立方体: ```html <template> <div ref="canvasContainer"></div> </template> <script> import * as THREE from 'three'; export default { mounted() { this.initScene(); this.createCube(); this.animate(); }, methods: { initScene() { this.scene = new THREE.Scene(); this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); this.renderer = new THREE.WebGLRenderer(); this.renderer.setSize(window.innerWidth, window.innerHeight); this.$refs.canvasContainer.appendChild(this.renderer.domElement); }, createCube() { const geometry = new THREE.BoxGeometry(); const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 }); this.cube = new THREE.Mesh(geometry, material); this.scene.add(this.cube); }, animate() { requestAnimationFrame(this.animate); this.cube.rotation.x += 0.01; this.cube.rotation.y += 0.01; this.renderer.render(this.scene, this.camera); }, }, }; </script> ``` 这只是一个简单的示例,你可以根据你的需求进行更加复杂的特效和交互。希望对你有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值