微信小程序样式旋转

时间:2022-09-13 11:52:36

相关文档:http://www.w3school.com.cn/cssref/pr_transform.asp

index.wxss文件

注意:如果是web前端,要注意浏览器的兼容性


.x1{
width: 46rpx;//元素的宽
height: 40rpx;//元素的高
top: 82rpx;//元素距离顶部的距离
left:315rpx;//元素距离左边的距离
transform-origin:50% 50%;//设置元素旋转的基本点
position: absolute;
transform: rotate(30deg);//30是元素旋转的度数
}
.x2{
width: 46rpx;
height: 40rpx;
top: 130rpx;
left:365rpx;
transform-origin:50% 50%;
position: absolute;
transform: rotate(60deg);
}
.x3{
width: 46rpx;
height: 40rpx;
top: 190rpx;
left:384rpx;
transform-origin:50% 50%;
position: absolute;
transform: rotate(90deg);
}
.x4{
width: 46rpx;
height: 40rpx;
top: 259rpx;
left:365rpx;
transform-origin:50% 50%;
position: absolute;
transform: rotate(120deg);
}
.x5{
width: 46rpx;
height: 40rpx;
top: 308rpx;
left:315rpx;
transform-origin:50% 50%;
position: absolute;
transform: rotate(150deg);
}
.x6{
width: 46rpx;
height: 40rpx;
top: 321rpx;
left:256rpx;
transform-origin:50% 50%;
position: absolute;
transform: rotate(180deg);
}
.x7{
width: 46rpx;
height: 40rpx;
top: 308rpx;
left:198rpx;
transform-origin:50% 50%;
position: absolute;
transform: rotate(210deg);
}
.x8{
width: 46rpx;
height: 40rpx;
top: 259rpx;
left:147rpx;
transform-origin:50% 50%;
position: absolute;
transform: rotate(240deg);
}
.x9{
width: 46rpx;
height: 40rpx;
top: 190rpx;
left:129rpx;
transform-origin:50% 50%;
position: absolute;
transform: rotate(270deg);
}
.x10{
width: 46rpx;
height: 40rpx;
top: 130rpx;
left:147rpx;
transform-origin:50% 50%;
position: absolute;
transform: rotate(300deg);
}
.x11{
width: 46rpx;
height: 40rpx;
top: 82rpx;
left:188rpx;
transform-origin:50% 50%;
position: absolute;
transform: rotate(330deg);
} .viewblockzzround{
position: absolute;
height: 245rpx;
width: 246rpx;
top: 120rpx;
left: 156rpx
}
.blockzzround{
width:100%;
height:100%;
}

index.wxml文件

<view class='viewblockzzround'>
<image src='https://api.longfengqi.net.cn/little/zzround.png' class='blockzzround'></image>
</view>
 
<image src='/image/src/redchair.png' class='x0' ></image>
 
<image src='/image/src/redchair.png' class='x1'></image>
 
<image src='/image/src/redchair.png' class='x2'></image>
 
<image src='/image/src/redchair.png' class='x3'></image>
 
<image src='/image/src/redchair.png' class='x4'></image>
 
<image src='/image/src/redchair.png' class='x5'></image>
 
<image src='/image/src/redchair.png' class='x6'></image>
 
<image src='/image/src/redchair.png' class='x7'></image>
 
<image src='/image/src/redchair.png' class='x8'></image>
 
<image src='/image/src/redchair.png' class='x9'></image>
 
<image src='/image/src/redchair.png' class='x10'></image>
 
<image src='/image/src/redchair.png' class='x11'></image>
 

最终效果图:

  微信小程序样式旋转