美文网首页前端
Vue 浮动的小球

Vue 浮动的小球

作者: 英勇的骑士_d175 | 来源:发表于2024-01-07 08:59 被阅读0次

1.组件flyBall.vue

<!--
 * 浮动小球
 * @author: Donglei
 * @since: 2023-09-20
 * flyBall.vue
-->
<template>
    <div class="fly-class" :style="`width: ${this.width}px;
                    height: ${this.height}px;
                    border: 1px solid ${this.color}1A;
                    border-radius: 50%;
                    box-shadow: inset 0px -23px 25px 0 ${this.color}2b,inset 0 -36px 30px 0px  ${this.color}26,inset 0 -79px 40px 0px ${this.color}1A,${this.color}0f 0px 2px 1px,${this.color}17 0px 4px 2px,${this.color}17 0px 8px 4px, ${this.color}17 0px 16px 8px,${this.color}17 0px 32px 16px;`">
        <slot></slot>
    </div>
</template>

<script>
export default {
    name: 'flyBall',
    props: {
        color: {
            type: String,
            default: function () {
                return '#FF0000'
            },
        },
        width: {
            type: Number,
            default: 100,
        },
        height: {
            type: Number,
            default: 100,
        },
    },
    data() {
        return {
            defaultClass: ''

        }
    },
    mounted() {
        this.defaultClass = `width: ${this.width}px;
                height: ${this.height}px;
                border: 1px solid ${this.color};
                border-radius: 50%;
                box-shadow: inset 0px -23px 25px 0 ${this.color}2b,
                inset 0 -36px 30px 0px  ${this.color}26,
                inset 0 -79px 40px 0px ${this.color}1A,
                ${this.color}0f 0px 2px 1px,${this.color}17 0px 4px 2px,
                ${this.color}17 0px 8px 4px, ${this.color}17 0px 16px 8px,
                ${this.color}17 0px 32px 16px;`
    },
    methods: {
    },
}

</script>

<style lang="scss" scoped>
.fly-class {
    animation: bounce-down 1.8s linear infinite;
}


@-webkit-keyframes bounce-down {
    25% {
        -webkit-transform: translateY(-10px);
    }

    50%,
    100% {
        -webkit-transform: translateY(0);
    }

    75% {
        -webkit-transform: translateY(10px);
    }
}
</style>

2.调用(需要传入颜色、宽、高)

 <div style="position: fixed; left: 10%; top: 10%;">
      <fly-ball color="#ff00ff" :width="100" :height="100">
        <div style="display: flex; flex-direction: column;justify-content: center;
      align-items: center;color: black;height: 100%;">
          <div>33摄氏度</div>
          <div>温度</div>
        </div>
      </fly-ball>
    </div>

相关文章

  • vue 小球粒子动画

    效果图 插件three.js,自行下载导入 炫彩丝带动画ribbon.js,需要代码的私信我

  • day-11-pygame的应用

    小球碰撞,大球碰击小球,小球消失

  • 鼠标酷炫特效--小球

    实现效果: 首先要引入vue.js html代码: 调节小球大小、自定义绘制图代码: 来源:https://blo...

  • 无标题文章

    清除浮动 http://www.jianshu.com/p/09bd5873bed4css bfc模型 vue的路...

  • 射线拓展

    小球撞击砖块,小球和砖块都必须有碰撞体,当小球撞击到砖块之后,小球消失,在小球原本位置再生成一个小球,点击鼠标继续...

  • Java 小球碰撞

    小球碰撞的关键是 判断小球是否碰撞过:1.当两小球间距小于小球直径时发生碰撞。2.当小球碰到边缘时发生碰撞。

  • 实现小球在弹射前的拉伸特效和动态障碍物特效

    当前我们实现小球弹射时,会先用鼠标点击小球,然后移动鼠标,当松开鼠标时,小球会弹射向鼠标松开的位置。我们按住小球的...

  • 基于C语言的小球移动课程设计

    用C语言实现“小球移动”的简单图形游戏。可添加、删除小球,小球的分数和大小随机,球会在游戏区域内反弹,小球可被删除...

  • 面试题合集

    css方面 1. 水平垂直居中方法 2. 清除浮动的方法 js方面 vue方面 1. watch与computed...

  • 知识回顾第一期

    一、作品效果1、小球朝着某个方向移动,碰到舞台边缘反弹。2、小猫追着小球跑,当小猫碰到小球后,小球随机变换位置继续...

网友评论

    本文标题:Vue 浮动的小球

    本文链接:https://www.haomeiwen.com/subject/twsindtx.html