Vue实现靠边悬浮球(PC端)
我想把退出登录的按钮做成一个悬浮球的样子,带动画的那种。
实现是这个样子:
手边没有球形图。所以用的毕设PPT扣的 校~,今年毕业,功能这里演示的为单机悬浮球注销登录


嗯,具体代码:
<div
:class="['meun-switch animated flex-row',uploadflag ? 'active rubberBand off' : 'leave jello']"
@mouseleave="uploadleave"
@mouseenter="uploadenter"
v-if="uploadShow"
@click.stop="logout"
>
<img :src="require('@/assets/1.png')"/>
</div>
data
uploadShow: false,
uploadflag: true,
js方法
uploadenter() {
this.uploadflag = true;
},
uploadleave() {
this.uploadflag = false;
},
uploadanimated() {
setTimeout(() => {
this.uploadShow = true;
setTimeout(() => {
this.uploadleave();
}, 1000);
}, 1000);
},
css
.off{
-webkit-animation:1s seconddiv;
background: transparent;
}
@keyframes seconddiv{
0% {transform: scale(1.4,1.4);}
10% {transform: scale(1,1);}
25% {transform: scale(1.2,1.2);}
50% {transform: scale(1,1);}
70% {transform: scale(1.2,1.2);}
100% {transform: scale(1,1);}
}
.meun-switch {
position: fixed;
top: 90px;
left: 0px;
z-index:;
cursor: pointer;
width: 150px;
height: 150px;
padding: 5px;
transition: all 0.25s;
&.leave {
left: -65px;
}
&.active {
left:;
}
&:hover {
transform: scale(1.02);
}
img {
width: 120px;
height: 120px;
}
}
页面代码:
<template>
<div id="app">
<transition name="el-zoom-in-center">
<div v-show="show3">
<div class="sidebar">
<!-- <card></card>-->
<list></list>
<div
:class="['meun-switch animated flex-row ys-float-btn',uploadflag ? 'active rubberBand off' : 'leave jello']"
@mouseleave="uploadleave"
@mouseenter="uploadenter"
v-if="uploadShow"
@click.stop="logout"
>
<img :src="require('@/assets/logo.png')"/>
</div>
</div>
<div class="main">
<message></message>
<usertext></usertext>
</div>
</div>
</transition> </div>
</template> <script> import list from '../../components/chat/list.vue'
import message from '../../components/chat/message.vue'
import usertext from '../../components/chat/usertext.vue'
import screenfull from 'screenfull' export default {
name: 'pageChat',
data() {
return {
//默认不全屏
isFullscreen: false,
show3: false,
uploadShow: false,
uploadflag: true,
}
},
created() { },
mounted: function () {
this.uploadanimated();
this.$store.dispatch('connect');
this.inintview();
},
methods: {
/*注销*/
logout () {
this.$confirm('此操作注销登录, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.getRequest('/logout');
window.sessionStorage.removeItem("user");
// 清除缓存
this.$router.replace("/");
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
},
inintview() {
setTimeout(() => {
this.show3 = true;
}, 1000)
},
uploadenter() {
this.uploadflag = true;
},
uploadleave() {
this.uploadflag = false; },
uploadanimated() {
setTimeout(() => {
this.uploadShow = true;
setTimeout(() => {
this.uploadleave();
}, 1000);
}, 1000);
},
click() {
// 如果不允许进入全屏,发出不允许提示 浏览器不能全屏
if (!screenfull.enabled) {
this.$message({
message: '浏览器不能全屏',
type: 'warning'
})
return false
}
screenfull.toggle()
this.$message({
message: '全屏啦',
type: 'success'
})
} },
components: {
list,
message,
usertext
}
}
</script> <style lang="scss" scoped>
.off{
-webkit-animation:1s seconddiv;
background: transparent;
} @keyframes seconddiv{
0% {transform: scale(1.4,1.4);}
10% {transform: scale(1,1);}
25% {transform: scale(1.2,1.2);}
50% {transform: scale(1,1);}
70% {transform: scale(1.2,1.2);}
100% {transform: scale(1,1);}
}
.meun-switch {
position: fixed;
top: 90px;
left: 0px;
z-index: 2001;
cursor: pointer;
width: 150px;
height: 150px;
padding: 5px;
transition: all 0.25s; &.leave {
left: -65px;
} &.active {
left: 0;
} &:hover {
transform: scale(1.02);
} img {
width: 120px;
height: 120px;
}
} #particles-js {
width: 100%;
height: calc(100% - 100px);
position: absolute;
overflow: hidden;
} #app {
/*背景裁剪在背景边框内部*/
background-clip: padding-box;
/*// 边框样式*/
border: 1px solid #eaeaea;
/*// 边框阴影*/
box-shadow: 0 0 25px #cac6c6;
margin: 20px auto;
width: 1100px;
height: 100%;
overflow: hidden;
border-radius: 10px;
overflow-x: hidden; .sidebar,
.main {
height: 100%;
} .sidebar {
float: left;
color: #f4f4f4;
background-color: transparent;
width: 300px;
height: 100%
} .main {
position: relative;
overflow: hidden;
background-color: transparent;
}
}
</style>
Vue实现靠边悬浮球(PC端)的更多相关文章
- vue搭配的UI框架 pc端 + 移动端
PC桌面端UI框架: 1,iview (最新,用户评分高功能多炫酷 解决和避免了其他UI框架出现的一些小问题) 2, bootstrap (使用用户最多样式死板没特色) 3,Element ...
- 【vue】vue +element 搭建项目,要求既支持pc端又支持移动端
使用场景:有适配pc端改为适配pc端和移动端,使用2套css 代码实现App.vue created: function () { if(document.documentElement.client ...
- vue pc端网站项目开发坑点与难度记录
背景 在一pc端的web项目里,由于某些特性需要由动态语言处理,所以只在有需要使用vue来处理数据的页面,直接引入vue.js来处理.由于刚开始并没有打算使用前端来渲染数据和处理交互,所以使用了一些非 ...
- vue 项目 切换手机端和pc端。同一个项目,配置不同的路由
1, 首先判断设备:在main.js里面写 // vue原型挂载 - 是否PC端 if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator. ...
- Vue PC端框架
Vue PC端框架 1. Element 中文文档:http://element-cn.eleme.io/#/zh-CN github地址:https://github.com/ElemeFE/ele ...
- 使用vue实现简单键盘,支持移动端和pc端
常看到各种app应用中使用自定义的键盘,本例子中使用vue2实现个简单的键盘,支持在移动端和PC端使用,欢迎点赞,h5 ios输入框与键盘 兼容性优化 实现效果: Keyboard.vue <t ...
- vue实现PC端分辨率适配
lib-flexible + px2rem Loader lib-flexible 阿里伸缩布局方案 px2rem-loader:px转rem: 依赖 首先需要安装 vue-cli 脚手架,这里我安装 ...
- 【实战问题】【4】Vue写的页面在微信手机端和微信web开发者工具中都能正常显示,但是在微信pc端上显示空白
原因:pc端微信浏览器不支持es6,而代码中使用了 let . 解决:将 let 改为 var(若使用 es6 语法比较多,可以进行转换,将 es6 语法转为 es5) 参考博客: 1,h5微信页面在 ...
- vue实现PC端调用摄像头拍照人脸录入、移动端调用手机前置摄像头人脸录入、及图片旋转矫正、压缩上传base64格式/文件格式
进入正题 1. PC端调用摄像头拍照上传base64格式到后台,这个没什么花里胡哨的骚操作,直接看代码 (canvas + video) <template> <div> &l ...
随机推荐
- [转] [知乎] 浅谈Roguelike
浅谈Roguelike 从柏林诠释说起 在2008年召开的国际Roguelike开发会议上,众多的Roguelike开发者与爱好者共同制定了<柏林诠释>,规定了Roguelike游戏需要具 ...
- redis list 基本操作
写在前面的话 本篇笔记写在笔者刚工作时.如有问题,请指教. 简介 list是链表,redis list的应用场景很多,也是Redis 最重要的数据结构之一,比如微博的关注列表,粉丝列表,消息列表等功能 ...
- 使用 Chrome 插件 Vimium 打造黑客浏览器
之前一直用 cVim,与 Vimium 功能类似,但是之后不在更新了,故转战到 Vimium. 简介 官网:http://vimium.github.io/ Vimium 是 Google Chrom ...
- java-锁膨胀的过程
先来看个奇怪的demo public class A { int i=0; // boolean flag =false; public synchronized void parse(){ i++; ...
- 小白初学Java的一点点收获
作为刚刚学习Java没有几天的小白,我想把我在学习过程中,所学习到的知识和注意事项和大家一起分享分享.在这个过程中,希望大家可以有所收获,有什么不对的地方,希望大家指出并且私信我. 首先说说第一次记事 ...
- python数据分析工具——Pandas、StatsModels、Scikit-Learn
Pandas Pandas是 Python下最强大的数据分析和探索工具.它包含高级的数据结构和精巧的工具,使得在 Python中处理数据非常快速和简单. Pandas构建在 Numpy之上,它使得以 ...
- Web前端三大主流框架是什么?Web前端前景与就业形势
近十年以来,IT行业发展火热,衍生了很多新职业,例如UI设计师.开发工程师.软件测试工程师等等,在众多备受瞩目的新生职业中,Web前端工程师是其中的一员.那么Web前端三大主流框架是什么呢? 一.We ...
- tp5.1 依赖注入的使用
参考:概念:https://blog.csdn.net/qq_36172443/article/details/82667427应用: http://www.cnblogs.com/finalandd ...
- linux--配置开发环境 --Nginx篇
安装: 安装好了话,我们的nginx的目录在: /etc/nginx 启动: sudo service nginx start 然后访问我们的页面就可以看到了我们的界面 然后我们配置我们的域名: 我 ...
- mysql 复制表结构和数据
CREATE TABLE 新表名 SELECT 字段 as 新字段,字段 as 新字段.....from 旧表名: