vue 添加旋转图片 修改css transform 值
//点击放大图片并旋转图片
conponents组建
<template>
<!-- 过渡动画 -->
<transition name="fade">
<div class="img-view" @click="bigImg">
<!-- 遮罩层 -->
<div class="img-layer">
<div class="imgBox">
<div style="width: 400px;height: 400px;margin-bottom: 20px;">
<img :src="imgSrc" :style="{transform:'rotateZ('+deg+'deg)'}">
</div>
<div class="rotateBox">
<el-button type="primary" @click.stop="fan()">
<svg-icon icon-class="zuoRotate" />
逆时针旋转
</el-button>
<el-button type="primary" @click.stop="zheng()" style="margin-left:20px ;">
<svg-icon icon-class="youRotate" />
顺时针旋转
</el-button>
</div>
</div>
</div>
</div>
</transition>
</template>
<script>
export default {
props: ['imgSrc'],
data(){
return{
deg:0,
}
},
methods: {
bigImg() {
// 发送事件
this.$emit('clickit')
},
fan(){
this.deg -= 90;
if(this.deg >= 360){
this.deg = 0
}
},
zheng(){
this.deg += 90;
if(this.deg >= 360){
this.deg = 0
}
}
}
}
</script>
<style scoped>
/*动画*/
.fade-enter-active,
.fade-leave-active {
transition: all .2s linear;
transform: translate3D(0, 0, 0);
}
.fade-enter,
.fade-leave-active {
transform: translate3D(100%, 0, 0);
}
/* bigimg */
.img-view {
position: relative;
width: 100%;
height: 100%;
}
/*遮罩层样式*/
.img-view .img-layer {
position: fixed;
z-index: 999;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.7);
width: 100%;
height: 100%;
overflow: hidden;
}
/*不限制图片大小,实现居中*/
.img-view .imgBox {
position: absolute;
left: calc(50% - 250px);
top: 100px;
width: 400px;
height: auto;
max-width: 100%;
max-height: 400px;
}
.img-view .imgBox img {
display: block;
width:400px;
height: auto;
max-width: 100%;
max-height: 400px;
margin: auto;
z-index: 1000;
margin-bottom: 10px;
}
.img-view .imgBox .rotateBox {
text-align: center;
}
</style>
使用:
<img src="https://mdn.mozillademos.org/files/12708/image-with-title.png" @click="clickImg($event)" width="100" height="100" style="margin-left: 120px;">
<!-- 放大图片 -->
<big-imgrotate v-if="showImg" @clickit="closeBigImg" :imgSrc="imgSrc"></big-imgrotate>
import BigImg from '@/components/bigImg_rotate/index.vue';
export default {
components: {
'big-imgrotate': BigImg
},
data() {
return {
showImg:false
}
},
methods: {
//点击放大图片
clickImg(e) {
this.showImg = true;
// 获取当前图片地址
this.imgSrc = e.currentTarget.src;
},
//关闭放大图片
closeBigImg(e) {
this.showImg = false;
},
}
}
vue 添加旋转图片 修改css transform 值的更多相关文章
- vue中如何实时修改输入的值
vue中如何实时修改输入的值 经常看到需要对用户输入的值进行实时修改,有时是需要修改为指定的展示内容,有时候是用来校验,禁止用户输入非法数据,总之是一个常见的需求吧,只是自己一直没有特意去关注.思来想 ...
- js 修改css属性值
js不能修改样式表 但是可以修改元素:比如 <div id="test" class="star-rating"></div> 对于上面 ...
- js修改css属性值
推荐用dom.style.setProperty('属性','属性值'); 例如: $("#id")[0].style.setProperty('margin-top','1px' ...
- vue打包后js和css、图片不显示,引用的字体找不到问题
vue打包后js和css.图片不显示,引用的字体找不到问题:图片一般都是背景图片. 一.vue打包出现js和css不显示问题: 1.不使用mode:'history' 2.使用mode:'histor ...
- css代码添加背景图片常用代码
css代码添加背景图片常用代码 1 背景颜色 { font-size: 16px; content: ""; display: block; width: 700px; heigh ...
- CSS transform旋转问题
我们都知道css的transform可以让旋转多少角度:transform:rotate(90deg),但是设置后只能旋转一次,如何想让它一直旋转下去怎么办?一种是使用matrix属性获取当前tran ...
- Sqlserver添加加字段、删除字段、修改字段类型、修改字段名、修改字段默认值
参考:https://www.cnblogs.com/pangpanghuan/p/6432331.html 初始化表: --.添加字段 --1.1.为null alter table DataTab ...
- vue项目中图片预览旋转功能
最近项目中需要在图片预览时,可以旋转图片预览,在网上找了下,发现有一款功能强大的图片组件:viewerjs. git-hup: https://github.com/fengyuanchen/view ...
- VUE项目中使用this.$forceUpdate();解决页面v-for中修改item属性值后页面v-if不改变的问题
VUE项目中使用this.$forceUpdate();解决页面v-for中修改item属性值后页面v-if不改变的问题:https://blog.csdn.net/jerrica/article/d ...
随机推荐
- Python 模块定义、导入、优化详解
一.定义 模块:用来从逻辑上组织 python 代码(变量,函数,类, 逻辑:实现一个功能),本质就是 .py 结尾的 python文件(例如:test.py文件,对应的模块名:test) 包:用来从 ...
- 报文分析5、UDP协议的头结构
UDP协议的头结构 源端口(2字节) 目的端口(2字节) 封报长度(2字节) 校验和(2字节) 数据 (1)源端口(Source Port):16位的源端口域包含初始化通信的端口号.源端口和IP地址的 ...
- en-zh(科学技术)science and technology-2
研究:长期不吃早餐,患心脏病风险增加87% Skipping breakfast could raise risk of heart disease by 87% Skipping breakfast ...
- poj1915
#include<iostream> using namespace std; #define SIZE 305 int vis[SIZE][SIZE]; int sx,sy,ex,ey; ...
- 精心调制的Bash主题分享
第一个是米色背景, 一样遵守蓝色为目录的习惯, 字体为浅灰色,代码和终端看起来相对比较清晰 第二个则是 深海蓝的背景风格,字体都选择饱和度较高的颜色,如下图 终端 配置方法,这里以 mintty 也就 ...
- mysql中的count()函数
1.count()函数是用来统计表中记录的一个函数,返回匹配条件的行数. 2.count()语法: (1)count(*)---包括所有列,返回表中的记录数,相当于统计表的行数,在统计结果的时候,不会 ...
- 2016(4)数据库系统,ER模型,规范化理论,并发控制
试题四(共25分) 阅读以下关于数据库设计的叙述,在答题纸上回答问题1至问题3. 某航空公司要开发一个订票信息处理系统,以方便各个代理商销售机票.开发小组经过设计,给出该系统的部分关系模式如下: 航班 ...
- __add__,关于运算符重载(用户权限)
1.首先定义三种用户类型:普通用户.管理员.超级管理员,不同用户类型的用户权限关系如下: 先看一段代码: class Scope(): # 定义一个基类,因为每个权限类都需要add()方法 allow ...
- python selenium处理windows窗口
selenium本身处理不了windows窗口,需要借助,PyAutoit包 与autoit工具 这里以文件上传窗口为例: 1.安装python pyauto包 pip install PyAutoi ...
- linux----------fedora 27 如何启用输入法
1.安装完成以后是自带了输入法的,但是需要启用. 一定要放到第一个位置,然后注销或者重启.