A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3resource.com/html-css-exercise/css-properties/transform-style-answer.php below:

Website Navigation


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

CSS Properties: How to transformed child elements preserve the 3D transformationsLast update on March 01 2024 13:09:18 (UTC/GMT +8 hours)

Go to Exercise page

Solution:

HTML Code :

<!DOCTYPE html><!-- Declares the document type and version of HTML -->
<html><!-- Begins the HTML document -->
<head><!-- Contains metadata and links to external resources -->
<title>How to transformed child elements preserve the 3D transformations</title><!-- Sets the title of the document -->
<style type="text/css"> /* Starts CSS styling */
#div1 {
    position: relative; /* Sets the positioning context for div1 */
    height: 250px; /* Sets the height of div1 to 250 pixels */
    width: 230px; /* Sets the width of div1 to 230 pixels */
    margin: 100px; /* Sets the margin around div1 */
    padding: 10px; /* Sets the padding inside div1 */
    border: 1px solid #CC0099; /* Sets the border style and color of div1 */
}

#div2 {
    padding: 50px; /* Sets the padding inside div2 */
    position: absolute; /* Positions div2 absolutely within its nearest positioned ancestor */
    border: 1px solid #6633FF; /* Sets the border style and color of div2 */
    background-color: #0000CC; /* Sets the background color of div2 */
    -webkit-transform: rotateY(60deg); /* Applies a Y-axis rotation to div2 for WebKit-based browsers */
    -webkit-transform-style: preserve-3d; /* Preserves the 3D transformations of child elements in WebKit-based browsers */
    transform: rotateY(60deg); /* Applies a Y-axis rotation to div2 for other browsers */
    transform-style: preserve-3d; /* Preserves the 3D transformations of child elements in other browsers */
}

#div3 {
    padding: 50px; /* Sets the padding inside div3 */
    position: absolute; /* Positions div3 absolutely within its nearest positioned ancestor */
    border: 1px solid #FF0000; /* Sets the border style and color of div3 */
    background-color: #33CCFF; /* Sets the background color of div3 */
    -webkit-transform: rotateY(-60deg); /* Applies a Y-axis rotation to div3 for WebKit-based browsers */
    transform: rotateY(-60deg); /* Applies a Y-axis rotation to div3 for other browsers */
}
</style><!-- Ends CSS styling -->
</head><!-- Ends the head section -->
<body><!-- Begins the body of the document -->
<h1><strong>w3resource Tutorial</strong></h1><!-- Displays a level 1 heading with bold text "w3resource Tutorial" -->
<div id="div1"><!-- Starts a div with id "div1" -->
<div id="div2"><strong>w3resource</strong><!-- Starts a div with id "div2" inside div1 -->
	<div id="div3">Web Development Tutorial</div><!-- Starts a div with id "div3" inside div2 -->
</div><!-- Ends div2 -->
</div><!-- Ends div1 -->
</body><!-- Ends the body section -->
</html><!-- Ends the HTML document -->

Explanation:

Live Demo:

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

See the solution in the browser

Supported browser

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4