Introduction to the use of CSS3 3D rotation rotate effect

不言
Release: 2018-06-25 16:07:41
Original
2495 people have browsed it

This article mainly introduces CSS3 3D rotation rotate effect examples in detail. It has certain reference value. Interested friends can refer to it.

The examples in this article share CSS3 3D rotation rotate effect with everyone. Effect examples are for your reference. The specific contents are as follows

Effect pictures:

Example code

<!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>
    <p id="experiment">
        <p id="block"></p>
    </p>
    <p 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/>
    </p>
</body>
</html>
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

CSS3 realizes the effect of background transparent text opaque

realization of linear color gradient in CSS3

The above is the detailed content of Introduction to the use of CSS3 3D rotation rotate effect. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!