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 ...
随机推荐
- robot 中文 乱码 问题 的处理
第一种方式: def unic(item): if isinstance(item, unicode): return item if isinstance(item, (bytes, ...
- 复制pdf文字出来是乱码
PDF文件复制文本为乱码 - longzhinuhou的博客 - CSDN博客 https://blog.csdn.net/longzhinuhou/article/details/83758966 ...
- keras,tensorflow,numpy,jupyter
docker-tensorflow:https://segmentfault.com/a/1190000015053704 pip install scipy pip install keras do ...
- SQL的几种连接:内连接、外连接(左连接、右连接、全连接)
表结构见前面博客 1.内连接 1.1.等值连接:在连接条件中使用等于号(=)运算符比较被连接列的列值,其查询结果中列出被连接表中的所有列,包括其中的重复列. 三种写法: select * from t ...
- table-一列细分为多列(合并单元格)
这个是一个很常见的一个表格展示需求,其中最要的就两个属性 rowspan 和 colspan .他们分别就是合并行 与 合并列. 要做的效果是如图下面这个,联系电话就是合并了单元格.这个说法类似于ex ...
- C++ opencv调用resize修改插值方式遇到的坑
opencv提供的热死则函数原型如下:void resize(InputArray src, OutputArray dst, Size dsize, double fx=0, double fy=0 ...
- ACM练习中关于LCS的题目
You are planning to take some rest and to go out on vacation, but you really don’t know which cities ...
- php java aes
class CryptAES{ protected $cipher = MCRYPT_RIJNDAEL_128; protected $mode = MCRYPT_MODE_ECB; protecte ...
- mysql语句,插入id随机生成
insert into 表名 VALUES(uuid(),…) 还有一个uuid_short(),只有数字 insert into 表名 VALUES(uuid_short(),…)
- tar打包
进入到目录里,执行下面的命令,可以把目录内的所有内容打包 tar -cvf 111.tar *