<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Inspect Element &#187; 3d</title>
	<atom:link href="http://inspectelement.com/tag/3d/feed/" rel="self" type="application/rss+xml" />
	<link>http://inspectelement.com</link>
	<description>Web Design &#38; Development Blog</description>
	<lastBuildDate>Wed, 25 Jan 2012 09:55:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Create a CSS3 Image Gallery with a 3D Lightbox Animation</title>
		<link>http://inspectelement.com/articles/create-a-css3-image-gallery-with-a-3d-lightbox-animation/</link>
		<comments>http://inspectelement.com/articles/create-a-css3-image-gallery-with-a-3d-lightbox-animation/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 13:20:13 +0000</pubDate>
		<dc:creator>Tom Kenny</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://inspectelement.com/?p=7617</guid>
		<description><![CDATA[For the most part, the CSS3 tutorials and examples out there are a little dull. Of course there are some really great examples out there such as Benjamin de Cock&#8217;s CSS Playground but most others consist of a drop-shadow here and a few rounded corners there and nothing more. It&#8217;s time to start doing something [...]]]></description>
			<content:encoded><![CDATA[<p>For the most part, the CSS3 tutorials and examples out there are a little dull. Of course there are some really great examples out there such as <a href="http://playground.deaxon.com/css/">Benjamin de Cock&#8217;s CSS Playground</a> but most others consist of a drop-shadow here and a few rounded corners there and nothing more. It&#8217;s time to start doing something more inspirational and useful at the same time.</p>
<p><img class="alignnone size-full wp-image-7637" title="3dgallery" src="http://inspectelement.com/wp-content/uploads/2011/04/3dgallery.jpg" alt="" width="645" height="452" /><br />
<span id="more-7617"></span></p>
<p>Having been inspired to get &#8216;<a href="http://hardboiledwebdesign.com/">Hardboiled</a>&#8216;, I&#8217;ve started playing around with a few cool techniques and exploring how to make the content accessible in less capable browsers while giving the best possible experiences to the ones that support the latest advancements in CSS. I&#8217;ve taken Benjamin&#8217;s CSS lightbox gallery and built upon by adding a few hover effects for the gallery grid itself and a 3D rotation for the lightbox content, all with the use of CSS.</p>
<p><a href="http://inspectelement.com/demos/css3/3dgallery/">View Demo</a></p>
<p><a href="http://inspectelement.com/demos/css3/3dgallery/"><img class="alignnone size-full wp-image-7640" title="3drotate" src="http://inspectelement.com/wp-content/uploads/2011/04/3drotate.jpg" alt="" width="645" height="365" /></a></p>
<h3>The :target Pseudo-Class</h3>
<p>First, let&#8217;s look at how the lightbox actually appears without JavaScript and only CSS with the use of the :target pseudo-class. If you&#8217;re writing CSS, you&#8217;re already using pseudo-classes as you&#8217;ll be familiar with :hover, :visited and :active.</p>
<p>You can link directly to a place on a page by adding a page anchor (#) with the ID of an element to the end of the URL:</p>
<pre><code>http://url.com/#info1</code></pre>
<p>You probably already knew that but what you may not know that you can affect the style of the element that is linked to via the :target pseudo-class. The following code would only be seen if a user clicks on a link with the target ID in:</p>
<pre><code>#info1:target { background-color: red; }</code></pre>
<p>In the case of the demo, we&#8217;re using any list item with an ID that has been &#8216;targeted&#8217; to display the lightbox <code>li[id]:target</code>. Pretty standard CSS is then used to display the lightbox on the page, even with a dark transparent overlay through the use of <code>opacity</code>.</p>
<h3>The Animation</h3>
<p>If we leave it at that, it&#8217;s pretty much the same as a standard lightbox or modal window so we&#8217;ll set it apart with a fun animation. Here is how we&#8217;ve created the animation with the help of keyframes (WebKit only for now):</p>
<pre><code>@-webkit-keyframes lightbox {
	0% { -webkit-transform: scale(5) rotateY(-270deg); }
	100% { -webkit-transform: scale(1) rotateY(0deg); }
}</code></pre>
<p>On it&#8217;s own, the code above won&#8217;t do anything so we need to reference it against the element(s) we want to animate.</p>
<pre><code>li[id]:target div { -webkit-animation: lightbox 0.75s cubic-bezier(0,0,0,1); }</code></pre>
<p>As you can see, the animation is called lightbox and that&#8217;s the first part of the <code>animation</code> property, followed by the duration and the timing function.</p>
<p>It&#8217;s very simple. We&#8217;re telling the div (the white box with the blue heading in the <a href="http://inspectelement.com/demos/css3/3dgallery/">demo</a>) to transform 5 times bigger with <code>scale(5)</code> and from a rotated position of -270 degress with <code>rotateY(-270deg)</code>. Then when the animation ends after 0.75s we want it to reset to it&#8217;s actual size and  rotation. The browser will create the animation in between (which is affected but the cubic-bezier timing function above).</p>
<h3>Less Capable Browsers</h3>
<p>The good thing about this is that browsers that don&#8217;t support CSS3 will fallback to an accessible version without the fancy animations thanks to the use of the page anchor and <a href="http://www.modernizr.com/">Modernizr</a>.</p>
<p><img class="alignnone size-full wp-image-7685" title="simple" src="http://inspectelement.com/wp-content/uploads/2011/04/simple.jpg" alt="" width="645" height="472" /></p>
<p>We do this by testing to see if CSS transforms aren&#8217;t supported and then adding CSS using the <code>.no-csstransforms</code> class. Why are we testing for a lack of CSS transforms and not CSS animation? It&#8217;s mainly to do with <code>:target pseudo-class</code> support which we can&#8217;t test for with Modernizr. It isn&#8217;t supported by older browsers, specifically IE8 and below but it is supported in all browsers with support for CSS transforms (as far as I know).</p>
<p>I&#8217;ve taken that one step further by creating an equal to or less than IE8 condition comment and <code>&lt;noscript&gt;</code> to <em>make sure</em> it is displayed the same in IE without JavaScript.</p>
<pre><code>&lt;!--[if lte IE 8]&gt;
&lt;noscript&gt;
&lt;style&gt;
    #information li { overflow: visible; position: relative; margin: 0 auto; margin-bottom: 25px; background: #fff; width: 600px; padding: 30px; height: auto; list-style: none; }
    #information li div a.close { position: relative; background: transparent; padding: 0; color: #0090e2; font-size: 12px; font-weight: normal; left: 0; top: 0; }
&lt;/style&gt;
&lt;/noscript&gt;
&lt;![endif]--&gt;</code></pre>
<p>We also want to replace the &#8216;x&#8217; (the close button in the lightbox) with &#8216;Back to top&#8217; text for lesser browsers to aid usability. We do that with a bit of jQuery and a test for no CSS transforms with Modernizr.</p>
<pre><code>if (!Modernizr.csstransforms) {
	$(document).ready(function(){
		$(".close").text("Back to top");
	});
}</code></pre>
<h3>Issues</h3>
<p>There are a couple of issues I need to point out:</p>
<ul>
<li>Double scrollbar when the lightbox content exceeds the height of the screen resolution</li>
<li>Animation is possibly slow on older machines (needs more testing)</li>
<li>Loads all content, whereas JavaScript solutions online load content when requested</li>
<li>If a browser has JavaScript turned off and doesn&#8217;t support CSS transforms, no content will be displayed. This is a problem with using Modernizr as a JS solution for browser feature testing.</li>
</ul>
<p>I recommend this should only be considered as a demonstration of CSS3 3D animations unless you don&#8217;t have much content in the lightbox, similar to the <a href="http://inspectelement.com/demos/css3/3dgallery/">demo</a>.</p>
<p>I&#8217;ll be looking to improve it all the time. In the meantime, let me know what you think and if you can offer any improvements or ideas please let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://inspectelement.com/articles/create-a-css3-image-gallery-with-a-3d-lightbox-animation/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Wallpapers of the Week 3: Beautifully Crafted Worlds</title>
		<link>http://inspectelement.com/bestoftheweek/wallpaper-of-the-week-3-beautifully-crafted-worlds/</link>
		<comments>http://inspectelement.com/bestoftheweek/wallpaper-of-the-week-3-beautifully-crafted-worlds/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 08:00:12 +0000</pubDate>
		<dc:creator>Tom Kenny</dc:creator>
				<category><![CDATA[best of the week]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[wallpaper]]></category>

		<guid isPermaLink="false">http://inspectelement.com/?p=771</guid>
		<description><![CDATA[This week's focus is on the beauty of fictional worlds, limited only by the artists' imaginations.]]></description>
			<content:encoded><![CDATA[<p>This week&#8217;s focus is on the beauty of fictional worlds, limited only by the artists&#8217; imaginations.</p>
<p><a href="http://www.zixpk.com/2008/04/machinery-of-stars.html"><img class="alignnone size-full wp-image-774" title="machineryofthestars" src="http://inspectelement.com/wp-content/uploads/2009/06/machineryofthestars.jpg" alt="machineryofthestars" width="560" height="350" />Machinery of the Stars</a></p>
<p><a href="http://tigaer.deviantart.com/art/ELYSIA-29608021"><img class="alignnone size-full wp-image-772" title="elysia" src="http://inspectelement.com/wp-content/uploads/2009/06/elysia.jpg" alt="elysia" width="560" height="356" />Elysia</a></p>
<p><a href="http://desk08.customize.org/wallpaper/121"><img class="alignnone size-full wp-image-775" title="bluemoon" src="http://inspectelement.com/wp-content/uploads/2009/06/bluemoon.jpg" alt="bluemoon" width="560" height="350" />Blue Moon</a></p>
<p><a href="http://desk08.customize.org/wallpaper/8"><img class="alignnone size-full wp-image-773" title="lush" src="http://inspectelement.com/wp-content/uploads/2009/06/lush.jpg" alt="lush" width="560" height="350" />Lush</a></p>
<p><a href="http://wall.alphacoders.com/big.php?p=CGI-Real-World-7192.jpg&amp;i=7192"><img class="alignnone size-full wp-image-777" title="returntoabalakin" src="http://inspectelement.com/wp-content/uploads/2009/06/returntoabalakin.jpg" alt="returntoabalakin" width="560" height="350" />The Return to Abalakin</a></p>
]]></content:encoded>
			<wfw:commentRss>http://inspectelement.com/bestoftheweek/wallpaper-of-the-week-3-beautifully-crafted-worlds/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

