CSS3 3D Transformation
3D Transformation
CSS3 allows you to use 3D transformations to format elements.
In this chapter, you will learn some of these 3D transformation methods:
rotateX()
rotateY()
How does it work?
Transformation is an effect that causes an element to change its shape, size, and position.
You can transform your elements using 2D or 3D transformations.
rotateX() method
rotateX() method rotates an element around its X-axis at a given degree.
rotateY() method
rotateY() method rotates an element around its Y-axis in a given degree.
new file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3D旋转的Demo</title>
<style>
#experiment {
-webkit-perspective: 800;
-webkit-perspective-origin: 50% 50%;
-webkit-transform-style: -webkit-preserve-3d;
}
#block {
width: 200px;
height: 200px;
background-color: pink;
margin: 100px auto;
-webkit-transition: background-color 3s;
}
#block:hover {
background-color: purple;
}
#ep {
text-align: center;
}
#ep input {
width: 800px;
}
</style>
<script>
function rotate() {
var x = document.getElementById("rotateX").value;
var y = document.getElementById("rotateY").value;
var z = document.getElementById("rotateZ").value;
document.getElementById("block").style.webkitTransform = "rotateX(" + x + "deg) rotateY(" + y + "deg) rotateZ(" + z + "deg)";
document.getElementById("degx-span").innerText = x;
document.getElementById("degy-span").innerText = y;
document.getElementById("degz-span").innerText = z;
}
</script>
</head>
<body>
<div id="experiment">
<div id="block"></div>
</div>
<div id="ep">
<p>rotate x: <span id="degx-span">0</span>deg</p>
<input type="range" min="-360" max="360" id="rotateX" value="0" class="range-control" onmousemove="rotate()"/><br/>
<p>rotate y: <span id="degy-span">0</span>deg</p>
<input type="range" min="-360" max="360" id="rotateY" value="0" class="range-control" onmousemove="rotate()"/><br/>
<p>rotate z: <span id="degz-span">0</span>deg</p>
<input type="range" min="-360" max="360" id="rotateZ" value="0" class="range-control" onmousemove="rotate()"/><br/>
</div>
</body>
</html>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















