欢迎来到代码驿站!

JavaScript代码

当前位置:首页 > 网页前端 > JavaScript代码

微信小程序实现点击图片旋转180度并且弹出下拉列表

时间:2021-06-18 08:44:03|栏目:JavaScript代码|点击:

本文为大家分享了微信小程序实现图片旋转、下拉列表的具体代码,供大家参考,具体内容如下

正文:

先上效果图:

index.wxml

<view class="phone_one" bindtap="clickPerson">
 <view class="phone_personal">{{firstPerson}}</view>
 <image src="../../image/v6.png" class="personal_image {{selectArea ? 'rotateRight' :''}}"></image> //三目法判断图片要不要旋转180。
 </view>
 
<view class="person_box">
 <view class="phone_select" hidden="{{selectPerson}}">
  <view bindtap="mySelect">测试1</view>
  <view bindtap="mySelect">测试2</view>
  <view bindtap="mySelect">测试3</view>
 </view>
</view>

index.js

Page({
 data:{
 selectPerson:true,
 firstPerson:'个人',
 selectArea:false,
 },
 //点击选择类型
 clickPerson:function(){
 var selectPerson = this.data.selectPerson;
 if(selectPerson == true){
  this.setData({
  selectArea:true,
  selectPerson:false,
 })
 }else{
  this.setData({
  selectArea:false,
  selectPerson:true,
 })
 }
 } ,
 //点击切换
 mySelect:function(e){
 this.setData({
  firstPerson:e.target.dataset.me,
  selectPerson:true,
  selectArea:false,
 })
 },
}}

index.wxss

.phone_personal{
 width: 100%;
 color:rgb(34, 154, 181);
 height:100rpx;
 line-height:100rpx;
 text-align: center;
}
.phone_one{
 display: flex; //用flex布局更方便。
 position: relative;
 justify-content: space-between;
 background-color:rgb(239, 239, 239);
 width:90%;
 height:100rpx;
 margin:0 auto;
 border-radius: 10rpx;
 border-bottom:2rpx solid rgb(255, 255, 255);
}
.person_box{
 position: relative;
}
.phone_select{
 margin-top:0;
 z-index: 100;
 position: absolute; //小程序中z-index和absolute需要同时存在,元素才能脱离文档。
}
.select_one{
 text-align: center;
 background-color:rgb(239, 239, 239);
 width:676rpx; //脱离文档后元素width不能再用百分比。
 height:100rpx;
 line-height:100rpx;
 margin:0 5%;
 border-bottom:2rpx solid rgb(255, 255, 255);
}
.personal_image{
 z-index: 100;
 position: absolute;
 right:2.5%;
 width: 34rpx;
 height: 20rpx;
 margin:40rpx 20rpx 40rpx 0;
 transition: All 0.4s ease; 
 -webkit-transition: All 0.4s ease;
}
.rotateRight{
 transform: rotate(180deg); //180°旋转图片。
}

上一篇:微信小程序实现翻牌抽奖动画

栏    目:JavaScript代码

下一篇:让div层随鼠标移动的实现代码 ie ff

本文标题:微信小程序实现点击图片旋转180度并且弹出下拉列表

本文地址:http://www.codeinn.net/misctech/143789.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有