<?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>Fetched from hammerspace</title>
	<atom:link href="http://hammerspace.co.uk/feed" rel="self" type="application/rss+xml" />
	<link>http://hammerspace.co.uk</link>
	<description>Web, Words and Photography</description>
	<lastBuildDate>Mon, 16 Apr 2012 10:55:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Responsive Design in Internet Explorer 10 / Windows 8</title>
		<link>http://hammerspace.co.uk/2012/04/responsive-design-in-internet-explorer-10-windows-8</link>
		<comments>http://hammerspace.co.uk/2012/04/responsive-design-in-internet-explorer-10-windows-8#comments</comments>
		<pubDate>Tue, 10 Apr 2012 22:18:09 +0000</pubDate>
		<dc:creator>David Jonathan Marland</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[responsive design]]></category>
		<category><![CDATA[windows 8]]></category>

		<guid isPermaLink="false">http://hammerspace.co.uk/?p=170</guid>
		<description><![CDATA[You&#8217;re probably well aware of responsive web design; a principle where you no longer build your website to a fixed 960 pixels wide, but allow it to adapt and flex to fit wherever it happens to be. There is a massive range of screen sizes from phone to smart phone to tablet to desktop and [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;re probably well aware of <a href="http://www.alistapart.com/articles/responsive-web-design/" title="Responsive web design">responsive web design</a>; a principle where you no longer build your website to a fixed 960 pixels wide, but allow it to adapt and flex to fit wherever it happens to be.</p>
<p>There is a massive range of screen sizes from phone to smart phone to tablet to desktop and even black and white devices like the Amazon Kindle. Each of these comes with their own set of challenges but it looks like there is a new kid coming up the block.</p>
<p><img src="https://lh6.googleusercontent.com/-W_ATBC9jgUM/T4SrEinHYtI/AAAAAAAAANk/MCY2o09kVYM/s800/Windows_8_Consumer_Preview_Start_Screen.png" alt="Windows 8 Start screen" /><br />
<a href="http://windows.microsoft.com/en-US/windows-8/consumer-preview" title="Windows 8">Windows 8</a> offers a radically new desktop/tablet experience and will support a range of hardware devices. Application developers for windows 8 will need to be aware of <a href="http://blogs.msdn.com/b/b8/archive/2012/03/21/scaling-to-different-screens.aspx" title="Scaling to different screens">scaling for different screens</a>.</p>
<p>Note: At the time of writing Windows 8 is still in Consumer preview so any of this is subject to change before general release.</p>
<h2>Internet Explorer 10</h2>
<p>In testing Internet Explorer 10 on Windows 8 I noticed that when you snap a site to the side the page was simply zooming out making it unreadable. It was quite a challenge to discover why but it appears that Internet Explorer 10 <a href="http://msdn.microsoft.com/library/ie/hh708740.aspx#Example_usage__Opting_out_of_automatic_scaling" title="Device adaptation">zooms the page out</a> when the width is less than 1024px. This may also affect portrait orientation but I am unable to confirm at present as I have the preview on my standard laptop.</p>
<p>This effect is irritating for those who spent a fair bit of time and effort working on their responsively designed pages. You can see the effect on <a href="http://hammerspace.co.uk/projects/ie10responsive/" title="Demo 1">this demo page</a>. A picture of what happens is shown below:</p>
<p><img src="https://lh3.googleusercontent.com/-NXiG5TjcC40/T4SrElwIALI/AAAAAAAAANk/A0QYB3vU-Us/s800/1.jpg" alt="Screenshot 1" /><br />
<em>Excuse the photograph; I couldn&#8217;t get a screenshot in Windows 8 + Mac keyboard.</em></p>
<p>The site on the left is zoomed out and unusable.</p>
<h2>Solution</h2>
<p>As I discovered buried in the <a href="http://msdn.microsoft.com/library/ie/hh708740.aspx#Example_usage__Opting_out_of_automatic_scaling" title="Device adaptation">device adaptation</a> page there is a simple solution that tells Internet Explorer 10 to disable its automatic scaling and adhere to your responsive designs. Simply add the following to your CSS file:</p>
<pre class="wp-code-highlight prettyprint">
@-ms-viewport { width: device-width; }
</pre>
<p>You can see this in action in <a href="http://hammerspace.co.uk/projects/ie10responsive/fixed.html" title="Demo 2">the second demo page</a>. The change has produced the desired effect in a snapped window (on the left):<br />
<img src="https://lh4.googleusercontent.com/-_G-maUwelGQ/T4SrE9REKII/AAAAAAAAANk/BxknczcB9Gk/s800/2.jpg" alt="Screenshot 2" /></p>
<p><strong>Update:</strong> <a href="https://github.com/h5bp/html5-boilerplate/issues/1047#issuecomment-5071828">necolas</a> makes a good point that it is not optimal to have to do this and it should be considered an IE10 bug. <a href="https://github.com/h5bp/html5-boilerplate/issues/1047">Further discussion here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://hammerspace.co.uk/2012/04/responsive-design-in-internet-explorer-10-windows-8/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS3 gradients with transparency</title>
		<link>http://hammerspace.co.uk/2012/02/css3-gradients-with-transparency</link>
		<comments>http://hammerspace.co.uk/2012/02/css3-gradients-with-transparency#comments</comments>
		<pubDate>Sat, 11 Feb 2012 20:47:39 +0000</pubDate>
		<dc:creator>David Jonathan Marland</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[alpha transparent]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[gradients]]></category>
		<category><![CDATA[rgba]]></category>

		<guid isPermaLink="false">http://hammerspace.co.uk/?p=155</guid>
		<description><![CDATA[As you are probably aware CSS3 introduces gradient backgrounds allowing some quite creative designs. However I&#8217;ve been bitten by an interesting quirk when using transparency in gradients. You&#8217;d expect that to create a gradient which fades out from a certain colour you&#8217;d just use: background: linear-gradient(top,#FFFFFF 0%,transparent 100%); See Example 2 for a working demo. [...]]]></description>
			<content:encoded><![CDATA[<p>As you are probably aware CSS3 introduces <a href="http://gradients.glrzad.com/" title="Gradient Background Generator">gradient</a> <a href="http://hallofhavoc.com/2011/08/how-to-use-css3-gradients-for-various-browsers/">backgrounds</a> allowing some quite creative designs.</p>
<p>However I&#8217;ve been bitten by an interesting quirk when using transparency in gradients. You&#8217;d expect that to create a gradient which fades out from a certain colour you&#8217;d just use:</p>
<pre class="wp-code-highlight prettyprint">
background: linear-gradient(top,#FFFFFF 0%,transparent 100%);
</pre>
<p>See <a href="/projects/gradient/">Example 2</a> for a working demo.</p>
<p><img src="http://hammerspace.co.uk/wp-content/uploads/2012/02/Screen-Shot-2012-02-11-at-20.35.09-300x147.png" alt="" title="Ugly Grey" width="300" height="147" class="alignnone size-medium wp-image-158" /></p>
<p>The effect is not as desired as browsers do not treat the value [transparent] as you might intuitively expect. The CSS3 colour spec <a href="http://www.w3.org/TR/css3-color/#transparent-def">states</a> that [transparent] can be considered a shorthand for transparent black, rgba(0,0,0,0).</p>
<p>Therefore the browsers are actually fading from white to black independently to fading from opaque to transparent. If you are not aware of this then it&#8217;s easy to end up with the ugly grey in the middle of your gradient. The <a href="http://dev.w3.org/csswg/css3-images/#color-stop-syntax">CSS3 Images spec</a> (Last Call Working Draft as of 11th Feb 2012) shows how this should not be the case. At present only Opera appears to use premultiplied values and behave correctly, fading out without going via black.</p>
<p><strong>Workaround</strong><br />
Until the browsers support the correct implementation the simple (obvious) workaround is to resort to rgba. This isn&#8217;t too much of a drawback as rgba is supported in all the browsers that support gradient backgrounds. You just need to remember that the red,green and blue values are the same in both stops and the alpha value changes from 1 to 0.</p>
<pre class="wp-code-highlight prettyprint">
background: linear-gradient(top,rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%);
</pre>
<p><img src="http://hammerspace.co.uk/wp-content/uploads/2012/02/Screen-Shot-2012-02-11-at-20.37.06.png" alt="" title="Cleaner fade out" width="266" height="155" class="alignnone size-full wp-image-160" /></p>
<p>See <a href="/projects/gradient/">example 3 on the demo page</a> for a live example</p>
]]></content:encoded>
			<wfw:commentRss>http://hammerspace.co.uk/2012/02/css3-gradients-with-transparency/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Truncate at space, Zend View Helper</title>
		<link>http://hammerspace.co.uk/2011/10/truncate-at-space-zend-view-helper</link>
		<comments>http://hammerspace.co.uk/2011/10/truncate-at-space-zend-view-helper#comments</comments>
		<pubDate>Wed, 19 Oct 2011 23:19:19 +0000</pubDate>
		<dc:creator>David Jonathan Marland</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[truncate]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://hammerspace.co.uk/?p=121</guid>
		<description><![CDATA[When writing web applications you may frequently find the need to truncate strings. In php you could just use substr but that could be dangerous. Therefore the safest idea is to truncate back to the nearest space. The code below is a Zend View Helper, constructed in a way to read cleanly in the page. [...]]]></description>
			<content:encoded><![CDATA[<p>When writing web applications you may frequently find the need to <a href="http://www.thefreedictionary.com/truncate" data-mce-href="http://www.thefreedictionary.com/truncate">truncate</a> strings. In php you <strong>could</strong> just use <a href="http://php.net/manual/en/function.substr.php" data-mce-href="http://php.net/manual/en/function.substr.php">substr</a> but that could be <a href="http://picchore.com/funny/carrots-glazed-with-what/" data-mce-href="http://picchore.com/funny/carrots-glazed-with-what/">dangerous</a>.</p>
<p>Therefore the safest idea is to truncate back to the nearest space. The code below is a Zend View Helper, constructed in a way to read cleanly in the page. It&#8217;s use in a Zend View is as follows:</p>
<pre class="wp-code-highlight prettyprint">&lt; ?$string = 'Hello People';?&gt;
&lt; ?=$this-&gt;truncate($string)-&gt;toLength(10)?&gt;
&lt; ?=$this-&gt;truncate($string)-&gt;toLength(10)-&gt;withPostfix('--')?&gt;
&lt; ?=$this-&gt;truncate($string)-&gt;midword()-&gt;toLength(10)-&gt;withPostfix('--')?&gt;</pre>
<p>As each method returns itself they can be chained together. The above outputs;</p>
<pre class="wp-code-highlight prettyprint">Hello…
Hello--
Hello peop--</pre>
<p>Methods</p>
<pre class="wp-code-highlight prettyprint">toLength($int) - the max string length to cut to
midword() - disable the safe truncation (probably not recommended) withPostfix($string) - replace the default postfix (...) with $string</pre>
<h2>Full class code</h2>
<pre class="wp-code-highlight prettyprint">&lt; ?php
class Zend_View_Helper_Truncate extends Zend_View_Helper_Abstract {
        private $_string;
        private $_length;
        private $_postfix;
        private $_cutatspace = true;

        public function truncate($string) {
            $this-&gt;_string = trim($string);
            $this-&gt;_defaultValues();
            return $this;
        }

        private function _defaultValues() {
            $this-&gt;toLength(100);
            $this-&gt;withPostfix('&amp;#0133;');
         }

        public function midword() {
            $this-&gt;_cutatspace = false;
            return $this;
        }

        public function toLength($int) {
            $this-&gt;_length = (int) $int;
            return $this;
        }
        public function withPostfix($str) {
            $this-&gt;_postfix = $str;
            return $this;
        }

        public function render() {
            // Return empty string if max length &lt; 1
            if ($this-&gt;_length &lt; 1) {
                return '';
            }

            // Return full string if max length &gt;= string length
            if ($this-&gt;_length &gt;= strlen($this-&gt;_string)) {
                return $this-&gt;_string;
            }

            // Return truncated string
            if ($this-&gt;_cutatspace) {
                while (strlen($this-&gt;_string) &gt; $this-&gt;_length) {
                    $cutPos = strrpos($this-&gt;_string, ' ', -1);
                    if ($cutPos === false) {
                        // no spaces left, whole string truncated
                        return '';
                    }
                    $this-&gt;_string = trim(substr($this-&gt;_string, 0, $cutPos));
                }
            } else {
                $this-&gt;_string = trim(substr($this-&gt;_string, 0, $this-&gt;_length));
            }
            return $this-&gt;_string . $this-&gt;_postfix;
        }

        public function __toString() {
            return $this-&gt;render();
        }
}</pre>
<p><strong>Update 11/02/2012: </strong><a href="http://www.monkeyhybrid.com/" title="Steve">Steve</a> noted an issue with this helper. I have updated the code above based on his suggestion. Thanks Steve.</p>
]]></content:encoded>
			<wfw:commentRss>http://hammerspace.co.uk/2011/10/truncate-at-space-zend-view-helper/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google Maps API points in polygons</title>
		<link>http://hammerspace.co.uk/2011/10/google-maps-api-points-in-polygons</link>
		<comments>http://hammerspace.co.uk/2011/10/google-maps-api-points-in-polygons#comments</comments>
		<pubDate>Wed, 19 Oct 2011 21:51:30 +0000</pubDate>
		<dc:creator>David Jonathan Marland</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://hammerspace.co.uk/?p=111</guid>
		<description><![CDATA[Update 27th March 2011: The Google Maps Geometry library now contains a containsLocation method which will achieve the same thing as detailed below. I&#8217;d recommend you use that instead. Discovering whether a point on a map is inside a polygon can be very useful, especially now that modern browsers and phones are location aware. If [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><strong>Update 27th March 2011:</strong> The Google Maps <a href="https://developers.google.com/maps/documentation/javascript/geometry">Geometry library</a> now contains a <a href="https://developers.google.com/maps/documentation/javascript/reference#poly">containsLocation</a> method which will achieve the same thing as detailed below. I&#8217;d recommend you use that instead.</p></blockquote>
<p>Discovering whether a point on a map is inside a polygon can be very useful, especially now that modern browsers and phones are location aware. If you can tell if your user is within a specific boundary then you can present them with immediately relevant information. An example I have used is telling the user they are in the coverage area of a local business (<a href="http://gascall.co/map">Gascall</a>).</p>
<p>Assuming you&#8217;ve already <a href="http://code.google.com/apis/maps/documentation/javascript/tutorial.html">set up your map</a>, the <a href="http://code.google.com/apis/maps/documentation/javascript/reference.html#Polygon">Google maps API</a> allows you to create polygons using simple code.</p>
<pre class="wp-code-highlight prettyprint">
var path = [
    new google.maps.LatLng(51.73383267274113, -1.03271484375),
    new google.maps.LatLng(51.45400691005984, -1.4501953125),
    new google.maps.LatLng(51.83577752045251, -0.8843994140625)];
    var polygon = new google.maps.Polygon({path:path, clickable:false});
    polygon.setMap(map);
</pre>
<p>You can create a Google maps point from latitude/longitude values or the users location:</p>
<pre class="wp-code-highlight prettyprint">
if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
        var point = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
    });
}
</pre>
<h2>Determining if the point is inside the polygon</h2>
<p>The google maps api does not already provide a method for checking points in polygons. Some <a href="http://appdelegateinc.com/blog/2010/05/16/point-in-polygon-checking/">research</a> has already been done on this, but I couldn&#8217;t find a complete solution in Google maps api v3 that also catered for crossing 180 degrees longitude. I would have done a straight translation into Google maps api v3, but decided to actually try to understand what was going on.</p>
<p>After researching a bit I stumbled across the <a href="http://rosettacode.org/wiki/Ray-casting_algorithm">Ray-casting algorithm</a> which will determine if an X-Y coordinate is inside a plotted shape. This will translate to latitude and longitude. The following extends the google.maps.polygon.prototype to use this algorithm. Simply include this code at a point in the code after google.maps has loaded:</p>
<pre class="wp-code-highlight prettyprint">
 google.maps.Polygon.prototype.Contains = function(point) {
        // ray casting alogrithm http://rosettacode.org/wiki/Ray-casting_algorithm
        var crossings = 0,
            path = this.getPath();

        // for each edge
        for (var i=0; i &lt; path.getLength(); i++) {
            var a = path.getAt(i),
                j = i + 1;
            if (j &gt;= path.getLength()) {
                j = 0;
            }
            var b = path.getAt(j);
            if (rayCrossesSegment(point, a, b)) {
                crossings++;
            }
        }

        // odd number of crossings?
        return (crossings % 2 == 1);

        function rayCrossesSegment(point, a, b) {
            var px = point.lng(),
                py = point.lat(),
                ax = a.lng(),
                ay = a.lat(),
                bx = b.lng(),
                by = b.lat();
            if (ay &gt; by) {
                ax = b.lng();
                ay = b.lat();
                bx = a.lng();
                by = a.lat();
            }
            // alter longitude to cater for 180 degree crossings
            if (px &lt; 0) { px += 360 };
            if (ax &lt; 0) { ax += 360 };
            if (bx &lt; 0) { bx += 360 };

            if (py == ay || py == by) py += 0.00000001;
            if ((py &gt; by || py &lt; ay) || (px &gt; Math.max(ax, bx))) return false;
            if (px &lt; Math.min(ax, bx)) return true;

            var red = (ax != bx) ? ((by - ay) / (bx - ax)) : Infinity;
            var blue = (ax != px) ? ((py - ay) / (px - ax)) : Infinity;
            return (blue &gt;= red);

        }

     };
</pre>
<p>Then to check a point:</p>
<pre class="wp-code-highlight prettyprint">
var point = new google.maps.LatLng(52.05249047600099, -0.6097412109375);
var polygon = new google.maps.Polygon({path:[INSERT_PATH_ARRAY_HERE]});
if (polygon.Contains(point)) {
    // point is inside polygon
}
</pre>
<p>I hope this proves useful. Let me know if you have any suggestions/comments. <a href="/projects/maps/">Test page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hammerspace.co.uk/2011/10/google-maps-api-points-in-polygons/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross browser alpha transparent background CSS (rgba)</title>
		<link>http://hammerspace.co.uk/2011/10/cross-browser-alpha-transparent-background-css</link>
		<comments>http://hammerspace.co.uk/2011/10/cross-browser-alpha-transparent-background-css#comments</comments>
		<pubDate>Sun, 09 Oct 2011 16:20:52 +0000</pubDate>
		<dc:creator>David Jonathan Marland</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[alpha transparent]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[rgba]]></category>

		<guid isPermaLink="false">http://hammerspace.co.uk/?p=41</guid>
		<description><![CDATA[In building the BBC Programmes website the design called for various layers of semi-transparent coloured boxes. These colours can change depending on the programme (for example: Never Mind the Buzzcocks) so an alpha transparent PNG is not a maintainable option. Obviously the simplest method is RGBA. #div { background: rgba(0,0,255,0.7); } As elegant as that is, [...]]]></description>
			<content:encoded><![CDATA[<p>In building the <a href="http://www.bbc.co.uk/programmes">BBC Programmes</a> website the design called for various layers of semi-transparent coloured boxes. These colours can change depending on the programme (for example: <a href="http://www.bbc.co.uk/programmes/b006v0dz">Never Mind the Buzzcocks</a>) so an alpha transparent PNG is not a maintainable option.<br />
Obviously the simplest method is <a href="http://www.w3.org/TR/css3-color/">RGBA</a>.</p>
<pre class="wp-code-highlight prettyprint">
#div {
    background: rgba(0,0,255,0.7);
}
</pre>
<p>As elegant as that is, it is not currently an acceptable solution in it&#8217;s own right. RGBA is not supported in Internet Explorer <a href="http://caniuse.com/css3-colors">below version 9</a>. Of course the BBC needs to <a href="http://www.bbc.co.uk/guidelines/futuremedia/technical/browser_support.shtml#support_table">support</a> the majority of it&#8217;s visitors. The phrase &#8220;it doesn&#8217;t need to look the same in every browser&#8221; could be thrown about, but in this case the semi-transparent boxes are quite essential for the look desired.</p>
<p>So, as any good web developer does, I turned to Google. I thought it would be a simple query (expected it to use IE filters) but it took unusually long to find it. Eventually I arrived at <a href="http://robertnyman.com/2010/01/11/css-background-transparency-without-affecting-child-elements-through-rgba-and-filters/">this blog post</a> which proved helpful.</p>
<p>Alpha-transparent background code (<a href="http://robertnyman.com/2010/01/11/css-background-transparency-without-affecting-child-elements-through-rgba-and-filters">quoted</a>)</p>
<pre class="wp-code-highlight prettyprint">
.alpha60 {
	/* Fallback for web browsers that doesn't support RGBa */
	background: rgb(0, 0, 0);
	/* RGBa with 0.6 opacity */
	background: rgba(0, 0, 0, 0.6);
	/* For IE 5.5 - 7*/
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);
	/* For IE 8*/
	-ms-filter: &quot;progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)&quot;;
}
</pre>
<h2>BUT</h2>
<p>There appeared to be a problem with this once we saw it in the wild. First you have to add zoom:1 to make it work in IE6-7 but this isn&#8217;t unusual. Secondly IE8 didn&#8217;t seem to work. As IE8 does support rgb() as a background colour the result is a solid coloured box.</p>
<p>Therefore we need to set the background back to transparent after the rgb rule (just in IE8 and below). After more Googling the answer was the <a href="http://webdood.com/?p=57">backslash 9 hack</a>.</p>
<p>Using that and tweaking (a lot) produced the following block of code. Note the -ms-filter line supported as IE8+ has been removed as it unnecessary. We have to use the non prefixed version anyway (for IE6,7) so the code is no more valid by using it in this scenario</p>
<pre class="wp-code-highlight prettyprint">
#div {
    background:rgb(255,0,0);
    background: transparent\9;
    background:rgba(255,0,0,0.3);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4cFF0000,endColorstr=#4cFF0000);
    zoom: 1;
}
</pre>
<p>This fixed the transparency problem but there was a new issue. Internet Explorer 9 is capable of displaying rgba <strong>AND</strong> the filter property. This creates a doubling up of the transparency and ruining it&#8217;s effects. It appears there is no CSS attribute hack that targets only IE8 or IE9 and not both (that has been discovered yet).</p>
<p>The ideal solution here is to not use the filter in IE9. The CSS filters are memory intensive and since IE9 is fully capable of rgba, it should be rewarded as such. IE9 is <a href="http://kimblim.dk/css-tests/selectors/">capable of many CSS3 selectors</a> so we&#8217;ll use one here:</p>
<pre class="wp-code-highlight prettyprint">
#div:nth-child(n) {
    filter:none;
}
</pre>
<p>This is a valid CSS selector that will match all elements in the same way as if it was not here. <a href="http://css-tricks.com/5452-how-nth-child-works/">More detail on how nth-child works</a>.</p>
<p><a href="/projects/alpha/test.html">This page shows various test scenarios</a></p>
<h2>Full code</h2>
<pre class="wp-code-highlight prettyprint">
#div{
    background:rgb(255,0,0);
    background: transparent\9;
    background:rgba(255,0,0,0.3);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4cFF0000,endColorstr=#4cFF0000);
    zoom: 1;
}
#div:nth-child(n) {
    filter: none;
}
</pre>
<p>So that&#8217;s the code required. I&#8217;ve put it here as a complete solution to save other developers having to search and test as much as I had to. Of course it&#8217;s recommended to use <a href="http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">conditional classes</a> instead but sometimes that&#8217;s just not possible.</p>
<p>The only other thing that slows down creating alpha transparent backgrounds is the conversion from hex -> rgba and opacity -> hex so below is a handy converter. Enter a hex colour and opacity value and it&#8217;ll spit out the code in the form seen above.</p>
<p>I&#8217;ll accept any tweaks/improvements in the comments.</p>
<p><iframe src="/projects/alpha/" height="400"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://hammerspace.co.uk/2011/10/cross-browser-alpha-transparent-background-css/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Start&#8230;</title>
		<link>http://hammerspace.co.uk/2011/09/start</link>
		<comments>http://hammerspace.co.uk/2011/09/start#comments</comments>
		<pubDate>Sun, 04 Sep 2011 12:32:58 +0000</pubDate>
		<dc:creator>David Jonathan Marland</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[introduction]]></category>

		<guid isPermaLink="false">http://hammerspace.co.uk/?p=31</guid>
		<description><![CDATA[Hello. I&#8217;ve finally created a blog, so hello world &#60;/cliché&#62; Who am I? I am David Jonathan Marland and I am a web developer. My plan is to use this blog to put up snippets of code that may be of interest to others. I will also put up bits of photography as I like to [...]]]></description>
			<content:encoded><![CDATA[<p>Hello. I&#8217;ve finally created a blog, so hello world &lt;/cliché&gt;</p>
<p><strong>Who am I?</strong></p>
<p>I am <a title="rland" href="http://rland.me.uk">David Jonathan Marland</a> and I am a web developer. My plan is to use this blog to put up snippets of code that may be of interest to others. I will also put up bits of photography as I like to play every now and then.</p>
<p>As you can tell this blog is quite plain at the moment and may even be slightly broken in places. I intend to over time evolve it by building a wordpress theme from scratch that is HTML5, responsive design (mobile first). I will document what I learn as I go, so keep following to see the changes.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://hammerspace.co.uk/2011/09/start/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

