<?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>Terra Duo Blog</title>
	<atom:link href="http://blog.terraduo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.terraduo.com</link>
	<description></description>
	<lastBuildDate>Thu, 01 Jul 2010 20:33:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Truly cross browser CSS3 gradients, with no special hacks or pre-made images</title>
		<link>http://blog.terraduo.com/2010/07/01/truly-cross-browser-css3-gradients/</link>
		<comments>http://blog.terraduo.com/2010/07/01/truly-cross-browser-css3-gradients/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 18:49:31 +0000</pubDate>
		<dc:creator>bruno</dc:creator>
				<category><![CDATA[CSS Tricks]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css tips]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[css3 gradients]]></category>

		<guid isPermaLink="false">http://blog.terraduo.com/?p=23</guid>
		<description><![CDATA[Seen as this is my first post here at the Terra Duo blog, I&#8217;d like to introduce myself. My name&#8217;s Bruno, and I run Terra Duo. In case you don&#8217;t know, we&#8217;re an Irish website development firm. In this blog &#8230; <a href="http://blog.terraduo.com/2010/07/01/truly-cross-browser-css3-gradients/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Seen as this is my first post here at the Terra Duo blog, I&#8217;d like to introduce myself. My name&#8217;s Bruno, and I run Terra Duo. In case you don&#8217;t know, we&#8217;re an Irish website development firm. In this blog I&#8217;ll be talking about how we do things, and about the development of some web applications we&#8217;re working on. I&#8217;ll also be giving my opinion on website development, as well as some tips and tricks to help you out.</p>
<p>Today, I want to talk about making CSS3 Gradients work on every browser. These are very new (and are <a href="http://dev.w3.org/csswg/css3-images/#linear-gradients">part of a working draft</a>), and only supported in Chrome, Safari and Firefox 3.6+. They are supported in Internet Explorer 5.5+ as well, with their little proprietary filter, but they can only be used on elements with display:block, as far as I know (I couldn&#8217;t get them to work on an inline element).</p>
<p>Even if we decided to stick with only using these gradients in block elements, there is another problem. There are other browsers, such as Opera, that don&#8217;t support these gradients, and older versions of browsers don&#8217;t support them either. We could use an image, but I don&#8217;t want to be creating new images every time I want to use a gradient. It&#8217;d be far too cumbersome. So I decided to get the computer to do it for me.</p>
<p>I wrote a PHP script that generates gradients on the fly. So far, it works with vertical or horizontal linear gradients. It&#8217;s missing support for color-stops and caching of the generated gradients both on the browser and the server, but I&#8217;ll be adding those features soon, if there&#8217;s a demand for it. Also, if anyone has any suggestions/ideas, I&#8217;d love to hear about them in the comments section.</p>
<p>The code is very simple:</p>
<pre class="brush: css">
.gradient {
background: url(&#039;gradient.php?vertical=true&amp;from=FF0000&amp;to=00FF00&amp;height=600&#039;) repeat-x;
background: -moz-linear-gradient(top, #FF0000, #00FF00);
background: -webkit-gradient(linear, left top, left bottom, from(#FF0000), to(#00FF00));
width: 800px;
height: 600px;
}
</pre>
<p>Please note, I&#8217;m only using 600px as the height of the element for demonstration purposes. And there you go. Firstly, we link to the gradient.php script, and afterwards, we use browser-specific gradient syntax. On browsers that don&#8217;t support CSS3 gradients, the gradient.php script is called. On browsers that do, it&#8217;s ignored, which means it doesn&#8217;t needlessly call the script or anything of the sort.</p>
<p>There&#8217;s one thing to bear in mind: in vertical gradients gradient.php requires a height to be provided and in horizontal gradients it requires a width. It&#8217;s a minor inconvenience. I could use JavaScript to figure out the height/width of the element, but it&#8217;s not worth the performance hit that that would bring.</p>
<p>If you don&#8217;t have PHP on your server, or you just want to experiment, I&#8217;ve put the gradient.php script up on Terra Duo for everyone to make use of freely.</p>
<p>To use it, simply point the URL in your CSS to http://labs.terraduo.com/gradient.php. If you use it, you&#8217;ll instantly get access to any updates I make to the script. I don&#8217;t plan on taking it down, but if anything happens and I&#8217;m forced to, I&#8217;ll post here and let you all know in advance.</p>
<p><a href="http://labs.terraduo.com/cross-browser-gradients.html">View the demo</a></p>
<p><a href="http://labs.terraduo.com/gradient.zip">Download gradient.php</a></p>
<p>That&#8217;s it for now. Let me know what you think, I&#8217;d love to hear your opinion.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.terraduo.com/2010/07/01/truly-cross-browser-css3-gradients/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
