<?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>Crystal's Adventures in Webdev Land &#187; css</title>
	<atom:link href="http://crysodenkirk.com/blog/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://crysodenkirk.com/blog</link>
	<description>Luck smiles on me often. Usually, it's with derision.</description>
	<lastBuildDate>Sun, 11 Jul 2010 20:30:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Color Wheels with only CSS3 and Primary Colors</title>
		<link>http://crysodenkirk.com/blog/2010/07/color-wheels-with-only-css3-and-primary-colors/</link>
		<comments>http://crysodenkirk.com/blog/2010/07/color-wheels-with-only-css3-and-primary-colors/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 20:26:06 +0000</pubDate>
		<dc:creator>Crys</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[experiments]]></category>

		<guid isPermaLink="false">http://crysodenkirk.com/blog/?p=1398</guid>
		<description><![CDATA[div{background:transparent;} .cw_out{background:transparent;width:400px;height:400px;margin:10px auto;position:relative;} .cw_out div,#ex1,#ex2{height:150px;width:150px;-moz-border-radius:150px 0px 0 0;-webkit-border-top-left-radius:150px;position:absolute;display:inline-block;} .cw_out div{display:block;} #ex1,#ex2{position:relative;display:block;background:rgba(255,25,0,1);margin:2px auto;} #ex2{-moz-transform: rotate(45deg);-webkit-transform: rotate(45deg);top:-37px;}; .red1,{background:rgba(255,25,0,.5);} .blue1{background:rgba(0,50,255,.5);} .yellow1{background:rgba(255,255,0,.5);} strong.red1{background:#f00;} strong.blue1{background:#02f;} strong.yellow1{background:#fc0;} .red2{background:rgba(255,25,0,.5);} .blue2{background:rgba(0,65,255,.5);} .yellow2{background:rgba(255,255,0,.5);} .red3{background:rgba(255,25,0,.2);} .blue3{background:rgba(0,65,255,.2);} .yellow3{background:rgba(255,255,0,.2);} code{padding:3px;text-shadow:none;} #s1{position:absolute;display:block;height:1px;width:1px;background:transparent;} #s2{display:block;position:absolute;height:300px; width:300px; border:1px solid #741;border:0;top:47px;left:47px;z-index:10;-moz-border-radius:150px;-webkit-border-radius:150px;margin:0;background-image: -moz-radial-gradient(center 45deg, circle closest-side, #fff 0%, rgba(0,0,0,.5) 100%,rgba(255,255,255,1) 25%, rgba(255,255,255,.1) 65%,rgba(0,0,0,0) 75%); background-image: -webkit-gradient(radial, 0% 0%, 0% 100%, from(#1a82f7), to(#2F2727));display:none;} #s3{display:block;position:absolute;width:298px;height:298px;border:4px [...]


Related posts:<ol><li><a href='http://crysodenkirk.com/blog/2010/05/in-search-of-bolder-type-and-a-font-outline/' rel='bookmark' title='Permanent Link: In Search of Bolder Type and a Font Outline'>In Search of Bolder Type and a Font Outline</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
div{background:transparent;}
.cw_out{background:transparent;width:400px;height:400px;margin:10px auto;position:relative;}
.cw_out div,#ex1,#ex2{height:150px;width:150px;-moz-border-radius:150px 0px 0 0;-webkit-border-top-left-radius:150px;position:absolute;display:inline-block;}
.cw_out div{display:block;}
#ex1,#ex2{position:relative;display:block;background:rgba(255,25,0,1);margin:2px auto;}
#ex2{-moz-transform: rotate(45deg);-webkit-transform: rotate(45deg);top:-37px;};
.red1,{background:rgba(255,25,0,.5);}
.blue1{background:rgba(0,50,255,.5);}
.yellow1{background:rgba(255,255,0,.5);}
strong.red1{background:#f00;}
strong.blue1{background:#02f;}
strong.yellow1{background:#fc0;}
.red2{background:rgba(255,25,0,.5);}
.blue2{background:rgba(0,65,255,.5);}
.yellow2{background:rgba(255,255,0,.5);}
.red3{background:rgba(255,25,0,.2);}
.blue3{background:rgba(0,65,255,.2);}
.yellow3{background:rgba(255,255,0,.2);}
code{padding:3px;text-shadow:none;}
#s1{position:absolute;display:block;height:1px;width:1px;background:transparent;}
#s2{display:block;position:absolute;height:300px; width:300px; border:1px solid #741;border:0;top:47px;left:47px;z-index:10;-moz-border-radius:150px;-webkit-border-radius:150px;margin:0;background-image: -moz-radial-gradient(center 45deg, circle closest-side, #fff 0%, rgba(0,0,0,.5) 100%,rgba(255,255,255,1) 25%, rgba(255,255,255,.1) 65%,rgba(0,0,0,0) 75%);
            background-image: -webkit-gradient(radial, 0% 0%, 0% 100%, from(#1a82f7), to(#2F2727));display:none;}
#s3{display:block;position:absolute;width:298px;height:298px;border:4px solid #BA8238;border:2px solid #dca45a;
   z-index:7;-moz-border-radius:150px;-webkit-border-radius:150px;top:48px;left:48px;-moz-box-shadow:1px 1px 6px #dca45a;-webkit-box-shadow:1px 1px 6px #dca45a;}
#r1{z-index:3;-moz-transform: rotate(-15deg);-webkit-transform: rotate(-15deg);top:71px;left:33px;
   filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.9659258262890683, M12=0.25881904510252074, M21=-0.25881904510252074, M22=0.9659258262890683,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.9659258262890683, M12=0.25881904510252074, M21=-0.25881904510252074, M22=0.9659258262890683)";}
#r2{z-index:2;-moz-transform: rotate(15deg);-webkit-transform: rotate(15deg);top:33px;left:71px;
  filter:  progid:DXImageTransform.Microsoft.Matrix( M11=0.9659258262890683, M12=-0.25881904510252074, M21=0.25881904510252074, M22=0.9659258262890683,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.9659258262890683, M12=-0.25881904510252074, M21=0.25881904510252074, M22=0.9659258262890683)";}
#r3{z-index:1;-moz-transform: rotate(45deg);-webkit-transform: rotate(45deg);top:19px;left:124px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)";}
#r4{z-index:2;-moz-transform: rotate(75deg);-webkit-transform: rotate(75deg);top:33px;left:177px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.25881904510252074, M12=-0.9659258262890683, M21=0.9659258262890683, M22=0.25881904510252074,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.25881904510252074, M12=-0.9659258262890683, M21=0.9659258262890683, M22=0.25881904510252074)";}
#r5{z-index:4;-moz-transform: rotate(105deg);-webkit-transform: rotate(105deg);top:71px;left:215px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0.25881904510252085, M12=-0.9659258262890683, M21=0.9659258262890683, M22=-0.25881904510252085,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=-0.25881904510252085, M12=-0.9659258262890683, M21=0.9659258262890683, M22=-0.25881904510252085)";}
#b1{z-index:3;-moz-transform:rotate(105deg);-webkit-transform:rotate(105deg);top:71px;left:215px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0.25881904510252085, M12=-0.9659258262890683, M21=0.9659258262890683, M22=-0.25881904510252085,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=-0.25881904510252085, M12=-0.9659258262890683, M21=0.9659258262890683, M22=-0.25881904510252085)";}
#b2{z-index:2;-moz-transform:rotate(135deg);-webkit-transform:rotate(135deg);top:124px;left:229px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0.7071067811865475, M12=-0.7071067811865476, M21=0.7071067811865476, M22=-0.7071067811865475,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=-0.7071067811865475, M12=-0.7071067811865476, M21=0.7071067811865476, M22=-0.7071067811865475)";}
#b3{z-index:1;-moz-transform:rotate(165deg);-webkit-transform:rotate(165deg);top:177px;left:215px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0.9659258262890682, M12=-0.258819045102521, M21=0.258819045102521, M22=-0.9659258262890682,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=-0.9659258262890682, M12=-0.258819045102521, M21=0.258819045102521, M22=-0.9659258262890682)";}
#b4{z-index:2;-moz-transform:rotate(195deg);-webkit-transform:rotate(195deg);top:215px;left:177px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0.9659258262890684, M12=0.25881904510252035, M21=-0.25881904510252035, M22=-0.9659258262890684,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=-0.9659258262890684, M12=0.25881904510252035, M21=-0.25881904510252035, M22=-0.9659258262890684)";}
#b5{z-index:5;-moz-transform:rotate(225deg);-webkit-transform:rotate(225deg);top:229px;left:124px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0.7071067811865477, M12=0.7071067811865475, M21=-0.7071067811865475, M22=-0.7071067811865477,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=-0.7071067811865477, M12=0.7071067811865475, M21=-0.7071067811865475, M22=-0.7071067811865477)";}
#y1{z-index:4;-moz-transform:rotate(225deg);-webkit-transform:rotate(225deg);top:229px;left:124px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0.7071067811865477, M12=0.7071067811865475, M21=-0.7071067811865475, M22=-0.7071067811865477,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=-0.7071067811865477, M12=0.7071067811865475, M21=-0.7071067811865475, M22=-0.7071067811865477)";}
#y2{z-index:2;-moz-transform:rotate(255deg);-webkit-transform:rotate(255deg);top:215px;left:72px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0.25881904510252063, M12=0.9659258262890683, M21=-0.9659258262890683, M22=-0.25881904510252063,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=-0.25881904510252063, M12=0.9659258262890683, M21=-0.9659258262890683, M22=-0.25881904510252063)";}
#y3{z-index:1;-moz-transform:rotate(285deg);-webkit-transform:rotate(285deg);top:176px;left:33px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.25881904510252113, M12=0.9659258262890682, M21=-0.9659258262890682, M22=0.25881904510252113,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.25881904510252113, M12=0.9659258262890682, M21=-0.9659258262890682, M22=0.25881904510252113)";}
#y4{z-index:2;-moz-transform:rotate(315deg);-webkit-transform:rotate(315deg);top:124px;left:19px;
  filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865473, M12=0.7071067811865477, M21=-0.7071067811865477, M22=0.7071067811865473,sizingMethod='auto expand');
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865473, M12=0.7071067811865477, M21=-0.7071067811865477, M22=0.7071067811865473)";}
#y5{z-index:4;-moz-transform:rotate(345deg);-webkit-transform:rotate(345deg);top:71px;left:33px;
  filter:  progid:DXImageTransform.Microsoft.Matrix(M11=0.9659258262890683, M12=0.2588190451025207, M21=-0.2588190451025207, M22=0.9659258262890683,sizingMethod='auto expand');
  -ms-filter: progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.9659258262890683, M12=0.2588190451025207, M21=-0.2588190451025207, M22=0.9659258262890683);}
</style>
<p><!--[if IE]></p>
<style type="text/css">
.red1 div,.red2 div,.red3 div{background:#f00;}
.blue1 div,.blue2 div,.blue3 div{background:#02f;}
.yellow1 div,.yellow2 div,.yellow3 div{background:#fc0;}
.red1 div,.blue1 div,.yellow1 div,.red2 div,.blue2 div,.yellow2 div{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);}
.red3 div,.blue3 div,.yellow3 div{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20);}
#s2{top:210px;left:211px;display:none;}
#s3{top:62px;left:62px;display:none;}
#r1{top:71px;left:32px;}
#r2{top:32px;left:71px;}
#r3{top:1px;left:109px;}
#r4{top:30px;left:175px;}
#r5{top:71px;left:215px;}
#b1{top:71px;left:215px;}
#b2{top:108px;left:216px;}
#b3{top:177px;left:215px;}
#b4{top:214px;left:175px;}
#b5{top:214px;left:110px;}
#y1{top:214px;left:110px;}
#y2{top:213px;left:72px;}
#y3{top:176px;left:33px;}
#y4{top:108px;left:6px;}
#y5{top:71px;left:32px;}
</style>
<p><![endif]--></p>
<div class="cw_out"><span id="s1"><span id="s2"></span><span id="s3"></span></p>
<div class=red3 id=r1>
<div></div>
</div>
<div class=red2 id=r2>
<div></div>
</div>
<div class=red1 id=r3>
<div></div>
</div>
<div class=red2 id=r4>
<div></div>
</div>
<div class=red3 id=r5>
<div></div>
</div>
<div class=blue3 id="b1">
<div></div>
</div>
<div class=blue2 id=b2>
<div></div>
</div>
<div class=blue1 id=b3>
<div></div>
</div>
<div class=blue2 id=b4>
<div></div>
</div>
<div class=blue3 id=b5>
<div></div>
</div>
<div class=yellow3 id=y1>
<div></div>
</div>
<div class=yellow2 id=y2>
<div></div>
</div>
<div class=yellow1 id=y3>
<div></div>
</div>
<div class=yellow2 id=y4>
<div></div>
</div>
<div class=yellow3 id=y5>
<div></div>
</div>
<p></span></div>
<p>There are no images above, nothing but css (half of it vendor propriety, sadly), and this was entirely created with primary colors: <strong class="red1" style="color:#fff;text-shadow:none;padding:5px;">Red</strong> <strong class="yellow1" style="text-shadow:none;padding:5px;">Yellow</strong> and <strong class="blue1" style="color:#fff;text-shadow:none;padding:5px;">Blue</strong>. Why? Because I wanted to see how well you could create other colors using additive color mixing methods like you would with paint through overlayed rgba semi-transparent colors. A <a href="http://www.colormatters.com/colortheory.html" title="If you don't know what primary colors or color wheels are for, go read this first" target="_blank">standard color wheel</a> with secondary and tertiary colors was the obvious test. This works in Firefox, webkit browsers and even, yes, Internet Explorer. Well, the curved edge that makes it a circle doesn&#8217;t work in IE. But the semi-transparent color overlays to simulate additive color mixing that I was wondering about? Works like a charm!<span id="more-1398"></span></p>
<p>So we&#8217;re all on the same page regardless of browser, this is how it looks to people using a mozilla or webkit browser:<br />
<div id="attachment_1903" class="wp-caption aligncenter" style="width: 362px"><img src="http://crysodenkirk.com/blog/wp-content/uploads/2010/07/cw_safari.jpg" alt="Color Wheel in mozilla and webkit" title="cw_safari" width="352" height="370" class="size-full wp-image-1903" /><p class="wp-caption-text">Color Wheel in mozilla and webkit</p></div></p>
<p>And this is how it looks in Internet Explorer:<br />
<div id="attachment_1904" class="wp-caption aligncenter" style="width: 447px"><img src="http://crysodenkirk.com/blog/wp-content/uploads/2010/07/cw_ie.jpg" alt="Color Wheel in Explorer" title="cw_ie" width="437" height="435" class="size-full wp-image-1904" /><p class="wp-caption-text">Color Wheel in Explorer</p></div></p>
<h4>Firefox, Safari and Chrome</h4>
<p>This is a fairly simple &#8212; if somewhat time consuming &#8212; illusion to create in Firefox and Webkit browsers. I decided to use 90&deg; angles for each layer of color, with each subsequent layer 30&deg; rotated further around the center point. Each of the primary colors is displayed at 50% opacity, except at the edges where there is an identical overlap with the next color&#8217;s endpoint. I made these endpoints 20% opacity to simulate the color getting lighter where one bleeds into the next.</p>
<p>Let&#8217;s take that one piece at a time.</p>
<p>First, I need a space to lay out the layers. I create a div and give it the creatively-named class of cw_out (<em>c</em>olor <em>w</em>heel <em>out</em>side). I choose a height and width of 400px because that&#8217;s the width I use for photos so they will fit in the main column on my front page. I&#8217;m going to nest the circle into the middle of this circle with a 50px cushion (you can see why if you glance above at what it looks like in IE).</p>
<p>Next, I needed a rounded, 90&deg; quadrant of a circle. My circle is 300px by 300px so a quadrant is 150px by 150px. Once I&#8217;ve made a square layer, I need to change one corner from squared off to an arc. This is added by <code>border-radius</code>, which isn&#8217;t really supported yet on its own, so you have to use the vendor-proprietary versions, <code>-moz-border-radius</code> and <code>-webkit-border-radius</code>. I only want one corner (the top left for no reason other than it was the first one I picked) curved though. In Firefox, they&#8217;ve implemented the familiar shorthand you&#8217;re used to, where you can do each corner independently, but Safari hasn&#8217;t. You have to use <code>-webkit-border-top-left-radius</code> &#8212; note that in firefox there&#8217;s no hyphen between top and left, and the words are flipped, if you aren&#8217;t using the shorthand: <code>-moz-border-radius-topleft</code>. But I&#8217;m a fan of shorthand, so my code for turning a square into a quadrant looks like this: <code>-moz-border-radius:150px 0 0 0;-webkit-border-top-left-radius:150px;</code>, which looks like this:</p>
<div id="ex1"></div>
<p>Then I have to tilt it so it fits in my circle. I tend to put red at the top, mainly out of habit, so I want my main red quadrant at the very top of the circle. In comes <code>transform</code>. The kind of transform we want to use is rotation, and luckily other than the vendor prefixes, the syntax is the same. To sit my quadrant at the top of the circle with its point in the center, I needed to transform it 45&deg; clockwise, which looks like this: <code>-moz-transform: rotate(45deg);-webkit-transform: rotate(45deg);</code>, like so:</p>
<div id="ex2"></div>
<p>Something to remember when you use tranform on an object is that its <code>top</code> and <code>left</code> don&#8217;t change, but they are relative now to the entire shape, which will not have the same apparent height and width as the non-rotated shape&#8230; however, when the browser renders it, it only allots the space for the non-rotated element. So in appearance, my square is now roughly 215px tall and wide (you can&#8217;t see the top part because of the border radius but it&#8217;s there), but the browser still renders the elements around it as though it were 150px tall and wide. That means the roughly 65px overhang at the bottom overlaps whatever&#8217;s next in the flow. (I fixed that in my example by moving the box up so it didn&#8217;t overlap this paragraph).</p>
<p>Next: positioning it to be a circle instead of random jumbled layers. I&#8217;m sure there&#8217;s some programatic, trigonometric function for figuring out how far off the top and left needed to be, but I decided it was faster to place a 1px wide and tall div in the very center of the box and guesstimate til I got the points on the 1px div (I&#8217;m very good at estimating distances on screen in pixels so this is a fast process for me). It&#8217;s easiest to do this with one piece at a time though, so when I finished positioning this first piece, I put <code>display:none;</code> at the end of the css declaration to hide it and performed the same steps on the next piece, until I&#8217;d done all fifteen of them.</p>
<p>To give you a good feel for what I mean by &#8220;overlapping layers&#8221;, here&#8217;s a screenshot with the <code>border-radius</code> removed:<br />
<div id="attachment_1907" class="wp-caption aligncenter" style="width: 443px"><img src="http://crysodenkirk.com/blog/wp-content/uploads/2010/07/cw_saf_nobr.jpg" alt="Color Wheel in Mozilla and Webkit with border-radius removed" title="cw_saf_nobr" width="433" height="409" class="size-full wp-image-1907" /><p class="wp-caption-text">Color Wheel in Mozilla and Webkit with border-radius removed</p></div></p>
<p>As you can see, the endpoints of each color dovetail over each other.</p>
<p>I put a circle (ie, a square with a <code>border-radius</code> equal to half it&#8217;s height/width) around the outside mainly to give it a solid edge and reduce visual interference from my textured background. I applied just a touch of a <code>box-shadow</code> to give it a slightly raised, three-dimensional feeling.</p>
<h4>Internet Explorer</h4>
<p>Doing this in IE turns out to be a whooole lot more complex&#8230; but still almost entirely doable and much of it has been available since IE5.5, believe it or not! Why spend the freakish amount of time to make it work in IE? Because frankly, I&#8217;m sick of seeing &#8220;Hey, isn&#8217;t this new css3 attribute nifty!&#8221; without finding some suitable way to accomplish something similar or at least meaningfully and gracefully degraded for IE. So long as most of the market is still on some version of IE, your nifty experiments are just time wasters if you&#8217;re not also finding a solution for IE (or designing exclusively for mobile). I dislike IE just as much as the rest of my design brethren, but I also know that without my users, there&#8217;s no reason for the design to exist in the first place, something I think half the web world has forgotten.</p>
<p>Ok, I&#8217;ll make an exception for <a href=http://www.subcide.com/articles/pure-css-twitter-fail-whale/ title="The CSS3 Fail Whale" target=_blank>The Pure CSS3 Fail Whale</a>. That&#8217;s not a meaningless time waster. That&#8217;s just cool, and I&#8217;m kind of impressed by how well it rendered even in IE.</p>
<p>But back to color wheels. <a href="http://msdn.microsoft.com/en-us/library/ms532847(VS.85).aspx" title="learn more about filters" target=_blank>IE has it&#8217;s own custom non-css called &#8220;filters&#8221;</a> that you can call from within a css declaration. These are occasionally processor intensive and it&#8217;s better to avoid them where possible. They are most definitely non-standard. But they&#8217;re there, and they work, provided you&#8217;re willing to do a little jury-rigging of your code. There&#8217;s a wide range of filters available (I would not call it a full range and many of them are kind of useless, but there&#8217;s quite a few out there).</p>
<p>Because I don&#8217;t want to only use right angles for rotation, I ended up going with <a href="http://msdn.microsoft.com/en-us/library/ms533014(v=VS.85).aspx" title="Enter the Matrix" target=_blank>the Matrix filter</a>. I&#8217;ll avoid the obvious movie-related jokes because after you read the specs on that one, you&#8217;re already going to be wishing you&#8217;d picked the blue pill without additional pun damage from me. Essentially, there are six variables relating to cosines, sines, and other trigonometric functions. I&#8217;m not sure why they implemented it this way &#8212; I&#8217;m guessing it&#8217;s the underlying programming related to how all programs render rotation. Regardless, it&#8217;s not something I feel like having to figure out for fifteen divs with six variables each. They&#8217;ve included a javascript function for determining the variables for each rotation and if you&#8217;re only doing rotation, I suggest just lifting that. Or you can go to <a href="http://www.css3please.com" target=_blank title="nifty css3 generator">css3please.com</a> and type in your angle of rotation and copy the M values for the transform filters from that. That&#8217;s what I did. There&#8217;s a caveat though if you do that. There&#8217;s an issue in the ie7 and earlier version of the transform filter that is not accounted for by the css you will get from css3please.com. Here&#8217;s what those filters look like coming from css3please.com:</p>
<pre><code>filter:  progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand',
    M11=0.7071067811865476, M12=-0.7071067811865475,
    M21=0.7071067811865475, M22=0.7071067811865476);
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand',
    M11=0.7071067811865476, M12=-0.7071067811865475,
    M21=0.7071067811865475, M22=0.7071067811865476)";
</code></pre>
<p>That&#8217;s the IE 5.5+ equivalent of css3&#8242;s <code>transform: rotate(45deg);</code>. I know, not too pretty. Let me explain the pieces and then I&#8217;ll explain how you have to change it to make it work in IE7.</p>
<p>First, you see <code>filter</code> and <code>-ms-filter</code>. I suppose in the interests of moving toward the correct behavior of all vendor proprietary css being prefixed with a vendor code, they&#8217;ve changed some or all of the filters to use -ms-. That&#8217;s good. The bad is, they removed support for just <code>filter</code> (hope you weren&#8217;t using them too extensively when IE8 came out&#8230;). So now to hit all versions of IE, you have to declare your filter twice. For some filters (like the opacity one below) you have to declare the vendor prefixed one first or it will fail in IE7 and below. Matrix is not one of those filters. Leaving it in this order is fine. Note also the quote marks on the prefixed version.</p>
<p>Sizing method refers to the bounding box of the element. There are several combinations available for the sizing method but mainly it boils down to what renders. You can clip/crop the element, or you can expand the element so the whole thing remains visible (which is what I&#8217;m doing here).</p>
<p>You can see here M11, M12, M21, and M22. The two not shown here are Dx and Dy, which don&#8217;t have to be declared because I haven&#8217;t included an &#8220;augmenting vector&#8221;. As for the Ms? I&#8217;m not even going to pretend to have any idea how those values translate into &#8220;rotate 45&deg;&#8221;. They can be used for skewing, resizing or rotation.</p>
<p>One other note about using the transform filters: If you want to use them on an absolutely positioned element, its parent also needs to be absolutely positioned. Now, my parent container is relatively positioned so it works with the layout of my blog, so I put another container inside it and absolutely positioned that. Additionally, any element you want to apply a filter to must &#8220;<a href="http://www.satzansatz.de/cssd/onhavinglayout.html" title="IE hasLayout explanation" target=_blank>have layout</a>&#8220;. This is an IE-only concept and my usual solution is to use <code>display:inline-block;</code> followed in a new declaration by whatever I actually want it to display as. </p>
<p>Now for the problem: In IE7 (and perhaps earlier, I don&#8217;t have access to check), the sizing method needs to be at the end of the declaration for &#8220;filter&#8221;. Otherwise it simply fails to render and I had issues with all css that comes after the filter being ignored. I&#8217;m going to assume this is likely some kind of parser error and it might even be an error that only happens in IE8&#8242;s version of IE7. Whether you&#8217;re writing your own filter up or using the one from css3please, you need to move the sizing method to the end. So for a 45&deg; rotation, your declarations will look like this:</p>
<pre><code>filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865476,
    M12=-0.7071067811865475, M21=0.7071067811865475,
    M22=0.7071067811865476,sizingMethod='auto expand');
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand',
    M11=0.7071067811865476, M12=-0.7071067811865475,
    M21=0.7071067811865475, M22=0.7071067811865476)";
</code></pre>
<p>So far, so good. Next, transparencies. Sadly, IE does not recognize rgba color yet. But it does have filters for opacity.</p>
<p>If you&#8217;re not trying to do anything that will involve transform filters (like rotating the squares), then you can easily do the overlapping transparencies with <code>-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20);</code>. Sadly, as soon as you apply a transform to it, the element reverts to full opacity because the alpha channel is stripped from the element as part of the transform. There&#8217;s a workaround for this that I haven&#8217;t seen anyone else using.</p>
<p>You can&#8217;t put the alpha transparency back on the element. One obvious possibility is to nest a new element inside the rotated one. This falls down as soon as you try to position it though because the nested element loses its parent&#8217;s rotation. Positions relative and absolute will position the box in reference to the origination point of the parent box (which, as with Mozilla and Webkit above, is where the box WOULD be if not rotated, not where it looks like it is on screen). So you end up with a semi-transparent, non-rotated element.</p>
<p>The way to get around this is to tell the browser to make it part of the standard flow, using <code>position:static;</code>. Once made static, you can make it a block element and size it. You can&#8217;t position it &#8212; if it&#8217;s the first thing in your rotated element it will sit at <code>top:0;left:0;</code> and you can&#8217;t change that. So you make both containers the same size, position the rotated container and then use the child container for the transparency. Turns out that though the transform strips off the alpha channel, you can still use a fully transparent background on the rotated container. Here&#8217;s an example with a border on the parent container so you can see it.</p>
<style type="text/css">
#it{background-color:#ff0000 !important;
  -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
  filter:alpha(opacity=50);
  opacity:0.5;display:block;position:static;height:300px;width:300px;top:100px;left:300px;}
#ot{border:3px solid #fff;background:transparent;display:block;position:absolute;
height:320px;width:320px;top:0px;left:0px;
-moz-transform: rotate(7.5deg); /* FF3.5+ */ -o-transform: rotate(7.5deg); /* Opera 10.5 */ -webkit-transform: rotate(7.5deg); /* Saf3.1+, Chrome */ -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.9914448613738104, M12=-0.13052619222005157, M21=0.13052619222005157, M22=0.9914448613738104)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.9914448613738104, M12=-0.13052619222005157, M21=0.13052619222005157, M22=0.9914448613738104,sizingMethod='auto expand');zoom: 1;}</p>
</style>
<div style="height:400px;width:400px;position:relative;margin:5px auto;">
<div id="ot">
<div id="it"></div>
<p><strong></strong>
</div>
</div>
<p>Once I figured that out, it was a simple matter of following the same steps as I had for Mozilla and Webkit for positioning &#8212; and of course all the positioning was different for IE than other browsers, so I ended up just giving in and using conditional comments to write some IE-only CSS (why not, I&#8217;m already using filters&#8230;).</p>
<h4>Conclusions</h4>
<p>I&#8217;m less than enthused by the green. It&#8217;s decent in Safari, a little better in Firefox, but just not green in IE. It&#8217;s more of a muddy grey. The orange in IE turned out very well though, so I&#8217;m not willing to outright say that additive color as a whole is a failure in IE. There do seem to be some problems with apparent opacity not matching actual opacity, which seems to be based on how dark the original color is. If I&#8217;d gone with a lighter blue, something with the same lightness as the yellow, I think I would have ended up with a greener green.</p>
<p>You can stop here or I&#8217;ve formatted the code in a more reader-friendly way on the next page if you&#8217;d like to see it in full. <a href="/blog/2010/07/color-wheels-with-only-css3-and-primary-colors/2/">Go To Page 2</a></p>
<img src="http://crysodenkirk.com/blog/?ak_action=api_record_view&id=1398&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://crysodenkirk.com/blog/2010/05/in-search-of-bolder-type-and-a-font-outline/' rel='bookmark' title='Permanent Link: In Search of Bolder Type and a Font Outline'>In Search of Bolder Type and a Font Outline</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://crysodenkirk.com/blog/2010/07/color-wheels-with-only-css3-and-primary-colors/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>In Search of Bolder Type and a Font Outline</title>
		<link>http://crysodenkirk.com/blog/2010/05/in-search-of-bolder-type-and-a-font-outline/</link>
		<comments>http://crysodenkirk.com/blog/2010/05/in-search-of-bolder-type-and-a-font-outline/#comments</comments>
		<pubDate>Thu, 27 May 2010 17:37:08 +0000</pubDate>
		<dc:creator>Crys</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://crysodenkirk.com/blog/?p=1129</guid>
		<description><![CDATA[I have always been annoyed by how not-bold the standard browser-safe system fonts are at smaller font sizes. And even now, calling in a bolder typeface using @font-face is not always a viable option (like a project I&#8217;m working on right now). I need heavier type than Verdana bold, and it needs an outline to [...]


Related posts:<ol><li><a href='http://crysodenkirk.com/blog/2010/07/color-wheels-with-only-css3-and-primary-colors/' rel='bookmark' title='Permanent Link: Color Wheels with only CSS3 and Primary Colors'>Color Wheels with only CSS3 and Primary Colors</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I have always been annoyed by how not-bold the standard browser-safe system fonts are at smaller font sizes. And even now, calling in a bolder typeface using @font-face is not always a viable option (like a project I&#8217;m working on right now). I need heavier type than Verdana bold, and it needs an outline to make it stand out against its background, it can&#8217;t have any extra markup, and it has to be cross browser compatible.<span id="more-1129"></span></p>
<p>Here&#8217;s my text without styling:</p>
<style type="text/css">
.outline_example,.outline_example span{display:inline-block;}
.outline_example{
    background:-webkit-gradient(linear, left top, left bottom, from(#444), to(#222), color-stop(0.5, #bbb));
    background:-moz-linear-gradient(0% 100% 90deg, #222, #bbb, #444 28px) bottom center repeat-x #4A494A;
    filter:  progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#cccccc', endColorstr='#666666');
    position:relative;
    display:block;
    color:#fc0;text-shadow:none;
    padding:0;
   }
span.outline_example span{
    font:16px/1.5 Verdana, Tahoma, Geneva, sans-serif; color:#fc0;text-shadow:none;
    padding:3px;
    position:relative;
    display:block;
    }
pre{
  margin: 16px 35px 16px 32px;
  padding:8px;
  white-space: pre-wrap; /* css-3 */
  white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
  white-space: -pre-wrap; /* Opera 4-6 */
  white-space: -o-pre-wrap; /* Opera 7 */
  word-wrap: break-word; /* Internet Explorer 5.5+ */
  font-family:monospace;
  border:2px solid #D28D40;
  background-color:#F8DF9C;
  text-shadow:none !important;
  }</p>
</style>
<p><span class="outline_example"><span>This is Verdana or Tahoma or Geneva</span></span></p>
<p>Note, these are actual colors from a current project and no, I don&#8217;t get a say in that. I just have to make it work. But this? Is totally unreadable. Let&#8217;s make it bold:</p>
<p><span class="outline_example"><span style="font-weight:bold;">Really? You call this bold?</span></span></p>
<p>Better, but still basically unreadable. For one thing, it&#8217;s not bold enough. But even if I could make it bolder, it would still be hard to read against this background. It needs a nice dark background for that color of text! </p>
<p>I grumble to myself: If I could just do this in photoshop&#8230; ah, for a good black outline.</p>
<p>But wait!</p>
<p>Firefox supports text-shadows now. IE has its weird &#8220;filter&#8221; renderings. Maybe just throwing in a text-shadow will solve it:</p>
<p><span class="outline_example"><span  style="font-weight:bold;text-shadow:1px 1px 2px #000;filter:progid:DXImageTransform.Microsoft.Shadow(color='black', Direction=90, Strength=4);">Better but&#8230; still hard on the eyes. Also, not very bold.</span></span></p>
<p>Here&#8217;s the css for the shadow:</p>
<pre>text-shadow:1px 1px 2px #000;
filter:progid:DXImageTransform.Microsoft.Shadow(color='black', Direction=90, Strength=4);</pre>
<p>I? Am very picky. I may not get to pick the color and the background but I can damn well make the combination work. That&#8217;s what I do.</p>
<p>Some people may use the word &#8220;stubborn&#8221; in place of picky&#8230;</p>
<p>So I ponder. I google to see the progress on font-effect:outline (which really doesn&#8217;t do what I want but hey, the spec&#8217;s still up in the air). I see lots of people asking the question of how to add an outline but no one answering it&#8230;</p>
<p>And then it hits me. I can make the text bolder using the text-shadow declaration with a 0px offset.</p>
<p><span class="outline_example"><span style="font-weight:bold;text-shadow:0px 0px 1px #fc0;filter:progid:DXImageTransform.Microsoft.Shadow(color='#ffcc00', Direction=90, Strength=3);">Going cross-eyed trying to read this.</span></span></p>
<pre>text-shadow:0px 0px 1px #fc0;
filter:progid:DXImageTransform.Microsoft.Shadow(color='#ffcc00', Direction=90, Strength=3);</pre>
<p>Kinda fuzzy. And it doesn&#8217;t stand out against the background. Not happy with this one. But text-shadow supports multiple shadows on the same element (IE doesn&#8217;t, but it worked with just one filter):</p>
<p><span class="outline_example"><span style="font-weight:bold;text-shadow:0px 0px 1px #fc0,0px 0px 3px #000,0px 0px 3px #000;filter:progid:DXImageTransform.Microsoft.Glow(color='#333333', Strength='1');">Ah, bolder and actually legible!</span></span></p>
<pre>text-shadow:0px 0px 1px #fc0,0px 0px 3px #000,0px 0px 3px #000;
filter:progid:DXImageTransform.Microsoft.Glow(color='#333333', Strength='1');</pre>
<p>The trick is to declare the black shadow twice at 3px because once is hardly visible. It&#8217;s transparent enough at that distance to barely register.But the 1px gold shadow gives the letter forms just a hair&#8217;s more heft. It&#8217;s not really any bolder, it just <em>looks</em> bolder.</p>
<p>Haven&#8217;t had a chance to test it in Safari, Chrome, IE6 or Opera but I&#8217;m pretty happy with it in Firefox 3.6 and IE7/8 &#8212; which is more than 97% of the users I have to consider for this project. I&#8217;ll update as I get the chance to test in other browsers.</p>
<p>Edit: Safari&#8217;s good.</p>
<img src="http://crysodenkirk.com/blog/?ak_action=api_record_view&id=1129&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://crysodenkirk.com/blog/2010/07/color-wheels-with-only-css3-and-primary-colors/' rel='bookmark' title='Permanent Link: Color Wheels with only CSS3 and Primary Colors'>Color Wheels with only CSS3 and Primary Colors</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://crysodenkirk.com/blog/2010/05/in-search-of-bolder-type-and-a-font-outline/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Calling all valid CSS &#8220;browser hacks!&#8221;</title>
		<link>http://crysodenkirk.com/blog/2009/09/calling-all-valid-css-browser-hacks/</link>
		<comments>http://crysodenkirk.com/blog/2009/09/calling-all-valid-css-browser-hacks/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 14:20:43 +0000</pubDate>
		<dc:creator>Crys</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://crysodenkirk.com/blog/?p=888</guid>
		<description><![CDATA[I don&#8217;t like to use css hacks. I do use them. In point of fact, I maintain a small list of css hacks so I can easily reference them. But I don&#8217;t like them. Except for the last one on that list, which I think I&#8217;ve used twice total, all those &#8220;hacks&#8221; are actually valid [...]


Related posts:<ol><li><a href='http://crysodenkirk.com/blog/2009/06/well-got-the-upgrade-to-ie8/' rel='bookmark' title='Permanent Link: Well, got the upgrade to IE8.'>Well, got the upgrade to IE8.</a></li>
<li><a href='http://crysodenkirk.com/blog/reference/tricks/' rel='bookmark' title='Permanent Link: Dev Tricks and CSS Hacks'>Dev Tricks and CSS Hacks</a></li>
<li><a href='http://crysodenkirk.com/blog/2009/05/that-kind-of-face/' rel='bookmark' title='Permanent Link: That kind of face?'>That kind of face?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t like to use css hacks. I do use them. In point of fact, I maintain <a href="http://crysodenkirk.com/blog/reference/tricks/">a small list of css hacks</a> so I can easily reference them. But I don&#8217;t like them. Except for the last one on that list, which I think I&#8217;ve used twice total, all those &#8220;hacks&#8221; are actually valid css that simply hook into Explorer&#8217;s irregular DOM and different levels of selector support to target cases that only exist in one browser or another.</p>
<p>Enter IE8 several months ago. Setting aside the fact that I can&#8217;t even get the damn thing to run without going through an initial &#8220;start -> erase all preferences -> close -> start -> close the &#8216;you need to customize!&#8217; window by clicking the X not the ok or it blows up -> open a new tab -> close the first tab&#8221; route (yes, I&#8217;ve done a clean install and tried trashing my prefs), once I finally get to it for testing, I find that its &#8220;Compatibility&#8221; and &#8220;IE7&#8243; rendering is occasionally off of IE7, and the IE8 rendering is different from IE6, IE7 or Firefox&#8230;</p>
<p>And so far, all I&#8217;m seeing for css hacks is invalid css code. Anyone out there yet found a css hack that targets only ie8 that&#8217;s <strong>valid</strong> css? Any way to target its modes in a way that would distinguish IE7 from IE8 Compatibility or IE8&#8242;s version of IE7?</p>
<img src="http://crysodenkirk.com/blog/?ak_action=api_record_view&id=888&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://crysodenkirk.com/blog/2009/06/well-got-the-upgrade-to-ie8/' rel='bookmark' title='Permanent Link: Well, got the upgrade to IE8.'>Well, got the upgrade to IE8.</a></li>
<li><a href='http://crysodenkirk.com/blog/reference/tricks/' rel='bookmark' title='Permanent Link: Dev Tricks and CSS Hacks'>Dev Tricks and CSS Hacks</a></li>
<li><a href='http://crysodenkirk.com/blog/2009/05/that-kind-of-face/' rel='bookmark' title='Permanent Link: That kind of face?'>That kind of face?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://crysodenkirk.com/blog/2009/09/calling-all-valid-css-browser-hacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
