css+沿正方形旋转,CSS3 rotateZ 沿边缘旋转

1

改变rotateZ的正负值,可改变旋转是逆时针还是顺时针。

但是发现上面的b中的文字也会跟着转起来。。。。那有没有法子让b中的内容不跟着一起转动呢?

经测试,可再加入下面的CSS即可,原理就是相对于a转动方向,设置b的方向相反就出现了想要的效果了。.b {

background-color: #00F;

height: 40px;

width: 40px;

border-radius:50%;

position: absolute;

left: 10px;

top:10px;

font-size: 24px;

line-height: 40px;

color: #FFF;

font-family: "微软雅黑";

text-align: center;

-webkit-animation:b 16s linear 0s infinite;animation:b 16s linear 0s infinite;

}

@keyframes b {0%{transform:rotateZ(45deg)} 100%{transform:rotateZ(-315deg)}}

继续阅读:CSS3

原创文章请注明转载自霍者博客本文地址:http://www.huozheweb.com/post/247.html,标题:CSS3 rotateZ 沿边缘旋转

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一段HTML5和CSS3制作的3D旋转爱心粒子代码,你可以将其复制到HTML文件中并在浏览器中查看效果: ```html <!DOCTYPE html> <html> <head> <title>3D旋转爱心粒子代码</title> <style> body { background-color: #000; overflow: hidden; } .heart { position: absolute; top: 50%; left: 50%; transform-style: preserve-3d; animation: rotate 10s linear infinite; } .heart .heart-piece { position: absolute; width: 100px; height: 100px; background-color: #f00; border-radius: 50%; transform-style: preserve-3d; animation: rotate 10s linear infinite; } .heart .heart-piece:before, .heart .heart-piece:after { content: ""; position: absolute; width: 100px; height: 100px; background-color: #f00; border-radius: 50%; transform-style: preserve-3d; animation: rotate 10s linear infinite; } .heart .heart-piece:before { transform: rotateY(90deg) rotateZ(45deg); } .heart .heart-piece:after { transform: rotateY(90deg) rotateZ(-45deg); } .heart .heart-piece:nth-child(1) { transform: rotateY(0deg) translateZ(50px); } .heart .heart-piece:nth-child(2) { transform: rotateY(90deg) translateZ(50px); } .heart .heart-piece:nth-child(3) { transform: rotateY(180deg) translateZ(50px); } .heart .heart-piece:nth-child(4) { transform: rotateY(-90deg) translateZ(50px); } @keyframes rotate { from { transform: rotateY(0deg); } to { transform: rotateY(360deg); } } </style> </head> <body> <div class="heart"> <div class="heart-piece"></div> <div class="heart-piece"></div> <div class="heart-piece"></div> <div class="heart-piece"></div> </div> </body> </html> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值