[英]Issue in transform property in CSS
I am trying to rotate a div which is inside another div. 我正在尝试旋转另一个div内的div。 whats wrong with my code.I come across with another method(:before child) but whats wrong with this methods?
我的代码出了什么问题我遇到了另一个方法(:before child),但是这种方法有什么问题? Thanks
谢谢
body { background: #ccc } .box { width: 70%; height: 200px; background: #FFF; margin: 40px auto; } .effect2 { position: relative; } .box1 { transform: rotate3d; position: absolute; width: 20%; height: 20px; background-color: aqua; }
<div class="box effect2"> <div class="box1"></div> </div>
body { background: #ccc } .box { width: 70%; height: 200px; background: #FFF; margin: 40px auto; } .effect2 { position: relative; } .box1{ transition: 1.5s; position: absolute; width: 20%; height: 20px; background-color: aqua; } .box1:hover{ transform: rotate3d(1,-1, 1,60deg); }
<div class="box effect2"> <div class="box1"></div> </div>
rotate3d, where supported, needs parameters, example: 如果支持,rotate3d需要参数,例如:
transform: rotate3d(1, 2.0, 3.0, 10deg)
body { background: #ccc } .box { width: 70%; height: 200px; background: #FFF; margin: 40px auto; } .effect2 { position: relative; } .box1 { transform: rotate3d(1,2.0,3.0,90deg); position: absolute; width: 20%; height: 20px; background-color: aqua; }
<div class="box effect2"> <div class="box1"></div> </div>
Give x,y or z to rotate and add the value 给x,y或z旋转并添加值
body { background: #ccc } .box { width: 70%; height: 200px; background: #FFF; margin: 40px auto; } .effect2 { position: relative; } .box1 { transform: rotateZ(45deg); position: absolute; width: 20%; height: 20px; background-color: aqua; }
<div class="box effect2"> <div class="box1"></div> </div>
Here are some posible values 这是一些可能的值
transform: rotate3d(1, 2.0, 3.0, 10deg)
transform: rotateX(10deg)
transform: rotateY(10deg)
transform: rotateZ(10deg)
You need to adapt to different browsers. 您需要适应不同的浏览器。
.class {
-webkit-transform:rotate(deg);
-moz-transform:rotate(deg);
-o-transform:rotate(deg);
transform:rotate(deg);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.