用html標簽+css寫出旋轉的正方體


有一段時間沒寫代碼了,剛寫有點手生,無從下手,為了能快速進入狀態,就寫了這一個小東西,純用標簽和樣式表寫。下面看一下我寫的。

這一段是樣式表:

  <style>
        *{
            margin: 0;
            padding: 0;
        }
        ul,li{
            list-style: none;
        }
        ul{
            position: relative;
            top: 200px;
            left: 200px;
            width: 200px;
            height: 200px;
            transform-style: preserve-3d;
            transition: all 5s;
       transform:rotateX(-45deg) rotateY(-45deg);
} ul:hover{ transform: rotateX(360deg) rotateY(360deg); } li{ position: absolute; width: 200px; height: 200px; border-radius: 20px; background-color: #222; } li:nth-child(1){ transform: translateZ(100px); background-color: red; } li:nth-child(2){ background-color: green; transform: translateZ(-100px); } li:nth-child(3){ background-color: silver; transform: rotateY(90deg) translateZ(-100px); } li:nth-child(4){ background-color: pink; transform: rotateY(90deg) translateZ(100px); } li:nth-child(5){ background-color: brown; transform: rotateX(90deg) translateZ(-100px); } li:nth-child(6){ background-color: yellow; transform: rotateX(90deg) translateZ(100px); } </style>

這一段是HTML:

  <ul>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>

對於這種毫無技術含量的,實在沒臉。看一下效果:

鼠標放在上面就會旋轉,感興趣的可以試一下,覺得low的多提意見,臉皮厚。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM