w3resource

CSS Properties: How to transformed child elements preserve the 3D transformations

Go to Exercise page

Solution:

HTML Code :

 <!DOCTYPE html>
  <html>
  <head>
  <title>How to transformed child elements preserve the 3D transformations</title>
  <style type="text/css">
  #div1 {
    position: relative;
    height: 250px;
    width: 230px;
    margin: 100px;
    padding: 10px;
    border: 1px solid #CC0099;
}

#div2 {
    padding: 50px;
    position: absolute;
    border: 1px solid #6633FF;
    background-color: #0000CC;
    -webkit-transform: rotateY(60deg);
    -webkit-transform-style: preserve-3d;
    transform: rotateY(60deg);
    transform-style: preserve-3d;
}

#div3 {
    padding: 50px;
    position: absolute;
    border: 1px solid #FF0000;
    background-color: #33CCFF;
    -webkit-transform: rotateY(-60deg);
    transform: rotateY(-60deg);

}
  </style>
  </head>
  <body>
  <h1><strong>w3resource Tutorial</strong></h1>
    <div id="div1">
  <div id="div2"><strong>w3resource</strong>
  	<div id="div3">Web Development Tutorial</div>
  </div>
</div>  
  </body>
  </html>

Live Demo:

See the Pen transform-style-answer by w3resource (@w3resource) on CodePen.


See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
YesYesYesYesYes

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.