css3之transform-style 3D旋转效果

//运行看效果

<!DOCTYPE html>

<html lang="en">
<head>
  <meta charset="utf-8" />

  <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame 
       Remove this if you use the .htaccess -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

  <title>3D旋转效果</title>
  <meta name="description" content="" />
  <meta name="author" content="Administrator" />
  <meta name="viewport" content="width=device-width; initial-scale=1.0" />

  <!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
  <link rel="shortcut icon" href="/favicon.ico" />
  <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
  <style type="text/css">
  *{font-size: 14px;color: #fff; padding:0; margin:0;}
  #container {
position: relative;
height: 300px;
width: 300px;
-webkit-perspective: 500;/*角度*/
margin-top: 200px;
margin-right: auto;
margin-left: auto;
  }
  
  #parent {
margin: 10px;
width: 280px;
height: 280px;
background-color: gray;
opacity: 0.8;
-webkit-transform-style: preserve-3d;
-webkit-animation: spin 5s infinite linear;
}
  #parent > div {
position: absolute;
top: 40px;
left: 40px;
width: 280px;
height: 200px;
padding: 10px;
-webkit-box-sizing: border-box;
}

#parent > :first-child {
background-color: #000;
-webkit-transform: translateZ(-100px) rotateY(45deg);
}
#parent > :last-child {
background-color: #333;
-webkit-transform: translateZ(50px) rotateX(20deg);
-webkit-transform-origin: 50% top;
}

/*执行y轴旋转*/

  @-webkit-keyframes spin {
from {-webkit-transform: rotateY(0);}
to {-webkit-transform: rotateY(360deg);}
}
 
  </style>
</head>
<body>
  <div>
    <header>
      <h1>transform-style的3D效果测试</h1>
    </header>
<div>
<div id="container">
<div id="parent">
<div>3D旋转效果</div>
<div>3D3D3D3D3D</div>
</div>
</div>
</div>
    <footer>
    </footer>
  </div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值