Created
August 4, 2015 05:01
-
-
Save fancyboynet/d882441ebc4daa9e0d34 to your computer and use it in GitHub Desktop.
[css3]立方体
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | |
<meta name="apple-mobile-web-app-capable" content="yes"/> | |
<meta name="apple-mobile-web-app-status-bar-style" content="black"/> | |
<meta content="telephone=no" name="format-detection"> | |
<title>cube</title> | |
<style> | |
body{ | |
margin: 200px; | |
} | |
@keyframes spin { | |
0%{transform: rotateY(0deg) rotateX(0deg);} | |
50%{transform: rotateY(360deg) rotateX(0deg);} | |
100%{transform: rotateY(360deg) rotateX(360deg);} | |
} | |
.cubeWrap { | |
perspective: 800px; | |
} | |
.cube { | |
position: relative; | |
width: 200px; | |
height: 200px; | |
transform-style: preserve-3d; | |
animation: spin 10s infinite linear; | |
} | |
.cube div { | |
position: absolute; | |
top: 0; | |
left: 0; | |
display: flex; | |
box-sizing: border-box; | |
width: 100%; | |
height: 100%; | |
border:1px solid rgba(100,100,100,.7); | |
background: rgba(100,100,100,.3); | |
align-items: center; | |
justify-content: center; | |
} | |
.cube .front { | |
transform: translateZ(100px); | |
} | |
.cube .back { | |
transform: translateZ(-100px) rotateY(180deg); | |
} | |
.cube .top { | |
transform: translateY(-100px) rotateX(90deg); | |
} | |
.cube .bottom { | |
transform: translateY(100px) rotateX(-90deg); | |
} | |
.cube .left { | |
transform: translateX(-100px) rotateY(-90deg); | |
} | |
.cube .right { | |
transform: translateX(100px) rotateY(90deg); | |
} | |
</style> | |
</head> | |
<body> | |
<div style="background: yellow;text-align: center">上边界</div> | |
<div class="cubeWrap"> | |
<div class="cube"> | |
<div class="front">front</div> | |
<div class="back">back</div> | |
<div class="top">top</div> | |
<div class="bottom">bottom</div> | |
<div class="left">left</div> | |
<div class="right">right</div> | |
</div> | |
</div> | |
<div style="background: yellow;text-align: center">下边界</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment