<?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>ThinkRobot &#187; css</title>
	<atom:link href="http://think-robot.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://think-robot.com</link>
	<description>Design &#38; Development Blog</description>
	<lastBuildDate>Tue, 09 Aug 2011 16:56:32 +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>Using TextMate for easier CSS3</title>
		<link>http://think-robot.com/2010/09/using-textmate-for-easier-css3/</link>
		<comments>http://think-robot.com/2010/09/using-textmate-for-easier-css3/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 19:54:15 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[transform]]></category>

		<guid isPermaLink="false">http://think-robot.com/?p=236</guid>
		<description><![CDATA[Over the past couple of years Webkit has popularised many fancy new CSS tricks. Amongst these the ability to rotate an element is certainly one of the most useful. Fortunately it&#8217;s also widely supported in other browsers, even in lowly old IE right back to version 5.5. The &#8216;modern&#8217; browsers support this with a reasonably [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past couple of years Webkit has popularised many fancy new CSS tricks. Amongst these the ability to rotate an element is certainly one of the most useful. Fortunately it&#8217;s also widely supported in other browsers, even in lowly old IE right back to version 5.5. The &#8216;modern&#8217; browsers support this with a reasonably simple syntax</p>
<p><span id="more-236"></span></p>
<pre><code>[-vendor-prefix-]transform: rotate([angle]deg);</code></pre>
<p>so to use this to rotate an element by 15 degrees in Webkit (e.g. Safari, Chrome), Mozilla and Opera you&#8217;d use</p>
<pre><code>-moz-transform: rotate(15deg);
-o-transform: rotate(15deg);
-webkit-transform: rotate(15deg);
transform: rotate(15deg); </code></pre>
<p>We include the rule without a vendor prefix so that once browsers start to implement this without requiring the use of it our CSS will be ready.</p>
<p>Sadly the syntax for Internet Explorer is a little more cumbersome. It uses the	DXImageTransform.Microsoft.Matrix filter which is a little cryptic, but fortunately quite well documented on <a href="http://msdn.microsoft.com/en-us/library/ms533014(VS.85).aspx">MSDN</a>. We also need 2 variations of this filter, one for IE &lt; 8 and another for IE ≥ 8.</p>
<p>To use the filter the first thing we need to do is convert our angle into radians (angle in radians = angle in degrees * π / 180) then we work with the sine and cosine of this angle:</p>
<pre><code>DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand',M11=[cos(angle)],M12=[-sin(angle)],M21=[sin(angle)],M22=[cos(angle)]);</code></pre>
<p>So if we take our rotate by 15 degrees example from above we&#8217;d end up with the following to cover all IE versions:</p>
<pre><code>filter:progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand',M11=0.965925826289068,M12=-0.258819045102521,M21=0.258819045102521,M22=0.965925826289068);
-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand',M11=0.965925826289068,M12=-0.258819045102521,M21=0.258819045102521,M22=0.965925826289068)";</code></pre>
<p>Obviously we don&#8217;t really want to have to whip out a calculator and type 6 lines of CSS every time we want to rotate an element. To save myself a little time I created a <a href="http://www.macromates.com">TextMate</a> bundle that simplifies the process a bit. This bundle allows me to type the standard syntax.</p>
<pre><code>transform:rotate(-10deg)</code></pre>
<p>Then hit a keyboard shortcut to have TextMate fill in the rest.</p>
<p>To add this bundle go to Bundles &gt; Bundle Editor &gt; Show Bundle Editor</p>
<p>Select CSS from the list on the left and side of the editor and select Add new command from the buttons at the bottom. Paste the following into the Command(s) field</p>
<pre><code>#!/usr/bin/env ruby
line = $stdin.read
if line =~ /(\s*)transform\s*:\s*rotate\s*\(\s*(-?[0-9]+)\s*deg\s*\)/i
	rad = $2.to_i * Math::PI / 180
	cos = Math.cos(rad)
	sin = Math.sin(rad)

	print $`
	print $1 + "-moz-transform:rotate(" + $2 + "deg);\n"
	print $1 + "-o-transform:rotate(" + $2 + "deg);\n"
	print $1 + "-webkit-transform:rotate(" + $2 + "deg);\n"
	print $1 + "transform:rotate(" + $2 + "deg);\n"
	print $1 + "filter:progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand',M11=" + 	cos.to_s + ",M12=" + (sin * -1).to_s + ",M21=" + sin.to_s + ",M22=" + cos.to_s + ");\n"
	print $1 + "-ms-filter:\"progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand',M11=" + cos.to_s + ",M12=" + (sin * -1).to_s + ",M21=" + sin.to_s + ",M22=" + cos.to_s + ")\";\n"
	print $'
else
	print line
end</code></pre>
<p>Then select Save: Nothing, Input: Selected text or Line and Output: Replace Selected Text. Now you need to setup how you&#8217;ll trigger this. Select Activation: Key Equivalent and then enter the keyboard shortcut you&#8217;d like &#8211; I&#8217;m using <kbd>Shift + Cmd + R</kbd></p>
<p><img class="alignleft size-medium wp-image-237" style="margin-right: 1em; margin-bottom: 1em;" title="bundle-editor" src="http://think-robot.com/wp-content/uploads/2010/09/bundle-editor-300x180.png" alt="bundle-editor" width="300" height="180" /></p>
<p>Finally close the bundle editor and select Bundle &gt; Bundle Editor &gt; Reload Bundles and you should be good to go.</p>
<p>Of course there are many other CSS3 properties that up until now have been implemented using vendor prefixes in some browsers. We can simplify creating these with some more TextMate snippets. I&#8217;ll include a couple of examples here, firstly box-shadow. Webkit and Mozilla support this using a vendor prefix, Opera and Internet Explorer 9 use the standard property. The syntax is:</p>
<pre><code>[-vendor-prefix-]box-shadow: [x offset] [y offset] [blur radius] [color];</code></pre>
<p>So to create a drak grey shadow just offset slightly below an element we might use something like this:</p>
<pre><code>-moz-box-shadow: 0 2px 5px #333;
-webkit-box-shadow: 0 2px 5px #333;
box-shadow: 0 2px 5px #333;</code></pre>
<p>For the TextMate snippet we&#8217;ll use tab triggers and placeholders &#8211; this let you type a keyword and hit the tab key to insert the text of the snippet with placeholder values inserted with the first placeholder selected so you can fill in a value, tabbing again moves onto the next placeholder and so on. Open up the bundle editor from Bundles &gt; Bundle Editor &gt; Show Bundle Editor and select to add a new snippet under the CSS section. Paste the following into the snippet window:</p>
<pre><code>-moz-box-shadow: ${1:x offset} ${2:y offset} ${3:blur radius} ${4:color};
-webkit-box-shadow: ${1:x offset} ${2:y offset} ${3:blur radius} ${4:color};
box-shadow: ${1:x offset} ${2:y offset} ${3:blur radius} ${4:color};</code></pre>
<p>Select Activation: Tab Trigger and type in the word box as the trigger. Name this snippet box-shadow and exit the bundle editor. Relaod bundles to give it a try. In a CSS file now type box and hit the tab key. The following should be inserted:</p>
<pre><code>-moz-box-shadow: x offset y offset spread color;
-webkit-box-shadow: x offset y offset spread color;
box-shadow: x offset y offset spread color;</code></pre>
<p>with the x offset text highlighted. Starting to type will overwrite all the x offset placeholders, hitting tab again will move onto the y offset. Easy. You could add another snippet that provided box shadows using the inset modifier.</p>
<pre><code>[-vendor-prefix-]box-shadow: inset [x offset] [y offset] [blur radius] [color];</code></pre>
<p>border-radius might also be a good candidate for a time-saving snippet. Probably the most common use of this is where we want to specify equally rounded corners on all round our box. We could use the same style of tab triggered snippet as with the box-shadow example. The snippet would be very simple with just a single placeholder &#8211; something like this:</p>
<pre><code>-moz-border-radius: ${1:1em};
-webkit-border-radius: ${1:1em};
border-radius: ${1:1em};</code></pre>
<p>TextMate is a wonderful editor and snippets really do make this stuff a breeze.</p>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2011/06/wordpress-update-permission-issues/" rel="bookmark">WordPress update permission issues</a></li><li><a href="http://think-robot.com/2008/10/display-meetings-from-entourage-using-geektool/" rel="bookmark">Display Meetings From Entourage Using GeekTool</a></li><li><a href="http://think-robot.com/2008/11/wordpress-nextgen-gallery-tweak/" rel="bookmark">WordPress NextGen gallery tweak</a></li><li><a href="http://think-robot.com/2008/08/opensuse-11-on-lenovo-thinkpad-x61-tablet-pc/" rel="bookmark">openSUSE 11 on Lenovo Thinkpad X61 (tablet pc)</a></li><li><a href="http://think-robot.com/2010/08/mantis-theme-mock-up/" rel="bookmark">Mantis theme mock-up</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2010/09/using-textmate-for-easier-css3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Firefox ignores tabs but not spaces in a pre tag</title>
		<link>http://think-robot.com/2009/02/firefox-ignores-tabs-but-not-spaces-in-a-pre-tag/</link>
		<comments>http://think-robot.com/2009/02/firefox-ignores-tabs-but-not-spaces-in-a-pre-tag/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 08:47:27 +0000</pubDate>
		<dc:creator>Joanna</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[styling]]></category>
		<category><![CDATA[tags]]></category>

		<guid isPermaLink="false">http://www.think-robot.com/?p=26</guid>
		<description><![CDATA[Sometimes HTML can be so frustrating. I love tabs in my code, however while styling the new blog theme I run into a Firefox only problem &#8211; despite being in a &#60;pre&#62; tag tabs would be ignored. I found references to this werid behaviour, however it seemed to affect the displayed indentation for both tabs [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes HTML can be so frustrating. I love tabs in my code, however while styling the new blog theme I run into a Firefox only problem &#8211; despite being in a <strong>&lt;pre&gt;</strong> tag tabs would be ignored.</p>
<p>I found <a href="http://www.sohtanaka.com/web-design/styling-pre-tags-with-css-code-block/" target="_blank">references to this werid behaviour</a>, however it seemed to affect the displayed indentation for both tabs and spaces, and not ignore one while adhering to the other.</p>
<p>The solution actually turned out quite simple. The only thing you needed was an element inside the <strong>&lt;pre&gt;</strong> tag with the <strong>display: block;</strong> property set. And you don&#8217;t even need to move the padding away from the <strong>&lt;pre&gt;</strong> tag.</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=7e114744-0059-415e-a3df-90a95b81a55a" alt="" /></div>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2009/04/week-of-the-month-in-mysql/" rel="bookmark">Week of the Month in Mysql</a></li><li><a href="http://think-robot.com/2008/11/nested-sortable-using-jtree-clickable-links/" rel="bookmark">Nested sortable using jTree - clickable links</a></li><li><a href="http://think-robot.com/2009/02/how-to-use-the-strong-ownership-list/" rel="bookmark">How To Use the Strong Ownership List</a></li><li><a href="http://think-robot.com/2009/02/improving-design-by-using-a-grid-system/" rel="bookmark">Improving Design by Using a Grid System</a></li><li><a href="http://think-robot.com/2011/03/jquery-multiple-events-without-default-behaviour/" rel="bookmark">jQuery Multiple Events Without Default Behaviour</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2009/02/firefox-ignores-tabs-but-not-spaces-in-a-pre-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

