<?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>fakedarren &#187; CSS</title>
	<atom:link href="http://blog.fakedarren.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fakedarren.com</link>
	<description>Adventures in teh interwebz</description>
	<lastBuildDate>Sat, 14 Aug 2010 12:58:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Embedding videos a different way</title>
		<link>http://blog.fakedarren.com/2010/06/embedding-videos-a-different-way/</link>
		<comments>http://blog.fakedarren.com/2010/06/embedding-videos-a-different-way/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 14:19:20 +0000</pubDate>
		<dc:creator>fakedarren</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://blog.fakedarren.com/?p=288</guid>
		<description><![CDATA[I&#8217;m starting a new project for a client over the coming weeks and one of the things I want to do during the project is make some improvements to the templates we use as the basis for most of our work.
One of the things that I really wanted to change is the way we deal [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m starting a new project for a client over the coming weeks and one of the things I want to do during the project is make some improvements to the templates we use as the basis for most of our work.</p>
<p>One of the things that I really wanted to change is the way we deal with embedding videos. I was looking to get rid of the dependency on JavaScript (<a href="http://code.google.com/p/swfobject/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/swfobject/?referer=');">SwfObject</a>). But in order to do that I&#8217;d have to solve two problems first.</p>
<p>The three reasons we started using SwfObject at work in the first place were:</p>
<ul>
<li>You used to have to &#8216;click to activate&#8217; Flash videos in our good friend IE. <a href="http://msdn.microsoft.com/en-us/ie/bb969055.aspx" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/ie/bb969055.aspx?referer=');">Luckily this is no longer an issue</a>.</li>
<li>It allowed you to pass w3c validation. Now, I do not care if a page does not validate because of an embedded YouTube video, but our clients do, and they pay the bills.</li>
<li>We wanted to be able to size the embedded content to fit the page layout. We could use JavaScript to calculate the dimensions before we injected it into the document.</li>
</ul>
<h2>Embedding without &lt;embed&gt;</h2>
<p>So the first thing we&#8217;d need is the HTML to embed a video without the &lt;embed&gt; tag, which is what breaks validation.</p>
<p><iframe style="width: 540px; height: 275px;" frameborder="0" src="http://jsfiddle.net/boske/jUJLH/embedded/html,result"></iframe></p>
<p>Nice! That was easy! I&#8217;ve tested this in all browsers on XP, Vista, Windows 7, and OSX &#8211; no problems!</p>
<h2>Sizing video elements with just CSS</h2>
<p>This one is a little bit trickier. First off we&#8217;re going to need a box that wraps the video element that maintains an aspect ratio; that is, one where the height adjusts to the width.</p>
<p>To do this, we&#8217;ll use a handy trick &#8211; using padding. Padding is cool. If you set the width of an element to 100%, then the padding top / bottom can be expressed as a percentage of this width. So for instance, if you had a column that is 400px wide, and you give an element inside it a width of 100% and a padding-top of 25%, it would get padding-top of 100px.</p>
<p><a href="http://jsfiddle.net/fnKfP/" onclick="pageTracker._trackPageview('/outgoing/jsfiddle.net/fnKfP/?referer=');">Here&#8217;s an example of this in action</a>. Resize the browser window, and you can see the height will always stay 25% of the width.</p>
<p>So now we have a way to create a placeholder for our video. We&#8217;ll position our video inside using absolute positioning. A couple more things:</p>
<ul>
<li>An extra sleeve element is required for our dear friend IE</li>
<li>The padding bottom to use is 56.25% for the ratio (it&#8217;s a 16:9 video, so it&#8217;s 9 / 6 = 0.5625), for 3:4 ratio videos you&#8217;d use 75%</li>
<li>The padding top is for the player&#8217;s controls (25px in this case)</li>
<li>You have to set the percentage on the padding-bottom, again, for IE</li>
</ul>
<p>Here&#8217;s the finished code. You can open it up in jsFiddle and resize the browser window to see it automatically resizing to the content.</p>
<p><iframe style="width: 540px; height: 385px;" frameborder="0" src="http://jsfiddle.net/boske/7hGcX/embedded/result,html,css"></iframe></p>
<p>So&#8230;what do you think? Do you know of any problems with this approach? Let me know in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fakedarren.com/2010/06/embedding-videos-a-different-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cross-browser CSS gradients</title>
		<link>http://blog.fakedarren.com/2010/01/cross-browser-css-gradients/</link>
		<comments>http://blog.fakedarren.com/2010/01/cross-browser-css-gradients/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 15:23:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://blog.fakedarren.com/?p=233</guid>
		<description><![CDATA[Firefox 3.6 is very close to release (it&#8217;s currently in its first release candidate) and once it lands every browser (even IE) has support for gradients in pure CSS.
This will be incredibly useful. As we add more and more JavaScript and rich media to web pages, performance is affected. One easy way we can mitigate [...]]]></description>
			<content:encoded><![CDATA[<p>Firefox 3.6 is very close to release (it&#8217;s currently in its first release candidate) and once it lands every browser (even IE) has support for gradients in pure CSS.</p>
<p>This will be incredibly useful. As we add more and more JavaScript and rich media to web pages, performance is affected. One easy way we can mitigate the effect this has is to leverage the power of CSS to reduce the number of background images we use; for instance for rounded corners and gradients. Border-radius is still not implemented in IE (rumoured to be included in IE12 when it&#8217;s out in 2043) but gradients are, and we should all start using them now.</p>
<h2>Example</h2>
<p>Here&#8217;s a real-life example. This is just a link; this style can be applied to any element; &lt;button&gt;, &lt;input type=&#8221;submit&#8221;&gt;. &lt;a&gt;, whatever.</p>
<p><a class="sexybutton" href="#">I&#8217;m a button</a></p>
<p>Dependent on what browser you are using, it will look different.</p>
<h2>How it looks cross-browser</h2>
<h4>Firefox 3.5</h4>
<p><img class="alignnone size-full wp-image-247" title="CSS3 Buttons in FF3.5" src="http://blog.fakedarren.com/wp-content/uploads/2010/01/ff3.5buttons.jpg" alt="CSS3 Buttons in FF3.5" width="250" height="26" /></p>
<h4>Firefox 3.6</h4>
<p><img class="alignnone size-full wp-image-248" title="CSS3 buttons in FF3.6" src="http://blog.fakedarren.com/wp-content/uploads/2010/01/ff3.6buttons.jpg" alt="CSS3 buttons in FF3.6" width="250" height="26" /></p>
<h4>Internet Explorer</h4>
<p><img class="alignnone size-full wp-image-249" title="CSS3 buttons in IE" src="http://blog.fakedarren.com/wp-content/uploads/2010/01/iebuttons.jpg" alt="CSS3 buttons in IE" width="250" height="26" /></p>
<h4>Safari and Chrome</h4>
<p><img class="alignnone size-full wp-image-250" title="CSS3 buttons in WebKit" src="http://blog.fakedarren.com/wp-content/uploads/2010/01/webkitbuttons.jpg" alt="CSS3 buttons in WebKit" width="250" height="26" /></p>
<h2>The CSS</h2>
<pre class="css">.sexybutton {
  background: #DEDEDE;
  background: -moz-linear-gradient(top, #FFF, #888);
  background: -webkit-gradient(linear, left top, left bottom, from(#FFF), to(#888));
  border: 1px solid #D6D6D6;
  color: #666;
  display: inline-block;
  filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#FFFFFF', EndColorStr='#888888');
  font: bold 1.3em/22px Helvetica, Arial, sans-serif;
  height: 22px;
  padding: 0 10px;
  text-decoration: none;
  text-shadow: 0 1px 0 #FFF;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
}
.sexybutton:HOVER {
  background: #BEBEBE;
  background: -moz-linear-gradient(top, #DDD, #666);
  background: -webkit-gradient(linear, left top, left bottom, from(#DDD), to(#666));
  border: 1px solid #B6B6B6;
  color: #444;
  filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#DDDDDD', EndColorStr='#666666');
  text-shadow: 0 1px 0 #DDD;
}</pre>
<h2>Summary</h2>
<p>I&#8217;m absolutely convinced that using CSS gradients is now viable. Gradients do make a difference, when used well, to the aesthetic of a webpage &#8211; more so, in my opinion, than a few pixels of rounded corner.</p>
<p>I&#8217;m also convinced that as we put more and more JavaScript onto our pages the performance hit of making a design work perfectly in all browsers gets less and less preference. We need to start leveraging CSS effects wherever possible; it is not fair to a user to have to wait for 100k of gradient images (and the extra HTML required) for something that can be represented by much less CSS.</p>
<p>I love this way of rendering gradients and will definitely be using it in my future work.</p>
<h3>Some links</h3>
<ul>
<li><a href="http://webkit.org/blog/175/introducing-css-gradients/" onclick="pageTracker._trackPageview('/outgoing/webkit.org/blog/175/introducing-css-gradients/?referer=');">Safari gradients</a></li>
<li><a href="http://hacks.mozilla.org/2009/11/css-gradients-firefox-36/" onclick="pageTracker._trackPageview('/outgoing/hacks.mozilla.org/2009/11/css-gradients-firefox-36/?referer=');">Firefox gradients</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms532997(VS.85).aspx?ppud=4" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/ms532997_VS.85_.aspx?ppud=4&amp;referer=');">Internet Explorer gradients</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.fakedarren.com/2010/01/cross-browser-css-gradients/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How I write my CSS, and why</title>
		<link>http://blog.fakedarren.com/2009/10/how-i-write-my-css-and-why/</link>
		<comments>http://blog.fakedarren.com/2009/10/how-i-write-my-css-and-why/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 18:14:42 +0000</pubDate>
		<dc:creator>fakedarren</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://blog.fakedarren.com/?p=14</guid>
		<description><![CDATA[I work with a team of awesome Front End Developers, who&#8217;s main job it is to take the designs and code it into accessible HTML and CSS. There are currently 4 of us, and a couple more have been and gone.
We all kind of agree on how we structure our HTML &#8211; in a way [...]]]></description>
			<content:encoded><![CDATA[<p>I work with a team of awesome Front End Developers, who&#8217;s main job it is to take the designs and code it into accessible HTML and CSS. There are currently 4 of us, and a couple more have been and gone.</p>
<p>We all kind of agree on how we structure our HTML &#8211; in a way that is semantically sound, and accessible &#8211; but one thing I&#8217;ve noticed is how different my views on how I structure my CSS are compared to my colleagues. I thought I&#8217;d explain myself, and hope to gain some insight into what others think about my style, given my reasons for choosing it.</p>
<h2>I always capitalise my tags</h2>
<p>I can&#8217;t actually remember when I started doing this &#8211; I guess it was right from the start &#8211; but I always capitalise any HTML element in my CSS. For instance:</p>
<pre class="css:twilight">DIV LI.selected A</pre>
<p>I do this because I really believe it&#8217;s more readable. IDs are very recognisable because of the # sign &#8211; classes, when quickly scanning CSS, are less easy to spot, because the period isn&#8217;t the most noticeable of characters. By capitalising my tag names, I can easily differentiate between IDs, tags, and classes.</p>
<h2>I always order my properties alphabetically</h2>
<p>When I mention this I normally get accused of having horrific OCD, which is probably quite true; a lot of people prefer to group properties by type; as in, top, left, right or border, padding, margin.</p>
<p>My argument for this is that if you order alphabetically you eliminate two possible problems; first of all, duplicates (however unlikely); second of all, gotchas like specifying a font rule after a line height. Compound properties (like font, background etc) implicitly include other rules in them. The main one &#8211; font declaration implicitly includes line-height.</p>
<pre class="css:twilight">line-height: 16px;
font: 1.2em Helvetica, Arial, sans-serif;</pre>
<p>In the above example, the line-height declaration means nothing. It is overriden by the font declaration. Ordering alphabetically eliminates this as a potential problem.</p>
<p>It also means when I&#8217;m looking quickly for something I know whether to look at the beginning or end of a set of properties.</p>
<h2>Single-line declarations FTL</h2>
<p>This is something that me and some of my colleagues can agree to disagree on. I HATE single line declarations. I find them so unreadable. One of my first experiences with single-line CSS was this horror show of a 2,000 line stylesheet &#8211; each one on a single line. First off &#8211; no way should you have 2,000 lines of CSS in one file &#8211; but the single line format killed me.</p>
<p>5 or so years ago this could have been considered best practice, given the prevalence of dial-up.  Now with broadband, whilst abusing a user&#8217;s connection is not encouraged, it&#8217;s not so much of a problem. The extra line breaks aren&#8217;t going to add up to much in terms of file size &#8211; so do yourself a favour and put your properties on separate lines.</p>
<p>It&#8217;s worth noting that whenever you see a &#8216;CSS formatter&#8217; (like <a title="Floele CSS Formatter" href="http://floele.flyspray.org/csstidy//css_optimiser.php" onclick="pageTracker._trackPageview('/outgoing/floele.flyspray.org/csstidy//css_optimiser.php?referer=');">this one</a>) if you format it as &#8216;readable&#8217; then it takes the multi-line approach. Single-line declarations are rubbish.</p>
<p>Also the argument that it&#8217;s harder to find a rule if you don&#8217;t put them all on one line is, in my eyes, invalid &#8211; Firebug tells me exactly what line it&#8217;s on.</p>
<h2>I put IE specific hacks in separate stylesheets</h2>
<p>Again, I find it extremely annoying when people put IE hacks in the stylesheets. They should be separate. I have a whole blog post in the works dedicated to IE hacks so I won&#8217;t go into any details here <img src='http://blog.fakedarren.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>I indent my CSS to show when a declaration is a child of another</h2>
<pre class="css:twilight">UL {
  list-style: none;
  margin: 0;
  padding: 0;
}
    UL LI  {
      color: #CCC;
    }</pre>
<p>By doing this I can clearly see what rules belong to what definition &#8211; again I chalk this down as personal preference but I find indenting like this to be much more readable.</p>
<h2>Use the server to compile your CSS &#8211; then break it up into chunks</h2>
<p>If you are working on a site that has so much CSS that it&#8217;s a performance problem to have lots of small, manageable CSS files, you need to invest the time on building something that collates and compresses them for you. This is NEVER an excuse to not break your CSS up into small manageable chunks, but rather a failure to use the tools you have to make something manageable and maintainable.</p>
<p>I&#8217;ll definitely be doing some posts in the future about this subject with simple C# and PHP examples.</p>
<h2>That&#8217;s how I do it &#8211; what about you?</h2>
<p>That&#8217;s how and why I structure my CSS like I do. I find that having a structure for CSS is something that a lot of people don&#8217;t do &#8211; it&#8217;s often an afterthought for a lot of Front End developers I know. I&#8217;d love to know what you think of my eccentric CSS-based behaviour and what works well for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fakedarren.com/2009/10/how-i-write-my-css-and-why/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
