美文网首页Vue
Vue<黏黏球效果>

Vue<黏黏球效果>

作者: 誰在花里胡哨 | 来源:发表于2019-09-19 19:19 被阅读0次
效果图:
ball.gif

如果想单纯的实现这种效果,其实使用CSS中的对比度和模糊度就能实现。

 filter: contrast(20); //对比度
 filter: blur(10px); //模糊度

具体怎么实现请参考https://www.jb51.net/css/672819.html,这个上面解释的很清楚,但是这种方法只适合于实现效果,因为当你想做一个菜单栏,你会发现根本看不见文字。

!!要注意下面的代码就能实现咯!😜

这篇文章主要运用了滤镜,通过CSS中直接引用 filter: url("#shadowed-goo");就可以直接实现效果了,svg内的东西我也不太清楚,直接拿来用就行了!!😁

代码如下:
<template>
  <div class="overall">
    <div class="box">
      <div class="ball" @click="ball=!ball">
          <div class="dot" v-for="(i,index) in 3" :key="index" :style="ball?`transform: rotate(${120*index}deg) translateX(90px)`:`transform: rotate(${120*index}deg)`">+</div>
      </div>
    </div>
    <svg style="width: 0; height: 0;">
    <defs>
    <filter id="shadowed-goo">
        <feGaussianBlur in="SourceGraphic" result="blur" stdDeviation="10" />
        <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 18 -7" result="goo" />
        <feGaussianBlur in="goo" stdDeviation="3" result="shadow" />
        <feColorMatrix in="shadow" mode="matrix" values="0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 -0.2" result="shadow" />
        <feOffset in="shadow" dx="1" dy="1" result="shadow" />
        <feBlend in2="shadow" in="goo" result="goo" />
        <feBlend in2="goo" in="SourceGraphic" result="mix" />
    </filter>
    <filter id="goo">
        <feGaussianBlur in="SourceGraphic" result="blur" stdDeviation="10" />
        <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 18 -7" result="goo" />
        <feBlend in2="goo" in="SourceGraphic" result="mix" />
    </filter>
    </defs>
</svg>
  </div>
</template>

<script>
export default {
    data(){
        return{
            ball:false
        }
    }
};
</script>

<style lang="scss" scoped>
.box {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  width: 360px;
  height: 360px;
 filter: url("#shadowed-goo");
 display: flex;
 justify-content: center;
 align-items: center;
//  filter: contrast(20); //对比度
  .ball {
    color: white;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: black;
    // filter: blur(10px); //模糊度
    position: relative;
    cursor: pointer;
    .dot{
        width: 70px;
        height: 70px;
        border-radius: 50%;
        background: black;
        position: absolute;
        top: calc(50% - 35px);
        left: calc(50% - 35px);
        transition: 0.5s;
        line-height: 70px;
        z-index: -1;
    }
  }
}
</style>

相关文章

  • Vue<黏黏球效果>

    效果图: 如果想单纯的实现这种效果,其实使用CSS中的对比度和模糊度就能实现。 具体怎么实现请参考https://...

  • 黏黏球

    你们知道粘粘球吗? 就是那种一个小球,在胶带上缠呀缠,越来越大的超解压的小球哟。 我今天就买了一个...

  • CSS+HTML<手机充电黏黏球效果>

    原文链接:https://www.jianshu.com/p/e6f8dace99ed 效果图: ?如果想单纯的实...

  • CSS+HTML<手机充电黏黏球效果>

    效果图: ?此处有用到svg滤镜效果,同等与以上效果(推荐使用) ?点击此处查看简单用法 ?这篇文章有一个比较生的...

  • 黏黏黏

    这两天,孩子一直黏着我,很黏,很黏,他都七岁了,都61斤了,还黏着我,每次看到我坐在沙发上,就一屁股坐在我身上,然...

  • 你需要谈一场黏黏黏黏黏黏黏黏黏人的恋爱

    1 在微博上看到的一句话:“喜欢那种,没一会就要问我在干嘛,总和我分享有趣事的人,总是会想起我,让我感觉自己被需要...

  • vue-html vue-text vue-once v

    1.vue-html 效果图示: 2.vue-text 效果图示: 3.vue-once vue-once只绑定一...

  • 总有一种理由

    晚上,当我奋笔疾书的在桌前写作业的时候,我妈却在一旁悄悄玩起了我的黏黏球。这……这球到底是给谁买的?! ...

  • 38.Vue 数字输入框组件

    效果: 案例 index.vue inputCmp.vue (组件)

  • vue vue-router vuex element-ui a

    product.vue productlist.vue productcontent.vue 效果 总结 样式的写...

网友评论

    本文标题:Vue<黏黏球效果>

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