首页  >  问答  >  正文

javascript - vue2.0 transition hover事件

使用vue2.0 transition怎么完成鼠标移上去,从屏幕外侧滑出二维码,离开二维码滑出屏幕的效果

大家讲道理大家讲道理2685 天前578

全部回复(2)我来回复

  • 巴扎黑

    巴扎黑2017-05-19 10:32:59

    vue 的transition组件会对组件内的元素进行 v-show v-if来进行判断执行进入动画,离开动画,所以写好对应的动画后,鼠标移入显示,离开隐藏即可

    回复
    0
  • 阿神

    阿神2017-05-19 10:32:59

    html

    <p id="app">
        <p id=ad-box @mouseenter='show =true' @mouseleave='show = false'>
            我是放广告的父盒子
            <transition name='fade'>
                <p id=ad v-show='show'>我是广告</p>
            </transition>
        </p>
    </p>

    css

    html, body, #app {
                width: 100%;
                height: 100%;
            }
    
            #ad-box {
                width: 200px;
                height: 200px;
                position: fixed;
                right: 0;
                bottom: 50%;
                background: #cccccc;
            }
    
            #ad {
                width: 100%;
                height: 100%;
                background: gray;
            }
    
            .fade-enter-active, .fade-leave-active {
                transition: opacity .5s
            }
    
            .fade-enter, .fade-leave-active {
                opacity: 0
            }

    要是想从屏幕外滑进来就换一下css样式就好了,大概就这么写

    回复
    0
  • 取消回复