Heim  >  Artikel  >  Web-Frontend  >  3D-Konvertierungsmodul in HTML und CSS

3D-Konvertierungsmodul in HTML und CSS

php中世界最好的语言
php中世界最好的语言Original
2018-03-13 11:45:401570Durchsuche

Dieses Mal stelle ich Ihnen das 3D-Konvertierungsmodul in HTML und CSS vor. Was sind die Vorsichtsmaßnahmen bei der Verwendung des 3D-Konvertierungsmoduls in HTML und CSS?

Die img-Tags im Artikel![](images/jacky/xin.png) wurden alle in das Macdown-Format geändert

1. Was sind 2D und 3D

1. Was 2D und 3D ist

2D ist eine Ebene mit nur Breite und Höhe und keiner Dicke
3D ist ein dreidimensionaler Körper mit Breite, Höhe und Dicke
Standardmäßig ist Alle Elemente werden in 2D angezeigt

2. So lassen Sie ein Element in 3D erscheinen

Dasselbe wie bei der Perspektive: Wenn Sie den 3D-Effekt eines Elements sehen möchten, müssen Sie nur ein hinzufügen transformieren Sie es in sein übergeordnetes Element-Stilattribut und setzen Sie es dann auf „preserve-3d“

3. 3d: 3D-Effekt;


2. Würfel (mit Mängeln, es liegt ein Problem mit der Seitentextanzeige vor)

<html lang="en"> <head>     <meta charset="UTF-8">     <title>106-3D转换模块</title>     <style>
         *{             margin: 0;             padding: 0;         }         
         .father{             width: 200px;             height: 200px;             
         background-color: red;             border: 1px solid #000;             margin: 100px auto;
                      perspective: 500px;             transform-style: preserve-3d; 
                      transform: rotateY(0deg); 
                               }         .son{             width: 100px;             height: 100px;             background-color: blue;             border: 1px solid #000;             margin: 0 auto;             margin-top: 50px;             transform: rotateY(45deg);         }     </style> </head> <body> <p class="father">     <p class="son"></p> </p> </body> </html>

<html lang="en"> <head>     <meta charset="UTF-8">     <title>107-3D转换模块-正方体</title>     <style>     *{         margin: 0;         padding: 0;     }     ul{         width: 200px;         height: 200px;         border: 1px solid #000;         box-sizing: border-box;         margin: 100px auto;         position: relative;         transform: rotateY(0deg) rotateX(0deg);         transform-style: preserve-3d;     }     ul li{         list-style: none;         width: 200px;         height: 200px;         font-size: 60px;         text-align: center;         line-height: 200px;         position: absolute;         left: 0;         top: 0;     }     ul li:nth-child(1){         background-color: red;         transform: translateX(-100px) rotateY(90deg);     }     ul li:nth-child(2){         background-color: green;         transform: translateX(100px) rotateY(90deg);     }     ul li:nth-child(3){         background-color: blue;         transform: translateY(-100px) rotateX(90deg);     }     ul li:nth-child(4){         background-color: yellow;         transform: translateY(100px) rotateX(90deg);     }     ul li:nth-child(5){         background-color: purple;         transform: translateZ(-100px);     }     ul li:nth-child(6){         background-color: pink;         transform: translateZ(100px);     } </style> </head> <body> <ul>     <li>1</li>     <li>2</li>     <li>3</li>     <li>4</li>     <li>5</li>     <li>6</li> </ul> </body> </html>

Würfel (mit Mängeln, nur zum Verständnis) )3D-Konvertierungsmodul in HTML und CSS

3. Würfel (ultimative Lösung)

Nach der Drehung um 90 Grad dreht sich das Koordinatensystem auch um 90 Grad, sodass es sich entlang der drehen sollte z-Achse;

Stereo-Effekt-Strategie: Zuerst um einen bestimmten Grad drehen, dann entlang der Z-Achse verschieben

<html lang="en"> <head>     <meta charset="UTF-8">     <title>108-3D转换模块-正方体终极</title>     <style>         *{             margin: 0;             padding: 0;         }         ul{             width: 200px;             height: 200px;             border: 1px solid #000;             box-sizing: border-box;             margin: 100px auto;             position: relative;             transform: rotateY(0deg) rotateX(0deg);             transform-style: preserve-3d;         }         ul li{             list-style: none;             width: 200px;             height: 200px;             font-size: 60px;             text-align: center;             line-height: 200px;             position: absolute;             left: 0;             top: 0;         }        
ul li:nth-child(1){             background-color: red;             transform: rotateX(90deg) translateZ(100px);                    }         
ul li:nth-child(2){             background-color: green;             transform: rotateX(180deg) translateZ(100px);         }         ul li:nth-child(3){             background-color: blue;             transform: rotateX(270deg) translateZ(100px);         }         ul li:nth-child(4){             background-color: yellow;             transform: rotateX(360deg) translateZ(100px);         }         ul li:nth-child(5){             background-color: purple;             transform: translateX(-100px) rotateY(90deg);         }         ul li:nth-child(6){             background-color: pink;             transform: translateX(100px) rotateY(90deg);         }     </style> </head> <body> <ul>     <li>1</li>     <li>2</li>     <li>3</li>     <li>4</li>     <li>5</li>     <li>6</li> </ul> </body> </html>



3D-Konvertierungsmodul in HTML und CSS Ich glaube, Sie haben den Fall in diesem Artikel gelesen. Nachdem Sie die Methode gemeistert haben, achten Sie bitte auf andere verwandte Artikel auf der chinesischen PHP-Website, um weitere spannende Inhalte zu erhalten!

Empfohlene Lektüre:

Übergangsmodul in HTML und CSS


2D-Konvertierungsmodul in HTML und CSS

Das obige ist der detaillierte Inhalt von3D-Konvertierungsmodul in HTML und CSS. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn