{"id":6033,"date":"2013-03-02T02:16:00","date_gmt":"2013-03-02T02:16:00","guid":{"rendered":"https:\/\/www.htmlgoodies.com\/uncategorized\/learn-css3-from-a-z-3d-transformations\/"},"modified":"2021-04-27T23:11:13","modified_gmt":"2021-04-27T23:11:13","slug":"css-3d-transform","status":"publish","type":"post","link":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/","title":{"rendered":"CSS Transform 3D: Three Dimensional Transitions"},"content":{"rendered":"

Introduction<\/strong><\/p>\n

Even though CSS3 is not supported on all browsers yet, many web developer have started to use some of the techniques that it provides. CSS3 has evolved into a technology which, when combined with HTML5 and JavaScript, may end up being a Flash-killer. In this series of articles, we will cover the key additions to CSS3. In the previous article<\/a>, we learned about 2D transformations in CSS3; and today we will take it to the next level and explore 3D transformations.<\/p>\n

CSS3 Transforms<\/strong><\/p>\n

While 2D transforms are a cool feature to have, they don’t really provide much enhancement for us web folks. At best, they save us from writing a few lines of Javascript; but they don’t really provide a new experience for the user. Fortunately we can’t say the same for 3D transforms. 3D transforms allow us web developers to render objects on the page that appear to be 3 dimensional. Flash, your days are now numbered!<\/p>\n

Browser support is always a concern in all our minds. Just as 2D transforms, 3D transforms were also pioneered by Apple and so Safari on the desktop as well as mobile (Mobile Safari for iOS) fully support it. Safari’s Webkit cousin, Chrome started to support it a while ago and so did Mozilla and Opera.<\/p>\n

Perspective<\/strong><\/p>\n

Perspective is the probably the most important concept and property in CSS when it comes to the 3D space. When the human eye sees a scene, objects in the distance appear smaller than those close by – this is known as perspective. In order to represent 3D imagery in 2D, the trick used is to make parallel lines that go away from the user merge towards a point, known as the vanishing point. The lines that are actually not parallel give the user a sense of depth.<\/p>\n

In CSS3, there are two ways to set the perspective of elements. Setting it with the perspective property sets it for the element in question as well as its children. Setting it as an attribute of the transform property will set it only for that specific transformation. Here is an example of both methods.<\/p>\n

\n
\"ss_perspective.png\"
Perspective<\/div>\n<\/div>\n

\"ss_transform.png\"<\/p>\n

The code for the above is as follows:<\/p>\n

.container {
width: 150px;
height: 150px;
perspective: 600px;
}<\/p>\n

#rotate-x .panel { transform: rotateX( 45deg ); }
#rotate-y .panel { transform: rotateY( 45deg ); }
#rotate-z .panel { transform: rotateZ( 45deg ); }<\/p>\n

#translate-x .panel { transform: translateX(30px); }
#translate-y .panel { transform: translateY(30px); }
#translate-z .panel { transform: translateZ(50px); }<\/div>\n

Note: In both the code samples above, I have only specified the main transform or perspective property to keep the code readable. In a real implementation, you will need to add the browser specific properties too (-webkit-transform, etc). You can get them by clicking on the working examples and viewing the source.<\/p>\n

Conclusion<\/strong><\/p>\n

Three dimensional transitions are definitely a game changer and give us, web developers, a glimpse of a better world with the capability of doing smooth animations without resorting to Flash. In this article, I covered the transform properties. By themselves they can’t serve much, but when we are start to transform the elements around using the transition properties, then the fun begins.<\/p>\n","protected":false},"excerpt":{"rendered":"

Introduction Even though CSS3 is not supported on all browsers yet, many web developer have started to use some of the techniques that it provides. CSS3 has evolved into a technology which, when combined with HTML5 and JavaScript, may end up being a Flash-killer. In this series of articles, we will cover the key additions […]<\/p>\n","protected":false},"author":20,"featured_media":3299,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[33771,30683,30618],"tags":[6285,30667,2003],"b2b_audience":[29],"b2b_industry":[52],"b2b_product":[68,136],"acf":[],"yoast_head":"\nCSS Transform 3D | Three Dimensional Transitions | HTML Goodies<\/title>\n<meta name=\"description\" content=\"3D Transform allows web developers to render objects on a page 3 dimensional. Discover how to use 3D Transform. Click here now.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS Transform 3D | Three Dimensional Transitions | HTML Goodies\" \/>\n<meta property=\"og:description\" content=\"3D Transform allows web developers to render objects on a page 3 dimensional. Discover how to use 3D Transform. Click here now.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/\" \/>\n<meta property=\"og:site_name\" content=\"HTML Goodies\" \/>\n<meta property=\"article:published_time\" content=\"2013-03-02T02:16:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-27T23:11:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/04\/image22.png\" \/>\n\t<meta property=\"og:image:width\" content=\"250\" \/>\n\t<meta property=\"og:image:height\" content=\"165\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@htmlgoodies\" \/>\n<meta name=\"twitter:site\" content=\"@htmlgoodies\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Arpan Dhandhania\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.htmlgoodies.com\/#organization\",\"name\":\"HTML Goodies\",\"url\":\"https:\/\/www.htmlgoodies.com\/\",\"sameAs\":[\"https:\/\/twitter.com\/htmlgoodies\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.htmlgoodies.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/03\/HTMLg_weblogo_MobileLogo.png\",\"contentUrl\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/03\/HTMLg_weblogo_MobileLogo.png\",\"width\":584,\"height\":136,\"caption\":\"HTML Goodies\"},\"image\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.htmlgoodies.com\/#website\",\"url\":\"https:\/\/www.htmlgoodies.com\/\",\"name\":\"HTML Goodies\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.htmlgoodies.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#primaryimage\",\"url\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/04\/image22.png\",\"contentUrl\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/04\/image22.png\",\"width\":250,\"height\":165},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#webpage\",\"url\":\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/\",\"name\":\"CSS Transform 3D | Three Dimensional Transitions | HTML Goodies\",\"isPartOf\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#primaryimage\"},\"datePublished\":\"2013-03-02T02:16:00+00:00\",\"dateModified\":\"2021-04-27T23:11:13+00:00\",\"description\":\"3D Transform allows web developers to render objects on a page 3 dimensional. Discover how to use 3D Transform. Click here now.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.htmlgoodies.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS Transform 3D: Three Dimensional Transitions\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/69376a4ea41efeb4ac2f9ba60c8d1614\"},\"headline\":\"CSS Transform 3D: Three Dimensional Transitions\",\"datePublished\":\"2013-03-02T02:16:00+00:00\",\"dateModified\":\"2021-04-27T23:11:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#webpage\"},\"wordCount\":522,\"publisher\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/04\/image22.png\",\"keywords\":[\"3D\",\"CSS3\",\"HTML5\"],\"articleSection\":[\"Design\",\"Guides\",\"HTML5\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/69376a4ea41efeb4ac2f9ba60c8d1614\",\"name\":\"Arpan Dhandhania\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4d3c6d36d470ece508945a096f80e5c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4d3c6d36d470ece508945a096f80e5c8?s=96&d=mm&r=g\",\"caption\":\"Arpan Dhandhania\"},\"url\":\"https:\/\/www.htmlgoodies.com\/author\/arpan-dhandhania\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CSS Transform 3D | Three Dimensional Transitions | HTML Goodies","description":"3D Transform allows web developers to render objects on a page 3 dimensional. Discover how to use 3D Transform. Click here now.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/","og_locale":"en_US","og_type":"article","og_title":"CSS Transform 3D | Three Dimensional Transitions | HTML Goodies","og_description":"3D Transform allows web developers to render objects on a page 3 dimensional. Discover how to use 3D Transform. Click here now.","og_url":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/","og_site_name":"HTML Goodies","article_published_time":"2013-03-02T02:16:00+00:00","article_modified_time":"2021-04-27T23:11:13+00:00","og_image":[{"width":250,"height":165,"url":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/04\/image22.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_creator":"@htmlgoodies","twitter_site":"@htmlgoodies","twitter_misc":{"Written by":"Arpan Dhandhania","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/www.htmlgoodies.com\/#organization","name":"HTML Goodies","url":"https:\/\/www.htmlgoodies.com\/","sameAs":["https:\/\/twitter.com\/htmlgoodies"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.htmlgoodies.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/03\/HTMLg_weblogo_MobileLogo.png","contentUrl":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/03\/HTMLg_weblogo_MobileLogo.png","width":584,"height":136,"caption":"HTML Goodies"},"image":{"@id":"https:\/\/www.htmlgoodies.com\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/www.htmlgoodies.com\/#website","url":"https:\/\/www.htmlgoodies.com\/","name":"HTML Goodies","description":"","publisher":{"@id":"https:\/\/www.htmlgoodies.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.htmlgoodies.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#primaryimage","url":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/04\/image22.png","contentUrl":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/04\/image22.png","width":250,"height":165},{"@type":"WebPage","@id":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#webpage","url":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/","name":"CSS Transform 3D | Three Dimensional Transitions | HTML Goodies","isPartOf":{"@id":"https:\/\/www.htmlgoodies.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#primaryimage"},"datePublished":"2013-03-02T02:16:00+00:00","dateModified":"2021-04-27T23:11:13+00:00","description":"3D Transform allows web developers to render objects on a page 3 dimensional. Discover how to use 3D Transform. Click here now.","breadcrumb":{"@id":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.htmlgoodies.com\/"},{"@type":"ListItem","position":2,"name":"CSS Transform 3D: Three Dimensional Transitions"}]},{"@type":"Article","@id":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#article","isPartOf":{"@id":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#webpage"},"author":{"@id":"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/69376a4ea41efeb4ac2f9ba60c8d1614"},"headline":"CSS Transform 3D: Three Dimensional Transitions","datePublished":"2013-03-02T02:16:00+00:00","dateModified":"2021-04-27T23:11:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#webpage"},"wordCount":522,"publisher":{"@id":"https:\/\/www.htmlgoodies.com\/#organization"},"image":{"@id":"https:\/\/www.htmlgoodies.com\/html5\/css-3d-transform\/#primaryimage"},"thumbnailUrl":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/04\/image22.png","keywords":["3D","CSS3","HTML5"],"articleSection":["Design","Guides","HTML5"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/69376a4ea41efeb4ac2f9ba60c8d1614","name":"Arpan Dhandhania","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4d3c6d36d470ece508945a096f80e5c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d3c6d36d470ece508945a096f80e5c8?s=96&d=mm&r=g","caption":"Arpan Dhandhania"},"url":"https:\/\/www.htmlgoodies.com\/author\/arpan-dhandhania\/"}]}},"_links":{"self":[{"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/posts\/6033"}],"collection":[{"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/comments?post=6033"}],"version-history":[{"count":0,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/posts\/6033\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/media\/3299"}],"wp:attachment":[{"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/media?parent=6033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/categories?post=6033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/tags?post=6033"},{"taxonomy":"b2b_audience","embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/b2b_audience?post=6033"},{"taxonomy":"b2b_industry","embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/b2b_industry?post=6033"},{"taxonomy":"b2b_product","embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/b2b_product?post=6033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}