<?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>Learning the World &#187; buttons</title>
	<atom:link href="http://learningtheworld.eu/tag/buttons/feed/" rel="self" type="application/rss+xml" />
	<link>http://learningtheworld.eu</link>
	<description></description>
	<lastBuildDate>Tue, 06 Nov 2012 00:17:33 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>More CSS Drop Shadows For All Browsers</title>
		<link>http://learningtheworld.eu/2010/ms-box-shadow/</link>
		<comments>http://learningtheworld.eu/2010/ms-box-shadow/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 16:00:18 +0000</pubDate>
		<dc:creator><![CDATA[Martin Kliehm]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[web standards]]></category>
		<category><![CDATA[blur]]></category>
		<category><![CDATA[box-shadow]]></category>
		<category><![CDATA[buttons]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[drop shadow]]></category>
		<category><![CDATA[eye-candy]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[ie8]]></category>
		<category><![CDATA[jumping-through-loops]]></category>
		<category><![CDATA[pseudo 3d]]></category>
		<category><![CDATA[shadow]]></category>
		<category><![CDATA[visual effects]]></category>

		<guid isPermaLink="false">http://learningtheworld.eu/?p=1021</guid>
		<description><![CDATA[Thanks to the unstoppable advancements of web standards aiding mankind to overcome the real burdens of the 21st century, adding drop shadows  to boxes became much easier in recent years! No more PNG background images! Leaving the question aside whether drop shadows are really progressive and appropriate for a flat medium (anybody remember the fad of “3D” bulging buttons in the 1990ies?), I&#160;was confronted with the challenge of adding box shadows in Internet Explorer for a client project.&#160;[&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Thanks to the unstoppable advancements of web standards aiding mankind to overcome the real burdens of the 21st century, adding <strong>drop shadows</strong> to boxes became much easier in recent years! No more PNG background images! Leaving the question aside whether drop shadows are really progressive and appropriate for a flat medium (anybody remember the fad of &ldquo;3D&rdquo; <a href="http://www.handson.nu/">bulging buttons</a> in the 1990ies?), I&nbsp;was confronted with the challenge of adding box shadows in Internet Explorer for a client project.</p>

<p><strong>Pro tip:</strong> communicate to the client that shadows are a <strong>bonus feature</strong>. Your designers may disagree, but the site will not suffer considerably when special effects like box shadows, text shadows, or rounded corners are regarded as enhancements for decent browsers. However, your client&rsquo;s budget will suffer when they are determined to provide the same visual effects on outdated browsers such as <acronym title="Internet Explorer 6">IE6</acronym>. That said, here is the well-known method in <acronym title="Cascading Style Sheets, 3rd Edition">CSS3</acronym>:</p>

<ol class="code" title="CSS">
<li><code><strong>.wrapper</strong> {</code></li>
<li class="indent"><code>background-color: #fff;</code></li>
<li class="indent"><code>border: 1px solid #d30d01;</code></li>
<li class="indent"><code><em>box-shadow:</em> 4px 4px 4px rgba(0, 0, 0, 0.2);</code></li>
<li class="indent"><code>float: left;</code></li>
<li class="indent"><code>height: 75px;</code></li>
<li class="indent"><code>margin: 15px;</code></li>
<li class="indent"><code>padding: 10px;</code></li>
<li class="indent"><code>width: 75px;</code></li>
<li class="indent"><code><em>-moz-box-shadow:</em> 4px 4px 4px rgba(0, 0, 0, 0.2);</code></li>
<li class="indent"><code><em>-o-box-shadow:</em> 4px 4px 4px rgba(0, 0, 0, 0.2);</code></li>
<li class="indent"><code><em>-webkit-box-shadow:</em> 4px 4px 4px rgba(0, 0, 0, 0.2);</code></li>
<li><code>}</code></li>
</ol>

<ol class="code" title="HTML code">
<li><code>&lt;div class=&quot;<em>wrapper</em>&quot;&gt;</code></li>
<li class="indent"><code>&lt;p&gt;CSS box-shadow&lt;/p&gt;</code></li>
<li><code>&lt;/div&gt;</code></li>
</ol>

<p>At the same time when we rolled out the website, Robert Nyman came to the conclusion that the proprietary Microsoft <code>filter</code> for <a href="http://robertnyman.com/2010/03/16/drop-shadow-with-css-for-all-web-browsers/"><code>Shadow</code> looks much prettier than <code>DropShadow</code></a>, so I forgot about blogging myself as his solution doesn&rsquo;t rely on unsemantic markup and is more elegant:</p>

<ol class="code" title="CSS">
<li><code><strong>.wrapper</strong> {</code></li>
<li class="indent">/* For IE 8 */</li>
<li class="indent"><code><em>-ms-filter: progid:DXImageTransform.Microsoft.Shadow</em>( Strength=5, Direction=135, Color='#999999' );</code></li>
<li class="indent">/* For IE 5.5 &#8211; 7 */</li>
<li class="indent"><code><em>filter: progid:DXImageTransform.Microsoft.Shadow</em>( Strength=5, Direction=135, Color='#999999' );</code></li>
<li><code>}</code></li>
</ol>

<p>Note that you get slightly better effects when you choose a dark gray instead of black as shadow color. If you can live with the rendering of the third box below, don&rsquo;t read any further. <img src="http://learningtheworld.eu/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /> </p>

<p>However, applying the filter had the side effect that text inside the box wasn&rsquo;t anti-aliased in <acronym>IE</acronym> 6-8 anymore, and the shadow still didn&rsquo;t look decent enough. So we added an extra <code>span</code> and applied the <code>blur</code> filter on it.</p>

<p><img src="/wp-content/uploads/2010/08/screenshot-box-shadow.png" alt="Screenshot comparing the solutions for CSS drop shadows side by side" width="481" height="103" class="fullsize" /></p>

<p>That led to a more complex code as we needed an inner wrapper where the border and background is applied to, while the outer wrapper merely acted as a&nbsp;&hellip; wrapper, where the styles were reset to defaults. <acronym title="Hypertext Markup Language">HTML</acronym> first:</p>

<ol class="code" title="HTML code">
<li><code>&lt;div class=&quot;<em>wrapper ms-box-shadow</em>&quot;&gt;</code></li>
<li class="indent"><code><strong>&lt;div class=&quot;inner&quot;&gt;</strong></code></li>
<li class="indent double"><code>&lt;p&gt;<acronym>Internet Explorer</acronym> with blur filter&lt;/p&gt;</code></li>
<li class="indent"><code><strong>&lt;/div&gt;</strong></code></li>
<li class="indent"><code><strong>&lt;span class=&quot;shadow&quot;&gt;&lt;/span&gt;</strong></code></li>
<li><code>&lt;/div&gt;</code></li>
</ol>

<p>And here&rsquo;s the <acronym>CSS</acronym> that&rsquo;s added with Conditional Comments for <acronym>IE</acronym> 6-8 only (as <acronym>IE9</acronym> supports native <acronym>CSS</acronym> <code>box-shadow</code>, <a href="http://caniuse.com/#feat=css-boxshadow">more or less</a>). The shadow element is absolutely positioned, set behind the inner content and blown up to 100%. Not original, but it works:</p>

<ol class="code" title="CSS">
<li><code><strong>.wrapper, .inner</strong> {</code></li>
<li class="indent"><code>background-color: #fff;</code></li>
<li class="indent"><code>border: 1px solid #d30d01;</code></li>
<li class="indent"><code>height: 75px;</code></li>
<li class="indent"><code>padding: 10px;</code></li>
<li class="indent"><code><em>position: relative;</em></code></li>
<li class="indent"><code>width: 75px;</code></li>
<li><code>}</code></li>
<li><code><strong>.wrapper</strong> {</code></li>
<li class="indent"><code>float: left;</code></li>
<li class="indent"><code>margin: 15px;</code></li>
<li><code>}</code></li>
<li>/* reset wrapper styles to defaults; work-around for screwed box-model */</li>
<li><code><strong>.ms-box-shadow</strong> {</code></li>
<li class="indent"><code>background-color: transparent;</code></li>
<li class="indent"><code>border: 0 none;</code></li>
<li class="indent"><code>height: 95px;</code></li>
<li class="indent"><code>padding: 0;</code></li>
<li class="indent"><code>width: 95px;</code></li>
<li><code>}</code></li>
<li>/* Move the inner wrapper to the foreground */</li>
<li><code><strong>.inner</strong> {</code></li>
<li class="indent"><code><em>z-index: 50;</em></code></li>
<li><code>}</code></li>
<li>/* The shadow element */</li>
<li><code><strong>.shadow</strong> {</code></li>
<li class="indent"><code>background-color: #000;</code></li>
<li class="indent"><code>display: block;</code></li>
<li class="indent"><code><em>filter: progid:DXImageTransform.Microsoft.Blur</em>( makeShadow='true', pixelRadius=4, shadowOpacity=0.30 );</code></li>
<li class="indent"><code>height: 100%;</code></li>
<li class="indent"><code>left: 0;</code></li>
<li class="indent"><code><em>position: absolute;</em></code></li>
<li class="indent"><code>top: 0;</code></li>
<li class="indent"><code>width: 100%;</code></li>
<li class="indent"><code><em>z-index: 0;</em></code></li>
<li><code>}</code></li>
</ol>

<p>For some reason I got a more similar result with the <code>shadowOpacity</code> set to 30% instead of 20%.</p>

<h3>Where&rsquo;s the crux?</h3>

<p>If we are willing to ignore lots of bloated <acronym>CSS</acronym>: <strong><acronym>IE6</acronym> only blows the shadow up to 100% when the wrapper has a fixed height</strong>. This sucks, but unless you want to add more bloated code in JavaScript I don&rsquo;t know of any solution for this problem. Still <acronym>IE</acronym> 7-8 handle a value of 100% right, and there are many cases where the height is known. Take for example photos where you&#8217;d like to apply shadows, some buttons, or horizontal shades lying above images, like the <a href="http://dekabank.de/db/en/company/social-responsibility/">shadow of the second level navigation on this site</a>. Beautiful, isn&rsquo;t it?</p>
]]></content:encoded>
			<wfw:commentRss>http://learningtheworld.eu/2010/ms-box-shadow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
