<?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>CSS-Plus</title>
	<atom:link href="http://css-plus.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://css-plus.com</link>
	<description>Dance with CSS and Javascript</description>
	<lastBuildDate>Fri, 20 Mar 2020 09:00:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.20</generator>
	<item>
		<title>How to merge two WordPress databases with MySQL</title>
		<link>http://css-plus.com/2015/03/how-to-merge-two-wordpress-databases-with-mysql/</link>
		<comments>http://css-plus.com/2015/03/how-to-merge-two-wordpress-databases-with-mysql/#respond</comments>
		<pubDate>Mon, 30 Mar 2015 16:59:10 +0000</pubDate>
		<dc:creator><![CDATA[Jamy Golden]]></dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-plus.com/?p=1706</guid>
		<description><![CDATA[Recently I&#8217;ve had to do this and I was unable to find something that could solve my problem online. I wanted to merge a WooCommerce WordPress site into a very large WordPress blog. It ended up being relatively simple to &#8230; <a href="http://css-plus.com/2015/03/how-to-merge-two-wordpress-databases-with-mysql/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Recently I&#8217;ve had to do this and I was unable to find something that could solve my problem online. I wanted to merge a <a href="http://www.woothemes.com/woocommerce/">WooCommerce WordPress</a> site into a very large <a href="https://wordpress.org/">WordPress</a> blog. It ended up being relatively simple to do this, however I&#8217;d just like to note that I&#8217;m not a <a href="http://www.mysql.com/">MySQL</a> professional so there may be much more efficient ways of doing this, however this was good enough for my needs. Make sure to backup your WordPress database before messing around with it.</p>
<p><span id="more-1706"></span></p>
<h2>Problems were faced</h2>
<p>The problem when merging WordPress databases is that you end up having conflicts with the primary keys. Initially I thought this wasn&#8217;t a problem since I could just merge the one into the other without specifying the primary key. Mysql would auto-increment this and all my problems would have been solved. I tried this and quickly realised that this would only work for me if I was merging a single table. By auto-incrementing the primary keys in the various tables I was merging, it broke the primary/foreign key relationship between them.<br />
What was the solution?<br />
Simple, increment all primary and foreign keys in one of the databases by X (read: insert number here). X can change depending on how large your database is. I was working on a particularly large one and did an increment of 10 000.</p>
<p>You have db1 and db2. You want db1 to have the extra posts/content types/categories/images included in db2. Do the primary/foreign key increments on db2. Mysqldump the relevant tables from db2 with &#8211;no-something-or-other flag and then import that script into db1.</p>
<h2>Bash script</h2>
<p>The <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">bash</a> script below will export posts, pages, products, images, categories and tags from db2 into db2.sql. Edit it to your needs. I&#8217;ve left comments in the bash script.</p>
<pre><code class="language-bash">
# WordPress export
# Assuming the db details are:
# db_name = db2
# db_user = root
# db_pass = pass
# =============================================================================

echo "Change all IDs to avoid conflicts"
echo "===================================================="

# wp_posts
mysql --user=root --password= db2 -e "UPDATE wp_posts 
    SET id = REPLACE(
        id, 
        wp_posts.id, 
        wp_posts.id + 10000
    ) 
    WHERE id &gt; 0"

# wp_postmeta
# Increment post_id 
# Increment meta_value fields for post thumbnails to retain reference
mysql --user=root --password= db2 -e "UPDATE wp_postmeta 
    SET post_id = REPLACE(
        post_id, wp_postmeta.post_id, 
        wp_postmeta.post_id + 10000
    ) 
    WHERE post_id &gt; 0"
mysql --user=root --password= db2 -e "UPDATE wp_postmeta 
    SET meta_value = REPLACE(
        meta_value, 
        wp_postmeta.meta_value, 
        wp_postmeta.meta_value + 10000
    ) 
    WHERE meta_key = '_thumbnail_id'"

# wp_terms
mysql --user=root --password= db2 -e "UPDATE wp_terms 
    SET term_id = REPLACE(
        term_id, wp_terms.term_id, 
        wp_terms.term_id + 10000
    ) 
    WHERE term_id &gt; 0"

# wp_term_taxonomy
mysql --user=root --password= db2 -e "UPDATE wp_term_taxonomy 
    SET term_taxonomy_id = REPLACE(
        term_taxonomy_id, wp_term_taxonomy.term_taxonomy_id, 
        wp_term_taxonomy.term_taxonomy_id + 10000
    ) 
    WHERE term_taxonomy_id &gt; 0"
mysql --user=root --password= db2 -e "UPDATE wp_term_taxonomy 
    SET term_id = REPLACE(
        term_id, 
        wp_term_taxonomy.term_id, 
        wp_term_taxonomy.term_id + 10000
    ) 
    WHERE term_id &gt; 0"
mysql --user=root --password= db2 -e "UPDATE wp_term_taxonomy 
    SET parent = REPLACE(
        parent, 
        wp_term_taxonomy.parent, 
        wp_term_taxonomy.parent + 10000
    ) 
    WHERE parent &gt; 0"

# wp_term_relationships
mysql --user=root --password= db2 -e "UPDATE wp_term_relationships 
    SET object_id = REPLACE(
        object_id, 
        wp_term_relationships.object_id, 
        wp_term_relationships.object_id + 10000
    ) 
    WHERE object_id &gt; 0"
mysql --user=root --password= db2 -e "UPDATE wp_term_relationships 
    SET term_taxonomy_id = REPLACE(
        term_taxonomy_id, 
        wp_term_relationships.term_taxonomy_id, 
        wp_term_relationships.term_taxonomy_id + 10000
    ) 
    WHERE term_taxonomy_id &gt; 0"

echo "Now for the dumping"
echo "===================================================="

mysqldump --no-create-info --user=root --password= db2 wp_posts &gt; wp_posts.sql
mysqldump --no-create-info --user=root --password= db2 wp_postmeta &gt; wp_postmeta.sql
mysqldump --no-create-info --user=root --password= db2 wp_terms &gt; wp_terms.sql
mysqldump --no-create-info --user=root --password= db2 wp_term_taxonomy &gt; wp_term_taxonomy.sql
mysqldump --no-create-info --user=root --password= db2 wp_term_relationships &gt; wp_term_relationships.sql

echo "Edit exported files to allow for seamless inserting"
echo "===================================================="

# wp_postmeta id's don't need to be force incremented. Remove all ID inserts
sed -ir "s/[)],[(][0-9]*,/),(/g" wp_postmeta.sql
sed -i "s/INSERT INTO \`wp_postmeta\` VALUES ([0-9]*,/INSERT INTO \`wp_postmeta\` (\`post_id\`, \`meta_key\`, \`meta_value\`) VALUES (/g" wp_postmeta.sql

# Prevents duplicates on wp_terms and wp_users script import
sed -i "s/);/) ON DUPLICATE KEY UPDATE slug = slug;/g" wp_terms.sql

</code></pre>
<p>Note: Users have been removed from the above export, therefore db1 users will be untouched.</p>
<p>Once the script has done all of the hard work, it&#8217;s time to import db2.sql into db1.</p>
<pre><code class="language-bash">
# Import into dummy DB
echo "Import into dummy DB"
echo "===================================================="
mysql -u root -p db1 &lt; wp_posts.sql
mysql -u root -p db1 &lt; wp_postmeta.sql
mysql -u root -p db1 &lt; wp_terms.sql
mysql -u root -p db1 &lt; wp_term_taxonomy.sql
mysql -u root -p db1 &lt; wp_term_relationships.sql

</code></pre>
<p>That&#8217;s it! Everything should have merged correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://css-plus.com/2015/03/how-to-merge-two-wordpress-databases-with-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install Sass and Compass</title>
		<link>http://css-plus.com/2014/05/install-sass-and-compass/</link>
		<comments>http://css-plus.com/2014/05/install-sass-and-compass/#respond</comments>
		<pubDate>Mon, 26 May 2014 16:15:42 +0000</pubDate>
		<dc:creator><![CDATA[Jamy Golden]]></dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-plus.com/?p=1684</guid>
		<description><![CDATA[This is a simple article that covers how to install Sass and Compass for terminal/command prompt usage, not how to use it. If you&#8217;re looking for the latter, check out this css-tricks screencast. Installing When running Sass/Compass you&#8217;ll only need &#8230; <a href="http://css-plus.com/2014/05/install-sass-and-compass/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This is a simple article that covers how to <strong><em>install</em></strong> <a href="http://sass-lang.com/">Sass</a> and <a href="http://compass-style.org/">Compass</a> for terminal/command prompt usage, not how to use it.</p>
<p>If you&#8217;re looking for the latter, check out this <a href="http://css-tricks.com/video-screencasts/88-intro-to-compass-sass/">css-tricks screencast</a>.</p>
<p><span id="more-1684"></span></p>
<h2>Installing</h2>
<p>When running Sass/Compass you&#8217;ll only need Sass or Compass, but this article will instruct you to install both.</p>
<p>Sass and Compass are Ruby applications, meaning you need to have Ruby installed. Ruby is a programming language.</p>
<h3>Install on Windows</h3>
<p>Make sure to read this whole section before installing.</p>
<p>Firstly, you need to begin the <a title="Download Ruby" href="http://rubyinstaller.org/downloads/">Ruby</a> installation. It&#8217;s probably best to pick the latest version. At the time of writing I would choose <code>Ruby 2.0.0-p481 (x64)</code> since that&#8217;s the latest version and I&#8217;m running a 64 bit OS.</p>
<p><strong>Important note:</strong> While running the installation, there is a checkbox option that is un-ticked by default: <em><strong>Add Ruby executables to your PATH</strong></em>. Make sure that is ticked. This allows for the keyword <code>ruby</code> to be linked to the Ruby installation for your command prompt.</p>
<p><img class="aligncenter size-full wp-image-1690" src="http://css-plus.com/wp-content/uploads/2014/05/ruby-install-windows.jpg" alt="ruby-install-windows" width="513" height="398" srcset="http://css-plus.com/wp-content/uploads/2014/05/ruby-install-windows.jpg 513w, http://css-plus.com/wp-content/uploads/2014/05/ruby-install-windows-180x139.jpg 180w, http://css-plus.com/wp-content/uploads/2014/05/ruby-install-windows-300x232.jpg 300w" sizes="(max-width: 513px) 100vw, 513px" /></p>
<p>Once this is done it&#8217;s time to install Sass and Compass.</p>
<p>Runy the following commands:</p>
<pre><code class="language-bash">gem install sass compass</code></pre>
<p>The above will install both Sass and Compass. It may take a while so just give it time to do it&#8217;s thing. Once it&#8217;s done, you&#8217;re done. Give yourself a high five.</p>
<h3>Install on OS X/Linux</h3>
<p>By default OS X and Linux have Ruby installed. So this should be very easy. Run the following command:</p>
<pre><code class="language-bash">sudo gem install sass compass</code></pre>
<p>That&#8217;s it. Yay for Unix based operating systems.</p>
<h2>But&#8230; I don&#8217;t like the terminal/command prompt</h2>
<p>It&#8217;s not as complicated as it seems. The feeling of being at home within the terminal is quite a liberating feeling and I suggest you learn it. There are a bunch of Sass/Compass GUIs out there and I&#8217;ve tried 3 of them. The following work in Windows, OS X and Linux.</p>
<ul>
<li><a href="http://compass.kkbox.com/">Compass.app</a> is my favourite because it runs in the background and there is minimal interface.</li>
<li><a href="http://alphapixels.com/prepros/">Prepros App</a> Is also pretty good. I&#8217;ve found some irritating things about it with regards to very specific Compass customization but it&#8217;s really easy to use.</li>
<li><a href="http://mhs.github.io/scout-app/">Scout</a> is pretty easy to use. I found it a bit slow and laggy.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://css-plus.com/2014/05/install-sass-and-compass/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create your own jQuery Image Slider</title>
		<link>http://css-plus.com/2013/10/create-your-own-jquery-image-slider/</link>
		<comments>http://css-plus.com/2013/10/create-your-own-jquery-image-slider/#comments</comments>
		<pubDate>Wed, 02 Oct 2013 18:02:02 +0000</pubDate>
		<dc:creator><![CDATA[Jamy Golden]]></dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://css-plus.com/?p=410</guid>
		<description><![CDATA[I originally posted this article on 15 September 2010. This is an updated version. This tutorial is for beginners. The method for creating the slider could be done differently, but I feel this way is more simple to understand. It &#8230; <a href="http://css-plus.com/2013/10/create-your-own-jquery-image-slider/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I originally posted this article on 15 September 2010. This is an updated version.</p>
<p>This tutorial is for beginners. The method for creating the slider could be done differently, but I feel this way is more simple to understand.<br />
<span id="more-410"></span><br />
It is important to picture what the HTML and CSS should be doing in order to create the component before actually beginning with the javascript. This way you know exactly what you are working towards. Below is a gif explaining the concept of the slider in terms of HTML and CSS.</p>
<p><img src="http://css-plus.com/wp-content/uploads/2013/10/slider-gif.gif" alt="slider-gif" width="530" height="130" class="aligncenter size-full wp-image-1664" /></p>
<p>Common things that cross my mind before actually jumping into development are:</p>
<dl>
<dt>Where are the hidden elements situated?</dt>
<dd>Beneath, on top, next to or behind the visible element?</dd>
<dt>How are they hidden?</dt>
<dd>Is their display set to none?</dd>
<dd>Are they outside of the parent element which is set to overflow: hidden?</dd>
<dd>Are they hidden behind visible element via z-index?</dd>
</dl>
<p>All right, enough of that, let&#8217;s get started.</p>
<h2>The HTML</h2>
<p>Before we create anything, we should try and get an idea of exactly what we are trying to achieve. I&#8217;ve drawn up a quick <a href="http://css-plus.com/wp-content/uploads/2010/09/gallery-wireframe.png">image slider wireframe</a>.</p>
<p>So let&#8217;s turn that into <abbr title="HyperText Markup Language">HTML</abbr>.</p>
<pre><code class="language-html">&lt;div class="gallery-wrap"&gt;
  &lt;div class="gallery clearfix"&gt;
    &lt;div class="gallery__item"&gt;
      &lt;img src="images/image1.jpg" class="gallery__img" alt="" /&gt;
    &lt;/div&gt;
     &lt;div class="gallery__item"&gt;
      &lt;img src="images/image2.jpg" class="gallery__img" alt="" /&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gallery__controls clearfix"&gt;
    &lt;div href="#" class="gallery__controls-prev"&gt;
      &lt;img src="images/prev.png" alt="" /&gt;
    &lt;/div&gt;
    &lt;div href="#" class="gallery__controls-next"&gt;
      &lt;img src="images/next.png" alt="" /&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre>
<p><code>.gallery-wrap</code> will be the visible area.<br />
<code>.gallery</code> is the element that contains the list of images.<br />
<code>.gallery__controls</code> contains the next and previous controls.</p>
<p>Generally an image slider would contain more than 2 images but I&#8217;ve left out the exact HTML I used in the demo for readability.</p>
<h2>The CSS</h2>
<pre><code class="language-css">.gallery-wrap { margin: 0 auto; overflow: hidden; width: 732px; }
.gallery { position: relative; left: 0; top: 0; }
.gallery__item { float: left; list-style: none; margin-right: 20px; }
.gallery__img { display: block; border: 4px solid #40331b; height: 175px; width: 160px; }

.gallery__controls { margin-top: 10px; }
.gallery__controls-prev { cursor: pointer; float: left; }
.gallery__controls-next { cursor: pointer; float: right; }</code></pre>
<p>The most important thing here is to set <code>.gallery</code> to &#8216;<code>position: relative</code>&#8216; and to set <code>.gallery-wrap</code> to &#8216;<code>overflow: hidden</code>&#8216;. The CSS is quite straight forward.</p>
<h2>The jQuery/Javascript</h2>
<p>This is where all the fancy tricks take place.</p>
<pre><code class="language-javascript">// Only run everything once the page has completely loaded
$(window).load(function(){

    // Fancybox specific
    $(".gallery__link").fancybox({
        'titleShow'     : false,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic'
    });

    // Set general variables
    // ====================================================================
    var totalWidth = 0;

    // Total width is calculated by looping through each gallery item and
    // adding up each width and storing that in `totalWidth`
    $(".gallery__item").each(function(){
        totalWidth = totalWidth + $(this).outerWidth(true);
    });

    // The maxScrollPosition is the furthest point the items should
    // ever scroll to. We always want the viewport to be full of images.
    var maxScrollPosition = totalWidth - $(".gallery-wrap").outerWidth();

    // This is the core function that animates to the target item
    // ====================================================================
    function toGalleryItem($targetItem){
        // Make sure the target item exists, otherwise do nothing
        if($targetItem.length){

            // The new position is just to the left of the targetItem
            var newPosition = $targetItem.position().left;

            // If the new position isn't greater than the maximum width
            if(newPosition &lt;= maxScrollPosition){

                // Add active class to the target item
                $targetItem.addClass("gallery__item--active");

                // Remove the Active class from all other items
                $targetItem.siblings().removeClass("gallery__item--active");

                // Animate .gallery element to the correct left position.
                $(".gallery").animate({
                    left : - newPosition
                });
            } else {
                // Animate .gallery element to the correct left position.
                $(".gallery").animate({
                    left : - maxScrollPosition
                });
            };
        };
    };

    // Basic HTML manipulation
    // ====================================================================
    // Set the gallery width to the totalWidth. This allows all items to
    // be on one line.
    $(".gallery").width(totalWidth);

    // Add active class to the first gallery item
    $(".gallery__item:first").addClass("gallery__item--active");

    // When the prev button is clicked
    // ====================================================================
    $(".gallery__controls-prev").click(function(){
        // Set target item to the item before the active item
        var $targetItem = $(".gallery__item--active").prev();
        toGalleryItem($targetItem);
    });

    // When the next button is clicked
    // ====================================================================
    $(".gallery__controls-next").click(function(){
        // Set target item to the item after the active item
        var $targetItem = $(".gallery__item--active").next();
        toGalleryItem($targetItem);
    });
});</code></pre>
<p>I have heavily commented the above code. All lines beginning with <code>//</code> are comment lines.</p>
<p>To recap, the following was done:</p>
<ul>
<li>Only run everything once the window (page) loads.</li>
<li>Calculate the total width of all the images.</li>
<li>Calculate the maximum scroll position. This is the total images width subtract the viewport (<code>.gallery</code>) width.</li>
<li>Create the toGalleryItem function. This function will scroll to any item we desire.
<ul>
<li>If the target item exists, continue. Otherwise there is nothing left to run.</li>
<li>The new position is the left position of the slide/image, relative to it&#8217;s container <code>.gallery</code>.</li>
<li>If the new position is less than or equal to the maximum scroll position, toggle active classes accordingly and animate to the new left position.</li>
<li>Otherwise animate to the maximum scroll position.</li>
</ul>
</li>
<li>Set slide container (<code>.gallery</code>) width to the sum of all the images width.</li>
<li>Set the first image as active.</li>
<li>When the previous button is clicked, go to the previous slide/image.</li>
<li>When the next button is clicked, go to the next slide/image.</li>
</ul>
<p>I will break down the javascript into 2 parts.<br />
I&#8217;m going to break the above up into 2 parts. Part explaining the variable declarations and part 2 explaining the rest of the jQuery/javascript.</p>
<h2>Summary of javascript/jQuery methods used:</h2>
<h4><code>$(".gallery__item").<a href="http://api.jquery.com/each/">each()</a></code></h4>
<p>I&#8217;ve written an article explaining the <a href="http://css-plus.com/2011/09/master-the-jquery-for-each-loop/">various jQuery each methods</a>a>.</p>
<h4><code>totalWidth = totalWidth + $(this).<a href="http://api.jquery.com/outerWidth/">outerWidth(true)</a>;</code></h4>
<h4><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a> toGalleryItem($targetItem)</code></h4>
<p>A function is a bit of javascript that can be run just by calling the function name. Essentially it&#8217;s a shortcut. Functions can be made dynamic by allowing the user to pass in variables or parameters such as <code>$targetItem</code></p>
<h4><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else">if</a>($targetItem.<a href="http://api.jquery.com/length/">length</a>){</code></h4>
<p>I&#8217;ve written an article about the <a href="http://css-plus.com/2011/07/jquery-if-else-statements/">if statement</a> you may want to have a look at.</p>
<h4><code><a href="http://api.jquery.com/addClass/">addClass</a> and <a href="http://api.jquery.com/removeClass/">removeClass</a></code></h4>
<p>These are self explanetory jQuery functions.</p>
<h4><code>$(".gallery").<a href="http://api.jquery.com/animate/">animate()</a></code></h4>
<p>This is a magic jQuery function that allows you to animate a wide range of CSS properties.</p>
<p>That&#8217;s about it! I hope you&#8217;ve found this tutorial useful.</p>
<p>If you have any questions or comments, feel free to leave a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://css-plus.com/2013/10/create-your-own-jquery-image-slider/feed/</wfw:commentRss>
		<slash:comments>197</slash:comments>
		</item>
		<item>
		<title>inline-block: The complete story</title>
		<link>http://css-plus.com/2013/01/inline-block-the-complete-story/</link>
		<comments>http://css-plus.com/2013/01/inline-block-the-complete-story/#comments</comments>
		<pubDate>Mon, 07 Jan 2013 15:20:05 +0000</pubDate>
		<dc:creator><![CDATA[Jamy Golden]]></dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[Cross-browser support]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://css-plus.com/?p=1591</guid>
		<description><![CDATA[inline-block is something I hadn&#8217;t used until a couple of months ago. I was comfortable with block and inline elements so I didn&#8217;t feel the need to learn anything more. I was also under the impression, as I&#8217;m sure many &#8230; <a href="http://css-plus.com/2013/01/inline-block-the-complete-story/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><code>inline-block</code> is something I hadn&#8217;t used until a couple of months ago. I was comfortable with block and inline elements so I didn&#8217;t feel the need to learn anything more. I was also under the impression, as I&#8217;m sure many developers are, that anything other than <code>display: block</code> and <code>display: inline</code> has cross-browser inconsistency problems and should be avoided.</p>
<p>This article focuses on why you should start using <code>display: inline-block</code>, understanding this value as well as how to make sure it is consistent across all modern browsers and IE7+.<br />
<span id="more-1591"></span><br />
<em>Note:</em> If you don&#8217;t yet know the differences between inline and block level elements, check out what <a href="http://www.css-101.org/block-level-elements/index.php">css-101</a> has to say about it.</p>
<h2>inline-block is your missing friend</h2>
<p><code>inline-block</code> solves all sorts of problems web-devs run into on a daily basis. I&#8217;m going to go through various common scenarios and cover how I would deal with them in a cross-browser fashion. You may notice some odd/hacky CSS included in the following examples &#8211; this will be covered in the Browser Compatibility section later in the article.</p>
<h2>inline-block vertically center (IBVC) hack</h2>
<p>Chris Coyier talks about a <a href="http://css-tricks.com/centering-in-the-unknown/">&#8220;Ghost&#8221; IBVC method</a> and he credits Michal Czernow for it&#8217;s origin. Chris also mentions how it&#8217;s equivalent to the <code>display: table/table-cell</code> method since it also doesn&#8217;t support IE7. I&#8217;ve been playing around with <code>inline-block</code> and tinkering with vertical centering and I&#8217;ve come up with something that seems to be the &#8216;Ghost&#8217; method (I&#8217;d discovered the &#8216;Ghost&#8217; method after stumbling upon this solution) with a few differences. The two differences being mine supports IE6+ (not that IE6 matters at all anymore, just an FYI) and it doesn&#8217;t require pseudo elements to function.</p>
<p>Being able to vertically center an element with a dynamic height is something that has plagued developers (or me at least) for a very long time and the cross-browser solution has been somewhat of a holy grail. I&#8217;ve seen many different vertical centering methods, the most popular being the display: table used with display: table-cell. The problem with this is IE7 doesn&#8217;t support either of those display values.</p>
<pre class="codepen" data-height="550" data-type="result" data-href="e5868d4087fbd7d5fb9d18c4a2831b03" data-user="JamyGolden" data-safe="true"></pre>
<p>I feel this hack is a <em>more simple</em> and <em>easily understandable</em> way of vertically/horizontally centering an element than the previously mentioned table/table-cell/IE7-bug-hack method. I also feel it&#8217;s much easier to understand and work with than the <a href="http://gtwebdev.com/workshop/vcenter/vcenter-inline-css.php">Gary Turner method</a> too, but well done to him for coming up with that over <strong>7 years ago</strong>. I&#8217;m sure other people will feel differently about this being the &#8220;best&#8221; way, however this is what I prefer..</p>
<h3>Problems</h3>
<p>&nbsp;</p>
<h4>vertical-align property</h4>
<p>One slight downside to this I&#8217;ve noticed is <code>vertical-align: middle</code> vertically aligns the capital letters, so lower case letters or <code>inline-block</code> elements are very slightly <em>off center</em>. I&#8217;ve noticed elements being off by about 2px to 4px depending on what size the items are. Although this occurs it&#8217;s pretty much negligible for me &#8211; especially since I can&#8217;t actually notice this unless I actually count pixels.</p>
<h5>Space characters</h5>
<p>Space characters are handled like a space would be handled within inline-elements. This means that spaces and or tabs will be displayed as a space once the page has rendered. There are a <a href="http://css-tricks.com/fighting-the-space-between-inline-block-elements/">couple of ways to work around this problem</a> but it can be annoying nonetheless.</p>
<h4>IE7 hand-holding</h4>
<p>The above mentioned ‘space characters&#8217; problem doesn&#8217;t take affect in IE7. The problem IE7 does come with is that it requires at least 1 other <code>inline-block</code> element to be present to allow the <code>inline-block</code> to vertically center. To get around this, I&#8217;ve added an &#8220;invisible&#8221; element after the item I&#8217;m centering &#8211; I&#8217;ve added it afterwards incase <code>:first-child</code> is used. This was included in the Ghost method through pseudo elements. Even though I&#8217;ve managed to remove pseudo elements, I&#8217;ve had to add an equivalent (or worse since it&#8217;s actual markup) for IE7. Boo.</p>
<h4>Alternative methods</h4>
<p>There is an IE7 CSS bug in which you can center an element vertically, and if used along side the table/table-cell method, it can work nicely (However I haven&#8217;t used it in practice). This <a href="http://dabblet.com/gist/2403795">can also be done</a> using the <a href="http://html5please.com/#flexbox">Flexbox</a> layout module &#8211; <a href="http://weblog.bocoup.com/dive-into-flexbox/">Flexbox</a> is definitely something that will be used much more in future, however as <a href="https://twitter.com/__leroux">Le Roux</a> pointed out to me, the current Flexbox support right now is a bit flakey &#8211; So it may be another 1 or 2 years before we can start using it with absolute confidence.</p>
<h2>Centering navigation items</h2>
<p>I often come across a navigation design where the amount of items in the navigation should be dynamic, however the navigation itself should remain centered regardless of how many or how wide the items are. <a href="http://css-plus.com/2010/11/how-to-horizontally-centre-anything-with-css/">Previously</a> I would have centered this with <code>display: table</code>, however, since display: table doesn&#8217;t have any IE7 support, I would have probably also used an IE7 javascript fallback (Or just let the navigation appear left aligned in IE7). With <code>display: inline-block</code>, this same result can be achieved with 2 (or 4 including IE7 support) css properties and values.</p>
<pre class="codepen" data-height="200" data-type="result" data-href="HEztc" data-user="JamyGolden" data-safe="true"></pre>
<p>How simple was that? Seriously?</p>
<h2>Article block listings</h2>
<p>Generally I solve the following kind of problem differently depending on the exact design and how I feel at the time.</p>
<p><img class="aligncenter size-full wp-image-1623" alt="article listing example" src="http://css-plus.com/wp-content/uploads/2013/01/article-listing.jpg" width="437" height="328" srcset="http://css-plus.com/wp-content/uploads/2013/01/article-listing.jpg 437w, http://css-plus.com/wp-content/uploads/2013/01/article-listing-180x135.jpg 180w, http://css-plus.com/wp-content/uploads/2013/01/article-listing-300x225.jpg 300w" sizes="(max-width: 437px) 100vw, 437px" /></p>
<p>An easy <code>inline-block</code> solution would be:</p>
<pre class="codepen" data-height="500" data-type="result" data-href="cpzaI" data-user="JamyGolden" data-safe="true"></pre>
<p>The design could have been more tricky, though. Typically the height would be dynamic, or possibly both the height and width. As you can see this isn&#8217;t exactly a <a href="http://masonry.desandro.com/">masonry</a> layout since each row starts and ends at the same top-offset. It is still not possible to solve a masonry design in LTE IE9 <a href="http://sickdesigner.com/masonry-css-getting-awesome-with-css3/">without javascript</a>. The height of these items are dynamic though, mere floats wouldn&#8217;t work correctly. If we used floats would end up with something like this:</p>
<pre class="codepen" data-height="500" data-type="result" data-href="ajGzI" data-user="JamyGolden" data-safe="true"></pre>
<p>To avoid that we could use <a href="http://css-tricks.com/how-nth-child-works/">:nth-child</a> and detect the first item in each row and then clear: left, but that would pose some cross-browser problems itself since <a href="http://caniuse.com/#feat=css-sel3">:nth-child is only supported by modern browsers</a>. We could add classes to these items via the CMS/backend language, but it would be easier if we could just get this working with CSS alone and without any problems! <img src="https://s.w.org/images/core/emoji/11/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
Yay, <code>inline-block</code> the the rescue again! <img src="https://s.w.org/images/core/emoji/11/72x72/1f600.png" alt="😀" class="wp-smiley" style="height: 1em; max-height: 1em;" /> You didn&#8217;t expect that did you?!</p>
<pre class="codepen" data-height="500" data-type="result" data-href="KvBGC" data-user="JamyGolden" data-safe="true"></pre>
<p>&nbsp;</p>
<h2>More navigation</h2>
<p>Surely there is some limit to the IE7 support? What about an <code>inline-block</code> within an <code>inline-block</code>?!</p>
<pre class="codepen" data-height="200" data-type="result" data-href="dEtzx" data-user="JamyGolden" data-safe="true"></pre>
<p>In the above example I have <strong>3 levels of nested <code>inline-block</code> items</strong> and it works perfectly in IE7+.</p>
<h2>Browser compatibility</h2>
<p>If you&#8217;ve read up until this point, you are well aware that an <strong>IE7 hack should be used to &#8220;enable&#8221; the <code>inline-block</code> functionality</strong>.</p>
<h3>The IE7 hack</h3>
<pre><code class="language-css">.item { display: block; *display: inline; zoom: 1; }</code></pre>
<p>This could be turned into valid CSS if you are using the <a href="http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">&lt;html&gt; conditional classes</a> (included in <a href="https://github.com/h5bp/html5-boilerplate">h5bp</a>):</p>
<pre><code class="language-css">.item { display: inline-block; }
.lt-ie8 .item { display: inline; zoom: 1; }</code></pre>
<h4>Why does that work?</h4>
<p>IE7 doesn&#8217;t support <code>inline-block</code> per se, however you can mimic the functionality by making it be an inline element and triggering <a href="http://www.satzansatz.de/cssd/onhavinglayout.html">hasLayout </a>on the element. The <code>zoom: 1</code> visually doesn&#8217;t change anything. It is applied this way because it is one of the properties that triggers hasLayout.</p>
<h2>Conclusion</h2>
<p><code>inline-block</code> is an amazing and underrated and underused property, in my opinion. <code>inline-block</code> is something that can and should be used today with confidence. We fear that which we do not understand &#8211; hopefully <code>inline-block</code> is now added to your CSS toolbox.</p>
]]></content:encoded>
			<wfw:commentRss>http://css-plus.com/2013/01/inline-block-the-complete-story/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to horizontally center elements of a dynamic width</title>
		<link>http://css-plus.com/2012/05/how-to-horizontally-center-elements-of-a-dynamic-width/</link>
		<comments>http://css-plus.com/2012/05/how-to-horizontally-center-elements-of-a-dynamic-width/#comments</comments>
		<pubDate>Mon, 21 May 2012 15:25:47 +0000</pubDate>
		<dc:creator><![CDATA[Jamy Golden]]></dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-plus.com/?p=1541</guid>
		<description><![CDATA[A couple of months ago I wrote an article titled &#8220;How to horizontally center anything with CSS&#8220;. The featured method of the article was to center an element with a dynamic width using display: table. This works wonderfully in IE8+ &#8230; <a href="http://css-plus.com/2012/05/how-to-horizontally-center-elements-of-a-dynamic-width/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>A couple of months ago I wrote an article titled &#8220;<a href="http://css-plus.com/2010/11/how-to-horizontally-centre-anything-with-css/" title="How to horizontally center anything with CSS">How to horizontally center anything with CSS</a>&#8220;. The featured method of the article was to <strong>center an element with a dynamic width</strong> using <code>display: table</code>. <span id="more-1541"></span>This works wonderfully in IE8+ and modern browsers. I would usually ignore IE7&#8217;s inability to render this property, however, every now and then it would <em>have</em> to work in IE7. This is an example of the <code>display: table</code> method:<br />
<iframe style="margin-top: 10px; width: 100%; height: 300" src="http://jsfiddle.net/cssplus/5grwG/embedded/result,html,css/" allowfullscreen="allowfullscreen" frameborder="0"></iframe></p>
<h2>New Method</h2>
<p>Ever since I came across the IE7 inline-block hack, I&#8217;ve been using it whenever I can. It works in IE7, why wouldn&#8217;t I use it everywhere?</p>
<p>Inline-blocks can be centered with the use of <code>text-align: center</code>. Therefore, a list of inline-blocks can be centered extremely easily. <em>This works absolutely wonderfully for horizontally centered navigations</em>, or anything that doesn&#8217;t have block level elements within it.<br />
This is an example of a navigation dynamically centered with the use of inline-block elements and the <code>text-align: center</code> property:<br />
<iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/cssplus/Wa37V/2/embedded/result,html,css/" allowfullscreen="allowfullscreen" frameborder="0"></iframe><br />
You may have noticed that the HTML doesn&#8217;t have spaces between the elements for readability like the previous example does. This is because the elements are treating the spaces/enters/tabs between them as an actual space since they are behaving like inline elements. IE7 doesn&#8217;t support <code>inline-block</code>, however an inline element which receives <a href="http://www.satzansatz.de/cssd/onhavinglayout.html">hasLayout</a> behaves as if it were an inline-block. <code>zoom: 1</code> is one of the properties which forces hasLayout on an element in IE.</p>
<h2>Conclusion</h2>
<p>This is an extremely simple way of solving a dynamically centered navigation problem with brilliant browser support. It may not be the solution for every <code>display: table</code> that is/was used, but it can definitely help in a bunch of different scenarios.</p>
]]></content:encoded>
			<wfw:commentRss>http://css-plus.com/2012/05/how-to-horizontally-center-elements-of-a-dynamic-width/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Gaussian Blur and CSS3/SVG</title>
		<link>http://css-plus.com/2012/03/gaussian-blur/</link>
		<comments>http://css-plus.com/2012/03/gaussian-blur/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 15:15:16 +0000</pubDate>
		<dc:creator><![CDATA[Jamy Golden]]></dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-plus.com/?p=1462</guid>
		<description><![CDATA[Edited: 07 January 2014 &#8211; Updated article to reflect current browser support. Gaussian blur is something I use a lot when it comes to Photoshop. It would be very handy to have that kind of &#8216;filter&#8217; power within a browser &#8230; <a href="http://css-plus.com/2012/03/gaussian-blur/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Edited: 07 January 2014 &#8211; Updated article to reflect current browser support.<br />
Gaussian blur is something I use a lot when it comes to Photoshop. It would be very handy to have that kind of &#8216;filter&#8217; power within a browser environment.<br />
<span id="more-1462"></span><br />
Before we get started, I think it&#8217;s just important to understand that both the <abbr title="Scalable Vector Graphics">SVG</abbr> and CSS filter properties affect an element and all of it&#8217;s children. A child element cannot be &#8216;un-blurred&#8217;, only blurred more. There are a few methods of recreating this Gaussian blur effect, some work cross-browser, others don&#8217;t but will be supported in future. </p>
<p>In the example jsfiddles you may notice <abbr title="Hypertext Markup Language">HTML</abbr> IE conditional statements: Usually those conditional statements are applied to the <code>&lt;html&gt;</code> element and I&#8217;ve added them to a div to mimic that functionality.</p>
<h2>CSS3 text-shadow<img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-chrome.png" alt="Chrome Logo" title="Supported by Chrome" width="32" height="32" class="alignright size-full wp-image-1500" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-firefox.png" alt="Firefox Logo" title="Supported by Firefox" width="32" height="32" class="alignright size-full wp-image-1501" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-ie.png" alt="Internet Explorer Logo" title="Supported by Internet Explorer" width="32" height="32" class="alignright size-full wp-image-1502" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-opera.png" alt="Opera Logo" title="Supported by Opera" width="32" height="32" class="alignright size-full wp-image-1503" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-safari.png" alt="Safari Logo" title="Supported by Safari" width="32" height="32" class="alignright size-full wp-image-1504" /></h2>
<p>I&#8217;m sure you&#8217;re either aware of, or easily understand how this trick works. Very simply, you give the text a text-shadow and make the it transparent so that only the shadow is visible. This gives a simple and effective blurred text effect. Usually I would detect for IE9 but it&#8217;s necessary in this case since IE9 doesn&#8217;t support text-shadow.<br />
<iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/jamygolden/CGFBT/2/embedded/result,html,css/" frameborder="0" width="320" height="240"></iframe></p>
<h3>Problems</h3>
<ul>
<li>Opera doesn&#8217;t currently support the transition to the text-shadow property. The blur works well though!</li>
<li>I&#8217;ve applied a lte-IE8 shadow filter to the text. It looks more like a smudge than a blur, but there you have it &#8211; use it, don&#8217;t use it.</li>
</ul>
<h3>Fallback</h3>
<p>Use <a href="http://www.modernizr.com/">Modernizr</a> ( or feature detect manually ) for text-shadow support to apply fallback styles. This is necessary due to the fact that the text has a transparent color and without the shadow, the font is illegible.</p>
<h2><abbr title="Scalable Vector Graphics">SVG</abbr> blur filter applied to a <abbr title="Scalable Vector Graphics">SVG</abbr> element<img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-chrome.png" alt="Chrome Logo" title="Supported by Chrome" width="32" height="32" class="alignright size-full wp-image-1500" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-firefox.png" alt="Firefox Logo" title="Supported by Firefox" width="32" height="32" class="alignright size-full wp-image-1501" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-opera.png" alt="Opera Logo" title="Supported by Opera" width="32" height="32" class="alignright size-full wp-image-1503" /></h2>
<p>The title may seem superfluous but it&#8217;s actually quite important to understand when it comes to <abbr title="Scalable Vector Graphics">SVG</abbr> filters. <abbr title="Scalable Vector Graphics">SVG</abbr> supports filters and we can easily and freely apply these filters to all kinds of <abbr title="Scalable Vector Graphics">SVG</abbr> elements. Note: <em>NOT</em> all kinds of <em>HTML</em> elements, I&#8217;ll elaborate a little later.<br />
<iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/jamygolden/2S6Ut/1/embedded/result,html,css/" frameborder="0" width="320" height="240"></iframe></p>
<h3>Problems</h3>
<ul>
<li>Chrome isn&#8217;t currently able to apply a <abbr title="Scalable Vector Graphics">SVG</abbr> filter if one has already been applied to an element. This means: if a <abbr title="Scalable Vector Graphics">SVG</abbr> element contains a filter, another filter won&#8217;t be applied via class change, hover or any other CSS pseudo class.</li>
<li>IE6-IE8 doesn&#8217;t support <abbr title="Scalable Vector Graphics">SVG</abbr> within HTML. They see these tags as made up tags and treats them as that. They elements are not able to be styled unless the <abbr title="Scalable Vector Graphics">SVG</abbr> is wrapped in an element and that wrapper element is styled. Alternatively document.createElement() could be used (This is what the HTML5 shim/shiv makes use of. more about it by Paul Irish).</li>
<li>No browser supports the transition property being applied to a <abbr title="Scalable Vector Graphics">SVG</abbr> element</li>
</ul>
<h2><abbr title="Scalable Vector Graphics">SVG</abbr> blur filter applied to a <abbr title="Scalable Vector Graphics">SVG</abbr> image element<img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-chrome.png" alt="Chrome Logo" title="Supported by Chrome" width="32" height="32" class="alignright size-full wp-image-1500" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-firefox.png" alt="Firefox Logo" title="Supported by Firefox" width="32" height="32" class="alignright size-full wp-image-1501" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-opera.png" alt="Opera Logo" title="Supported by Opera" width="32" height="32" class="alignright size-full wp-image-1503" /></h2>
<p>Most of us want to apply a blur filter to images so the above example is all well and good, but it probably won&#8217;t be of too much assistance since the CSS3 text-shadow blur does the same thing. We&#8217;re not able to drop &lt;img&gt; elements into <abbr title="Scalable Vector Graphics">SVG</abbr> an image, luckily <abbr title="Scalable Vector Graphics">SVG</abbr> has it&#8217;s own way of inserting external images. Suddenly this gives us quite a lot of freedom when it comes to Gaussian blur or <a href="https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html">other</a> <a href="http://updates.html5rocks.com/2011/12/CSS-Filter-Effects-Landing-in-WebKit">SVG filters</a>.<br />
<iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/jamygolden/yUG5U/2/embedded/result,html,css/" frameborder="0" width="320" height="240"></iframe></p>
<h3>Most of the above problems apply here as well as a few more:</h3>
<ul>
<li>Chrome can&#8217;t apply a <abbr title="Scalable Vector Graphics">SVG</abbr> filter if one has already been applied, however there is a work around for this in <a href="http://tools.google.com/dlpage/chromesxs">Chrome</a><a href="http://tools.google.com/dlpage/chromesxs">Canary</a>. If you apply a filter to a parent <abbr title="Scalable Vector Graphics">SVG</abbr> element and a hover filter to the child element, the hover effect will take place.</li>
<li>No browser supports the transition property being applied to an <abbr title="Scalable Vector Graphics">SVG</abbr> element</li>
<li>IE9 renders the image (without an applied filter), But lte-IE8 doesn&#8217;t display the image whatsoever.</li>
</ul>
<h2><abbr title="Scalable Vector Graphics">SVG</abbr> Blur Filter applied to <abbr title="Hypertext Markup Language">HTML</abbr> elements<img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-firefox.png" alt="Firefox Logo" title="Supported by Firefox" width="32" height="32" class="alignright size-full wp-image-1501" /></h2>
<p><iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/jamygolden/saR88/1/embedded/result,html,css/" frameborder="0" width="320" height="240"></iframe></p>
<h3>Problems</h3>
<ul>
<li>Firefox is the only browser that supports this</li>
<li>The transition property still doesn&#8217;t take affect when applied</li>
</ul>
<h2>CSS Blur Filter<a href="http://tools.google.com/dlpage/chromesxs"><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-chrome.png" alt="Chrome Logo" title="Supported by Chrome" width="32" height="32" class="alignright size-full wp-image-1500" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-opera.png" alt="Opera Logo" title="Supported by Opera" width="32" height="32" class="alignright size-full wp-image-1503" /></a></h2>
<p>This is where it all gets very exciting. A CSS property that fully supports all kinds of filters including the most important one (for this article at least), the blur filter. It is more simple to use than you could ever imagine – element { filter: blur(2px) }</p>
<p>Unfortunately this can&#8217;t be applied to <abbr title="Scalable Vector Graphics">SVG</abbr> elements, however there is a bit of a work around: You can wrap the <abbr title="Scalable Vector Graphics">SVG</abbr> element within an <abbr title="Hypertext Markup Language">HTML</abbr> tag and apply the CSS filter to that. The only draw back is that the entire <abbr title="Scalable Vector Graphics">SVG</abbr> element will be blurred, and not a single element.<br />
<iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/jamygolden/3asZC/847/embedded/result,html,css/" frameborder="0" width="320" height="240"></iframe><br />
It&#8217;s merely a filter property with a blur value applied. Absolutely amazing. On top of everything, since it&#8217;s a standard CSS property, the transition property works perfectly. You can transition from a normal image, to a half blurred/half grey scale image if you&#8217;d like. It&#8217;s all up to your imagination.</p>
<h3>Problems</h3>
<ul>
<li>Not complete browser support. Webkit only, currently.</li>
</ul>
<p>The &#8220;problem&#8221; is quite a large set back here. The only browser that supports this is a nightly browser version &#8211; This means that we should pretty much stay away from it until at least 2 popular browsers support it&#8230; Right?</p>
<h3>I think you could use it now actually</h3>
<ul>
<li>As long as it&#8217;s not an absolutely dependant feature, browsers will degrade gracefully &#8211; If the property isn&#8217;t supported, the image is unaffected.</li>
<li>It should be supported in Chrome pretty soon</li>
<li>You could use the CSS filter (webkit only) along with the <abbr title="Scalable Vector Graphics">SVG</abbr> filter applied to an <abbr title="Hypertext Markup Language">HTML</abbr> element (firefox only)</li>
</ul>
<p>Here is an example of the CSS Filter used alongside the <abbr title="Scalable Vector Graphics">SVG</abbr> filter.<br />
<iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/jamygolden/3asZC/3/embedded/result,html,css/" frameborder="0" width="320" height="240"></iframe><br />
<a href="http://updates.html5rocks.com/2011/12/CSS-Filter-Effects-Landing-in-WebKit">HTML</a><a href="http://updates.html5rocks.com/2011/12/CSS-Filter-Effects-Landing-in-WebKit">5</a><a href="http://updates.html5rocks.com/2011/12/CSS-Filter-Effects-Landing-in-WebKit">Rocks</a> has a cool article and demo about this property &#8211; Keep in mind the demo currently only works in Chrome Canary.</p>
<h2>Good old fashioned images<img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-chrome.png" alt="Chrome Logo" title="Supported by Chrome" width="32" height="32" class="alignright size-full wp-image-1500" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-firefox.png" alt="Firefox Logo" title="Supported by Firefox" width="32" height="32" class="alignright size-full wp-image-1501" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-ie.png" alt="Internet Explorer Logo" title="Supported by Internet Explorer" width="32" height="32" class="alignright size-full wp-image-1502" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-opera.png" alt="Opera Logo" title="Supported by Opera" width="32" height="32" class="alignright size-full wp-image-1503" /><img src="http://css-plus.com/wp-content/uploads/2012/03/32x32-safari.png" alt="Safari Logo" title="Supported by Safari" width="32" height="32" class="alignright size-full wp-image-1504" /></h2>
<p>This is obviously the most popular at the moment due to the browser support.<br />
<iframe style="width: 100%; height: 600px;" src="http://jsfiddle.net/jamygolden/xG6bb/embedded/result,html,css" frameborder="0" width="320" height="240"></iframe></p>
<h3>Problems</h3>
<ul>
<li>Increased page size due to extra images</li>
<li>Increased HTTP requests (if you don&#8217;t use a sprite)</li>
<li>Annoying to manage if something has to change across all images</li>
</ul>
<h2>What was learnt?</h2>
<p>Chrome can&#8217;t swap <abbr title="Scalable Vector Graphics">SVG</abbr> filters. This means that an element can&#8217;t have a <abbr title="Scalable Vector Graphics">SVG</abbr> filter applied and then have that filter change on hover. IE9 can&#8217;t do much of this which was expected, but what I didn&#8217;t expect was for Safari to be almost as bad at it.</p>
<h2>Anything else?</h2>
<ul>
<li>You could blur the images via the HTML5 canvas, but that&#8217;s another article.</li>
<li>I don&#8217;t really mention Safari in this article &#8211; Most of this doesn&#8217;t seem to work in Safari 5.0.1 for Windows.</li>
<li>The CSS filters are going to be very cool</li>
</ul>
<h2>Article influences</h2>
<p>Paul Irish helped me look in the right direction &#8211; There is a surprisingly little amount of information about this topic out there.</p>
<blockquote class="twitter-tweet" data-in-reply-to="176918533891035136"><p>@<a href="https://twitter.com/jamygolden">jamygolden</a> canary supports CSS filters <a title="https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html" href="https://t.co/vD34peBH">dvcs.w3.org/hg/FXTF/raw-fi&#8230;</a> certainly the shorthands. havent tried the others. you should!<br />
— Paul Irish &#9685;&#8255;&#9685; (@paul_irish) <a href="https://twitter.com/paul_irish/status/176928121675726849" data-datetime="2012-03-06T07:12:06+00:00">March 6, 2012</a></p></blockquote>
<p>Paul&#8217;s article <a href="http://paulirish.com/2010/svg-filters-on-html5-video/"><abbr title="Scalable Vector Graphics">SVG</abbr> filters on HTML5 video</a> was quite informative. <a href="http://paulirish.com/2010/high-res-browser-icons/">High Res Browser Icons</a> was a life saver and I now make use of <a href="http://css3please.com/">CSS3 Please</a> multiple times a day.</p>
<p>The IE &#8216;blur&#8217; method which was used originates from a <a href="http://www.useragentman.com/blog/2011/04/23/css-blurred-text-shadow-in-ie-part-i/">useragentman article</a>. Subsequently <a href="http://www.useragentman.com/">Zoltan Hawryluk&#8217;s</a> (the owner of the useragentman blog) added some really helpful comments in the comments area and helped achieve a really good looking text-blur effect for IE7+.</p>
]]></content:encoded>
			<wfw:commentRss>http://css-plus.com/2012/03/gaussian-blur/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>My Journey to the Perfect Text-Editor</title>
		<link>http://css-plus.com/2012/02/my-journey-to-the-perfect-text-editor/</link>
		<comments>http://css-plus.com/2012/02/my-journey-to-the-perfect-text-editor/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 15:39:40 +0000</pubDate>
		<dc:creator><![CDATA[Jamy Golden]]></dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-plus.com/?p=1413</guid>
		<description><![CDATA[This article is about why I feel Sublime Text 2 is the best text editor ever and how/why I ended up using it. I&#8217;ve decided to write this because I seem to talk about this topic quite often and it &#8230; <a href="http://css-plus.com/2012/02/my-journey-to-the-perfect-text-editor/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This article is about why I feel Sublime Text 2 is the best text editor ever and how/why I ended up using it. I&#8217;ve decided to write this because I seem to talk about this topic quite often and it would be easier for me to reference someone to an article rather than explaining my rationale over and over again.<br />
<span id="more-1413"></span></p>
<h2>Dreamweaver<img class="alignright size-full wp-image-1430" title="Windows" src="http://css-plus.com/wp-content/uploads/2012/02/windows-logo.jpg" alt="Windows Logo" width="40" height="40" /><img class="alignright size-full wp-image-1431" title="OSx" src="http://css-plus.com/wp-content/uploads/2012/02/apple-logo.png" alt="Apple Logo" width="40" height="40" /><a href="http://www.adobe.com/products/dreamweaver.html"><img class="alignright size-full wp-image-1420" title="Dreamweaver" src="http://css-plus.com/wp-content/uploads/2012/02/dreamweaver.png" alt="Dreamweaver thumbnail" width="40" height="40" /></a></h2>
<p>I started using Dreamweaver&#8217;s design mode when I began web-development. I didn&#8217;t touch HTML. I started using some of the <abbr title="Dreamweaver">DW</abbr> javascript functionality which I thought was quite powerful at the time ( this was literally all done without looking at HTML ), but I was getting frustrated with the tabular layout &#8211; It felt like I was fighting it more than working with it. Changing the width of tabular layouts isn&#8217;t easy when you have multiple nested tables.</p>
<p>I started seeing all kinds of unbelievable tutorials and javascript plugins online. Things like dragging elements around as if they were windows in an operating system. I slowly started manipulating other people&#8217;s code within the <abbr title="Dreamweaver">DW</abbr> code view and eventually I was permanently using that view. I felt design mode was for newbies and tabular design was old-school and evil. It was at this time that I started following popular online blogs such as <a href="http://css-tricks.com/">CSS-Tricks</a> and <a href="http://davidwalsh.name/">David Walsh</a>, etc.</p>
<p>Dreamweaver features that stood out for me:</p>
<ul>
<li>I enjoyed the syntax highlighting colours</li>
<li>Wrap text in element functionality</li>
<li>tags closed automatically</li>
<li>Find/replace throughout open files</li>
</ul>
<p>Note: It took Dreamweaver 30 seconds to load up so I could take the screenshot. Core2Quad 2.3ghz with 3gb of ram.</p>
<h2>Notepad++<img class="alignright size-full wp-image-1430" title="Windows" src="http://css-plus.com/wp-content/uploads/2012/02/windows-logo.jpg" alt="Windows Logo" width="40" height="40" /><a href="http://notepad-plus-plus.org/"><img class="alignright size-full wp-image-1436" title="Notepad++" src="http://css-plus.com/wp-content/uploads/2012/02/notepad-plus-plus.png" alt="Notepad++ Logo" width="56" height="40" /></a></h2>
<p>I eventually moved over to Notepad++. I enjoyed how quick it was &#8211; Lightning quick compared to the bulky Dreamweaver. However it didn&#8217;t have most of the things I liked about Dreamweaver and it wasn&#8217;t nearly as aesthetically pleasing with regards to icon layout, icons, colours in general and the syntax highlighting. I actually found &#8211; and still do find &#8211; the toolbar of icons ( including print, copy/cut/paste, find, etc) very insulting. Eventually I was using Notepad++ without turning back to Dreamweaver for anything, but still I didn&#8217;t feel completely comfortable with it, something was missing.</p>
<p>Note: I probably didn&#8217;t use this editor to it&#8217;s full potential.</p>
<h2>E-TextEditor<img class="alignright size-full wp-image-1430" title="Windows" src="http://css-plus.com/wp-content/uploads/2012/02/windows-logo.jpg" alt="Windows Logo" width="40" height="40" /><a href="http://www.e-texteditor.com/"><img class="alignright size-full wp-image-1423" title="e-texteditor" src="http://css-plus.com/wp-content/uploads/2012/02/e-texteditor.jpg" alt="" width="40" height="40" /></a></h2>
<p>I began noticing how many people were talking about TextMate but I could not use it since it was/is a Mac specific application. After some googling I noticed there was a &#8216;Windows&#8217; version of TextMate called &#8216;E-TextEditor&#8217;.</p>
<p>I found the syntax highlighting very pleasing and it had almost everything I could want, including FTP built into the app &#8211; This felt much more simple to get going than the Dreamweaver FTP functionality. One thing it didn&#8217;t have was &#8216;Find/replace throughout open files&#8217;. This was something I had missed since Dreamweaver.</p>
<p>Without a doubt, this became my text-editor of choice.</p>
<h2>GEdit<img class="alignright size-full wp-image-1426" title="Linux" src="http://css-plus.com/wp-content/uploads/2012/02/linux-tux.jpg" alt="Linux Tux" width="40" height="40" /><a href="http://projects.gnome.org/gedit/"><img class="alignright size-full wp-image-1424" title="GEdit" src="http://css-plus.com/wp-content/uploads/2012/02/gedit.png" alt="GEdit Logo" width="100" height="50" /></a></h2>
<p>I was getting fed up with Windows for various reasons and I couldn&#8217;t afford a Mac, so Linux ( Ubuntu ) was my next logical step. GEdit was/is the default text editor for Ubuntu and I was surprised that the default text editor that was so &#8216;advaced&#8217; compared to other default OS text editors. This mainly included pleasing syntax highlighting and tabbed functionality. GEdit didn&#8217;t have the &#8216;Find/replace throughout open files&#8217; functionality and something about it didn&#8217;t feel great when using it for larger projects. As far as features went, it didn&#8217;t have too many that I was aware of. For small HTML/CSS/JS projects or tests it was perfect though.</p>
<h2>Scite<img class="alignright size-full wp-image-1426" title="Linux" src="http://css-plus.com/wp-content/uploads/2012/02/linux-tux.jpg" alt="Linux Tux" width="40" height="40" /><a href="http://www.scintilla.org/SciTE.html"><img class="alignright size-full wp-image-1427" title="Scite" src="http://css-plus.com/wp-content/uploads/2012/02/scite.png" alt="Scite Logo" width="40" height="40" /></a></h2>
<p>By default Scite has ( or my default installation at the time ) the line numbers disabled. This is/was highly annoying and on top of that, it wouldn&#8217;t &#8216;remember&#8217; my option to keep line numbers enabled. Small things like this can really get to me &#8211; I want to feel completely at ease, comfortable and happy with my tools.</p>
<p>I didn&#8217;t really like the icons and the general look and feel of the editor, however, it was definitely much more advanced and nicer to use than GEdit &#8211; with options like “Convert selection to lowercase” to regular expression searches. By this time I had decided Scite was the Linux text editor for me, however as much as I liked it I preferred E-TextEditor, but I had completely moved away from Windows &#8211; apart from my virtual machine with PhotoshopCS3 and IETester. It&#8217;s difficult using a text editor when I would have switched it for E-TextEditor or TextMate in a heartbeat.</p>
<h2>Coda<img class="alignright size-full wp-image-1431" title="OSx" src="http://css-plus.com/wp-content/uploads/2012/02/apple-logo.png" alt="Apple Logo" width="40" height="40" /><a href="http://panic.com/coda/"><img class="alignright size-full wp-image-1422" title="Coda" src="http://css-plus.com/wp-content/uploads/2012/02/coda.png" alt="Coda Logo" width="40" height="40" /></a></h2>
<p>I began using a Mac at work and it had Coda pre-installed. I had heard almost as much about Coda as I had about TextMate, mainly from Chris Coyier and a co-worker/friend. I enjoyed Coda &#8211; It had extremely simple and intuitive FTP support and was very nice to use. Coda had random nuggets I hadn&#8217;t seen in editors, like a wildcard character within searches. This could be achieved with regular expressions in other text editors, but the simple option was nice. The lack of functionality I was used to got to me. Coda was nice for larger PHP projects or smaller HTML projects.</p>
<h2>TextMate<img class="alignright size-full wp-image-1431" title="OSx" src="http://css-plus.com/wp-content/uploads/2012/02/apple-logo.png" alt="Apple Logo" width="40" height="40" /><a href="http://macromates.com/"><img class="alignright size-full wp-image-1429" title="TextMate" src="http://css-plus.com/wp-content/uploads/2012/02/textmate.jpg" alt="TextMate Logo" width="40" height="40" /></a></h2>
<p>I was really eager to try out TextMate. I had heard so much about it and E-TextEditor was based on it.</p>
<p>TextMate was very different from other editors &#8211; especially since I was new to OSx. It was pretty much just a window of text. All the options could be accessed via keyboard-shortcuts or by the options panel. It took me a couple of minutes to get used to it but I really loved it.</p>
<h2>Komodo Edit<img class="alignright size-full wp-image-1430" title="Windows" src="http://css-plus.com/wp-content/uploads/2012/02/windows-logo.jpg" alt="Windows Logo" width="40" height="40" /><img class="alignright size-full wp-image-1426" title="Linux" src="http://css-plus.com/wp-content/uploads/2012/02/linux-tux.jpg" alt="Linux Tux" width="40" height="40" /><img class="alignright size-full wp-image-1431" title="OSx" src="http://css-plus.com/wp-content/uploads/2012/02/apple-logo.png" alt="Apple Logo" width="40" height="40" /><a href="http://www.activestate.com/komodo-edit"><img class="alignright size-full wp-image-1425" title="Komodo Edit" src="http://css-plus.com/wp-content/uploads/2012/02/komodo-edit.png" alt="Komodo Edit Logo" width="40" height="40" /></a></h2>
<p>As much as I liked TextMate, I could never get completely used to it because at the time I was working on 2 operating systems &#8211; OSx ( work ) and Ubuntu ( home/dev ). I was also sure I would end up using Windows for some or other reason in future due to work or somewhere else I was forced to. This meant that I would be using a different text editor on each operating system. This made me feel uncomfortable and I didn&#8217;t want to learn to use something I&#8217;d end up not using. It felt like a waste of time investment. I definitely wanted to get used to an editor that worked across all platforms. I wanted a text editor I would use for the rest of my life.</p>
<p>My seeking continued until I had found KomodoEdit. It was great. It had a couple of things I wasn&#8217;t ecstatic about, but the fact that it was cross platform made me forget about those quickly. KomodoEdit was definitely a very powerful text editor. I was referred to the application by a hardcore PHP backend friend and that made me feel good since I felt that I could grow with the editor if I needed to.</p>
<p>KomodoEdit is a light-weight and free version of KomodoIDE. I had found pretty much everything I had wanted.</p>
<ul>
<li>Light-weight &#8211; Check</li>
<li>Multiple language support &#8211; Check</li>
<li>Plenty of options &#8211; Check</li>
<li>Powerful &#8211; Check</li>
<li>Cross-Platform compatible &#8211; Check</li>
<li>Aesthetically pleasing &#8211; No</li>
<li>Find/replace throughout open tabs &#8211; No</li>
</ul>
<h2>Sublime Text 2<img class="alignright size-full wp-image-1430" title="Windows" src="http://css-plus.com/wp-content/uploads/2012/02/windows-logo.jpg" alt="Windows Logo" width="40" height="40" /><img class="alignright size-full wp-image-1426" title="Linux" src="http://css-plus.com/wp-content/uploads/2012/02/linux-tux.jpg" alt="Linux Tux" width="40" height="40" /><img class="alignright size-full wp-image-1431" title="OSx" src="http://css-plus.com/wp-content/uploads/2012/02/apple-logo.png" alt="Apple Logo" width="40" height="40" /><a href="http://www.sublimetext.com/2"><img src="http://css-plus.com/wp-content/uploads/2012/02/sublime-text-thumb-logo.png" alt="Sublime Text Logo" title="Sublime Text 2" width="40" height="40" class="alignright size-full wp-image-1460" /></a></h2>
<p>Finally I stumbled upon Sublime Text 2. And it was good.</p>
<p>It had everything I could ever want and more, this went from <a href="http://www.sublimetext.com/docs/2/multiple_selection_with_the_keyboard.html">Multi-select</a> to <a href="http://www.sublimetext.com/docs/2/distraction_free.html">distraction free mode</a>. It had all the above checks, it was aesthetically pleasing and had an unbelievable find functionality. The Mac text editors ( TextMate and Coda ) look and feel far better to use than applications on other operating systems &#8211; It&#8217;s like they&#8217;re just made better. SublimeText2 has kept this feeling, even on different operating systems. The fact that text editors had to look ugly in Linux and Windows had been something I had wondered about on and off for a long time &#8211; Finally there was one editor that broke my perception.</p>
<p>I had never used a dark theme before but the default SublimeText2 was perfect. It had Chrome styled tabs, you could record macros, create your own snippets very easily and it had a visual map of document on the side of the editor ( this seemed like it could get old quickly, but I find it very useful in spotting patterns in larger documents).</p>
<p>The options worked differently compared to any other application I had used before. An options page was a text page in a sort of object/array layout. At first I thought this was temporary and it would be updated in a future version, but I finally realized how brilliant it was. You could search for options via the text editor. Search results appear in another default text-editor tab and it&#8217;s all consistent. You don&#8217;t ever leave tabs and text, brilliant.</p>
<p>The best part is, it&#8217;s only a beta. That&#8217;s right, until the time of this writing <abbr title="Sublime Text 2">ST2</abbr> is a beta and it gets updated VERY often. New features, functionality and bug fixes come out with every update. <abbr title="Sublime Text 2">ST2</abbr> has always been expensive for a text-editor, atleast $59 is expensive for one to me, but <abbr title="Sublime Text 2">ST2</abbr> allows you to trial the software for as long as you&#8217;d like. On the site it says:</p>
<p>Sublime Text may be downloaded and evaluated for free, however a license must be purchased for continued use.</p>
<p>The license comes with a bunch of perks, the most noticable includes a per-user license, not per-install or per-machine. This means you can use the registered version on whatever operating system and machine you&#8217;re using. After running and using it on all operating systems I decided to purchase it and I would urge anyone who loves it half as much as I do to support the development.</p>
<p>On top of all of this, I&#8217;ve subsequently began to learn Ruby and it&#8217;s got a Ruby build system installed &#8211; along with a bunch of other builds, including ant build. <abbr title="Sublime Text 2">ST2</abbr> supports a vast amount of languages ( more than just syntax highlighting ), has plugin support and it supports Textmate snippets. The <a href="http://www.sublimetext.com/forum/">community </a>is also pretty great.</p>
<p>As you may possibly know, I develop HTML, CSS, Javascript, PHP and Ruby. I&#8217;ve got friends who I&#8217;ve convinced to permanently use <abbr title="Sublime Text 2">ST2</abbr> and they use languages ranging from Python to C++.</p>
<p>According to me, it is by far the best text-editor around.</p>
<h2>tldr;</h2>
<p>Sublime Text 2 is awesome.</p>
<h2>Disclaimer</h2>
<p>I don&#8217;t own any of the icons used, they belong to the text-editor/operating system.<br />
I may have unfairly moved on from some of the text editors due to lack of specific functionality (or perceived lack of), aesthetics and cross-OS support. I may have been a bit unfair and some of you may disagree with me, but for me <abbr title="Sublime Text 2">ST2</abbr> wins in every field. Also, if I&#8217;ve misrepresented any text-editor above, please correct me by with a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://css-plus.com/2012/02/my-journey-to-the-perfect-text-editor/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Bulletproof full page background images don&#8217;t exist</title>
		<link>http://css-plus.com/2012/01/bulletproof-full-page-background-images/</link>
		<comments>http://css-plus.com/2012/01/bulletproof-full-page-background-images/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 16:23:16 +0000</pubDate>
		<dc:creator><![CDATA[Jamy Golden]]></dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-plus.com/?p=1393</guid>
		<description><![CDATA[They don&#8217;t and can&#8217;t exist. Before I continue, let me explain what a &#8216;bulletproof full page background&#8217; is. This is a solution that will always give the &#8216;perfect&#8217; full page background-image across multiple viewports regardless of which image you are &#8230; <a href="http://css-plus.com/2012/01/bulletproof-full-page-background-images/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>They <em>don&#8217;t</em> and <em>can&#8217;t exist</em>. Before I continue, let me explain what a &#8216;bulletproof full page background&#8217; is. This is a solution that will always give the &#8216;perfect&#8217; full page background-image across multiple viewports <strong>regardless of which image you are using</strong>.<br />
<strong>Note:</strong> I understand &#8216;perfect&#8217; is a very subjective term.<br />
<span id="more-1393"></span><br />
I have been asked to create a full page background image before; There was a problem, however&#8230; </p>
<p>Images can stretch nicely as long as the proportion remains constant, otherwise the image looks stretched. This is an example of what someone might consider a perfect full page background-image:<br />
<img src="http://css-plus.com/wp-content/uploads/2012/01/perfect-scale-1.png" alt="" title="perfect-scale-1" width="366" height="218" class="alignnone size-full wp-image-1394" srcset="http://css-plus.com/wp-content/uploads/2012/01/perfect-scale-1.png 366w, http://css-plus.com/wp-content/uploads/2012/01/perfect-scale-1-180x107.png 180w, http://css-plus.com/wp-content/uploads/2012/01/perfect-scale-1-300x178.png 300w" sizes="(max-width: 366px) 100vw, 366px" /><br />
As you can see, the scale remains constant and this works with the perfect full page background-image.</p>
<h2>Problem 1</h2>
<p>The background in the previous example contains the width/height of the viewport. If the second viewport didn&#8217;t have the same dimension ratio, that very same background could look something like this:<br />
<img src="http://css-plus.com/wp-content/uploads/2012/01/scale-stretch-height.png" alt="" title="scale-stretch-height" width="466" height="197" class="alignnone size-full wp-image-1396" srcset="http://css-plus.com/wp-content/uploads/2012/01/scale-stretch-height.png 466w, http://css-plus.com/wp-content/uploads/2012/01/scale-stretch-height-180x76.png 180w, http://css-plus.com/wp-content/uploads/2012/01/scale-stretch-height-300x126.png 300w" sizes="(max-width: 466px) 100vw, 466px" /><br />
That is clearly an example of a &#8216;failed&#8217; full page background. </p>
<h2>Problem 2</h2>
<p>A <em>typical and easy</em> way to fix it would be to set the background-image width to be equal to the viewport&#8217;s width, but <em>leave the height a dynamic size</em>. This would give you something that looks like this:<br />
<img src="http://css-plus.com/wp-content/uploads/2012/01/scale-cutoff.png" alt="" title="scale-cutoff" width="466" height="197" class="alignnone size-full wp-image-1395" srcset="http://css-plus.com/wp-content/uploads/2012/01/scale-cutoff.png 466w, http://css-plus.com/wp-content/uploads/2012/01/scale-cutoff-180x76.png 180w, http://css-plus.com/wp-content/uploads/2012/01/scale-cutoff-300x126.png 300w" sizes="(max-width: 466px) 100vw, 466px" /><br />
Obviously the problem here is that the entire bottom area of the image is currently not visible&#8230; Unless you scroll down, which defeats the purpose of a full-page background-image.</p>
<h2>Problem 3</h2>
<p>You could very well set the height to fit the viewport&#8217;s height and have a dynamic width. With this example, the output would now look something like this:<br />
<img src="http://css-plus.com/wp-content/uploads/2012/01/scale-cutoff-width.png" alt="" title="scale-cutoff-width" width="466" height="197" class="alignnone size-full wp-image-1400" srcset="http://css-plus.com/wp-content/uploads/2012/01/scale-cutoff-width.png 466w, http://css-plus.com/wp-content/uploads/2012/01/scale-cutoff-width-180x76.png 180w, http://css-plus.com/wp-content/uploads/2012/01/scale-cutoff-width-300x126.png 300w" sizes="(max-width: 466px) 100vw, 466px" /><br />
This seems like the perfect full page background image solution right? Well&#8230; Not really. If we used the exact same technique with an image that has a larger width than it does height, it would look like this:<br />
<img src="http://css-plus.com/wp-content/uploads/2012/01/scale-stretch-width.png" alt="" title="scale-stretch-width" width="466" height="197" class="alignnone size-full wp-image-1397" srcset="http://css-plus.com/wp-content/uploads/2012/01/scale-stretch-width.png 466w, http://css-plus.com/wp-content/uploads/2012/01/scale-stretch-width-180x76.png 180w, http://css-plus.com/wp-content/uploads/2012/01/scale-stretch-width-300x126.png 300w" sizes="(max-width: 466px) 100vw, 466px" /></p>
<h2>So, what is the solution?</h2>
<p>The perfect solution exists, as long as you don&#8217;t feel that &#8216;perfect&#8217; implies every image should look great with the specific solution. As long as you have background images with similar layouts ( All have width &gt; height or visa versa ) you could use a solution to work with them all.</p>
<p>I have seen a static image used as a centered background image which worked well for that situation.<br />
<img src="http://css-plus.com/wp-content/uploads/2012/01/static-example.png" alt="" title="static-example" width="466" height="197" class="alignnone size-full wp-image-1398" srcset="http://css-plus.com/wp-content/uploads/2012/01/static-example.png 466w, http://css-plus.com/wp-content/uploads/2012/01/static-example-180x76.png 180w, http://css-plus.com/wp-content/uploads/2012/01/static-example-300x126.png 300w" sizes="(max-width: 466px) 100vw, 466px" /></p>
<h2>Conclusion</h2>
<p>When it comes to full page background images and dynamic backgrounds, make sure you understand how the dimensions work and pick the right solution for your needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://css-plus.com/2012/01/bulletproof-full-page-background-images/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Use :pseudo-elements as list-style-image alternatives</title>
		<link>http://css-plus.com/2011/12/control-your-list-items/</link>
		<comments>http://css-plus.com/2011/12/control-your-list-items/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 16:25:17 +0000</pubDate>
		<dc:creator><![CDATA[Jamy Golden]]></dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-plus.com/?p=1312</guid>
		<description><![CDATA[Styling lists with CSS can be a bit of a pain from time to time. If I require an kind of customized bullet, the first CSS property I think of is list-style: none;. I&#8217;ve tried on more than one occasion &#8230; <a href="http://css-plus.com/2011/12/control-your-list-items/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Styling lists with <abbr title="Cascading Style Sheets">CSS</abbr> can be a bit of a pain from time to time. If I require an kind of customized bullet, the first <abbr title="Cascading Style Sheets">CSS</abbr> property I think of is <code>list-style: none;</code>. I&#8217;ve tried on more than one occasion to use <code>list-style-image</code> but it&#8217;s given me nothing but trouble when attempting to position it. A popular alternative is to use the image as a <code>background-image</code> of the list item.<br />
<span id="more-1312"></span></p>
<pre><code class="language-css">li { background: url(images/bullet.png) no-repeat left top; list-style: none; }</code></pre>
<p>This gives us the ability to move the &#8216;<i>list-item</i>&#8216; around as we please without problems. Great solution! right?! No, there are three very annoying (however, small) problems with this method:</p>
<ul>
<li>You can&#8217;t effectively include the list item in a sprite, as you&#8217;d run into problems displaying areas of the sprite you wish to remain hidden.</li>
<li>An image obviously can&#8217;t work with ordered lists as the numbered <code>list-style-type</code> would require a different image for each list item. This is possible but not very effective as it would require a lot of images and it wouldn&#8217;t be ever-expanding &#8211; It would have static amount of numbered images.</li>
<li>Adds to HTTP requests &#8211; this is especially annoying if you&#8217;ve got a couple of different lists all using this method</li>
</ul>
<p>Those are my two problems I have with the <code>background-image</code>, but I have managed to find a way around it.</p>
<h2>Standard background-image method</h2>
<p>Before I get started on the way I usually do this, let me show you what I did before and what I think most people do.</p>
<h3>The <abbr title="Hypertext Markup Language">HTML</abbr> necessary</h3>
<pre><code class="language-html">&lt;ul class="first-example"&gt;
	&lt;li&gt;SEO&lt;/li&gt;
	&lt;li&gt;Content Management System&lt;/li&gt;
	&lt;li&gt;Social Network Integration&lt;/li&gt;
	&lt;li&gt;Another list item for emphasis&lt;/li&gt;
&lt;/ul&gt;</code></pre>
<h3>The <abbr title="Cascading Style Sheets">CSS</abbr> necessary</h3>
<pre><code class="language-css">.first-example li { background: url(../i/tick.png) no-repeat left 8px; }
.first-example li { border-bottom: 1px solid #eee; font-size: 14px; list-style: none; padding: 10px 0 10px 40px; }</code></pre>
<p>You can see what&#8217;s going on, no explanation needed. The only thing to note here is the list items contain a background image and that image is a single file separate from the sprite which adds to http requests.</p>
<h2>Make use of <b>pseudo elements</b></h2>
<p>Pseudo elements are our friends. They are that extra bit of gas in the tank. When everything looks dull and there is no easy way to do what it is you want to do, look towards pseudo elements.</p>
<p>We could use pseudo elements as the &#8216;bullets&#8217;. This would solve the problem of showing more sprite than we&#8217;d like since we can set the pseudo-element&#8217;s <code>width</code> and <code>height</code> and give it the sprite background.</p>
<h3>The HTML</h3>
<p>The HTML is exactly the same as the first example with. The only difference is the class selector used for us to target.</p>
<pre><code class="language-html">&lt;ul class="second-example"&gt;
	&lt;li&gt;SEO&lt;/li&gt;
	&lt;li&gt;Content Management System&lt;/li&gt;
	&lt;li&gt;Social Network Integration&lt;/li&gt;
	&lt;li&gt;Another list item for emphasis&lt;/li&gt;
&lt;/ul&gt;</code></pre>
<pre><code class="language-css">li { border-bottom: 1px solid #eee; font-size: 14px; list-style: none; padding: 10px 0 10px 40px; position: relative; }

ul.second-example li:before {
	content: '';
	background: url(../i/sprite.png) no-repeat left top;
	height: 20px;
	width: 20px;
	position: absolute;
	left: 0;
	top: 8px;
}

ul.second-example li:nth-child(2n):before {
	background-position: -21px 0;
}</code></pre>
<p>Why exactly are we giving every second example a different list item image? For two reasons:</p>
<ul>
<li>It gives me an excuse to use a sprite in this example</li>
<li>We&#8217;re just retro and hip like that</li>
</ul>
<p>Le&#8217;s see what would have happened if we gave the first example the sprite as the background.</p>
<h3>List item with the sprite as a background-image</h3>
<p><img src="http://css-plus.com/wp-content/uploads/2011/11/background-with-sprite.jpg" alt="List items with a sprite background image" title="background-with-sprite" width="270" height="150" class="alignleft size-full wp-image-1318" /></p>
<h3>List item with pseudo element using the sprite as a background image &#8211; Preferred method</h3>
<p><img src="http://css-plus.com/wp-content/uploads/2011/11/pseudo-element-with-sprite.jpg" alt="Pseudo elements acting as list item bullets" title="pseudo-element-with-sprite" width="270" height="150" class="alignleft size-full wp-image-1319" /></p>
<h2>Make use of <abbr title="Cascading Style Sheets">CSS</abbr> counters</h2>
<p><img src="http://css-plus.com/wp-content/uploads/2011/12/ordered-list-pseudo-elements.jpg" alt="" title="ordered-list-pseudo-elements" width="241" height="167" class="alignleft size-full wp-image-1337" />What exactly are <a href="https://developer.mozilla.org/en/CSS_Counters">CSS counters</a>? A <abbr title="Cascading Style Sheets">CSS</abbr> counter is a function that is accepted by the <code>content</code> property of a pseudo element. You can count whatever it is you like. The amount of <code>&lt;section&gt;</code> elements in an article, the amount of <code>&lt;h2&gt;</code> elements, etc. In this case we&#8217;re going to be counting the amount of <code>&lt;li&gt;</code> elements. This way we can dynamically give the :before/:after pseudo elements a numerical value which will help to number our list items. </p>
<p>The <a href="https://developer.mozilla.org/en/CSS_Counters">CSS counter</a> property is within the <a href="http://www.w3.org/TR/CSS2/generate.html#counters">CSS 2.1 spec</a>. So this means that it has support down to IE8. I understand that it won&#8217;t work in IE7 &amp; IE6, but I don&#8217;t really care too much &mdash; I&#8217;d probably just give them the default numerical <code>list-item-type</code>.</p>
<h3>Bring on the CSS</h3>
<p>Some of <abbr title="Cascading Style Sheets">CSS</abbr> following will be the same as the previous CSS, but that&#8217;s because the list is styled in a similar fashion.<br />
li { border-bottom: 1px solid #eee; font-size: 14px; list-style: none; padding: 10px 0 10px 40px; position: relative; }<br />
li:first-child { border-top: 1px solid #eee; }</p>
<p>ul.first-example li { content: &#8221;; background: url(../i/tick.png) no-repeat left 8px; }</p>
<pre><code class="language-javascipt">ol.third-example { counter-reset: li; }

ol.third-example li { position: relative; }

ol.third-example li:before { 
	content: counter(li); 
	counter-increment: li; 
	background: #f692bb; 
	color: #333;
	font: bold 14px/20px sans-serif; 
	height: 20px; 
	text-align: center; 
	width: 20px; 
	position: absolute; 
	left: 0; 
	top: 8px; 
	-webkit-border-radius: 10px;
	   -moz-border-radius: 10px;
	        border-radius: 10px;
	-webkit-box-shadow: inset 0 0 5px #F0498D, 2px 2px 0 rgba(0,0,0,.15);
	   -moz-box-shadow: inset 0 0 5px #F0498D, 2px 2px 0 rgba(0,0,0,.15);
		box-shadow: inset 0 0 5px #F0498D, 2px 2px 0 rgba(0,0,0,.15);
}</code></pre>
<p>Before I continue, thanks <a href="http://twitter.com/paulirish">paulirish</a> and <a href="http://twitter.com/jon_neal">jon_neal</a> for <a href="http://css3please.com/">CSS3 Please</a> &#8211; Quite a helpful tool.</p>
<p>Note: the position relative on the list item is very necessary since you&#8217;ll be absolutely positioning the pseudo elements within each item.</p>
<p>To use the counter() function properly, 3 things need to ne done.</p>
<ul>
<li>The counter of the specific element needs to be reset &mdash; Or as I like to think of it, enabled</li>
<li>The counter-increment needs to be told what to count, and by how much. (the increment could be by 2, or 10, in this example we&#8217;re going to leave it on 1 by default)</li>
<li>The counter() function needs to be passed into the content property and then told what to count</li>
</ul>
<p>Ok so first thing to do is to add the <code>counter-reset</code> property to the parent/ancestor container of the item you wish to count. You then give the <code>counter-reset</code> value the element type of the element to count. If you&#8217;d like to count the amount of paragraphs in the article element, you could reset the counting by adding the following <abbr title="Cascading Style Sheets">CSS</abbr> to your document:</p>
<pre><code class="language-javascript">body { counter-reset: p; }
/* Or */
article { counter-reset: p; }</code></pre>
<p>It cascades, so any container will do.</p>
<p>You would then add the <code>counter-increment</code> property to the pseudo element, this tells the pseudo element which element to count and by how much.</p>
<pre><code class="language-css">li { counter-increment: li 5; }</code></pre>
<p>That example would count in increments of 5 starting on that value, so: 5, 10, 15, etc. If you leave that value out it defaults to 1.</p>
<p>Finally, you would then add the <code>counter()</code> function to the <code>content</code> property of the pseudo element. This literally tells the pseudo element to contain the incremented value. </p>
<h2>Conclusion</h2>
<p>I find this extremely useful and consider it one of my better <abbr title="Cascading Style Sheets">CSS</abbr> tricks.<br />
Browser support isn&#8217;t horrible, but not brilliant either &mdash; The inclusion of IE7 would make it brilliant. Never the less, it&#8217;s completely usable in every day scenarios since I use it fairly often and I give IE7 the deafult numbered styling.</p>
<p>To recap: <b>counter-reset</b>: element, <b>counter-increment</b>: element num, <b>content</b>: counter(element).</p>
<p>Note: I actually make use of the custom bullets via pseudo elements on my unordered list items within my current website design.</p>
]]></content:encoded>
			<wfw:commentRss>http://css-plus.com/2011/12/control-your-list-items/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to make the input placeholder more user friendly</title>
		<link>http://css-plus.com/2011/09/make-the-input-placeholder-user-friendly/</link>
		<comments>http://css-plus.com/2011/09/make-the-input-placeholder-user-friendly/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 14:15:03 +0000</pubDate>
		<dc:creator><![CDATA[Jamy Golden]]></dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://css-plus.com/?p=1232</guid>
		<description><![CDATA[I&#8217;ve always loved placeholder text for input fields. Not too long ago the only way to achieve this would be to create a special javascript function that enabled the desired functionality, but now it magically comes pre-built into HTML5. Incase &#8230; <a href="http://css-plus.com/2011/09/make-the-input-placeholder-user-friendly/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve always loved placeholder text for input fields. Not too long ago the only way to achieve this would be to create a special javascript function that enabled the desired functionality, but now it <strong>magically comes pre-built into <abbr title="Hypertext Markup Language 5">HTML5</abbr></strong>. Incase you&#8217;re wondering, placeholder text is the text within an input field that disappears once you click on it. It&#8217;s often used in place of a label.<span id="more-1232"></span></p>
<h2>How is it not user friendly? <span><a href="#h1-html"><abbr title="Too long, didn't read">tl;dr</abbr> &#8211; Take me to the tutorial already</a></span></h2>
<p>Placeholder text can be very helpful and can save a lot of page space while also being aesthetically pleasing. With this great feature, however, comes a problem: If the placeholder text is being used in place of a label, it can become very confusing when you focus on the field and the &#8216;label&#8217; disappears.</p>
<p>It&#8217;s important for users to know:</p>
<ul>
<li>What field they are currently on</li>
<li>What field they have filled in</li>
</ul>
<h3>Typical input placeholder problem</h3>
<figure><img src="http://css-plus.com/wp-content/uploads/2011/09/placeholder-problem.png" alt="Figure 1 - Standard input placeholder problem" title="Figure 1 - Standard input placeholder problem" width="365" height="30" class="alignnone size-full wp-image-1234" /><figcaption>Which input field am I on?</figcaption></figure>
<p>Based on the image above, it&#8217;s impossible to tell what the first/focused field is. It is relatively simple to deduce <em>it&#8217;s either</em> a &#8216;<em>username</em>&#8216; or &#8216;<em>email</em>&#8216; field. The only way to find out which field you&#8217;re on would be to remove all the text in the field and blur (lose focus). I have personally been caught by this dozens and dozens of times and I find it very annoying.</p>
<p>One method that websites, such as <a href="http://twitter.com" rel="external">Twitter</a>, have been adopting is to have the <em>placeholder text fade out slightly on focus</em>, but only disappear once the user inputs some text. This is arguably the way that the <abbr title="Hypertext Markup Language 5">HTML5</abbr> placeholder should work by default.</p>
<h3>An improved version</h3>
<p><img src="http://css-plus.com/wp-content/uploads/2011/09/twitter-placeholder.jpg" alt="Figure 2 - The Twitter input placeholder" title="Figure 2 - The Twitter input placeholder" width="385" height="375" class="alignleft size-full wp-image-1247" /></p>
<ol>
<li>Normal Placeholder text</li>
<li>Placeholder text fades out slightly on focus</li>
<li>The input field is unknown once text has been added</li>
<li>The title attribute is used to add information</li>
</ol>
<p>The method that the <strong>Twitter login system</strong> uses is a big step up from the problem in fig.1, however the <strong>same problem still exists</strong> once the user has added text. </p>
<p>The <strong>title attribute</strong> has been used here so a user can see the placeholder text by hovering over the input field which is a great addition. Unfortunately in general, I still don&#8217;t feel this is as very user friendly as it could be.</p>
<h2>The solution</h2>
<p>I would like all of the bonuses of both the placeholder method and the standard label method. I&#8217;ve decided there is one basic way to achieve this: Have either the <strong>label of the input field</strong> or an <em>appropriate icon</em> appear to the right of the field after the field has received focus.</p>
<p>So that&#8217;s it, in this tutorial I&#8217;m going to show you how you can make a form with placeholder text that is semantic, user-friendly and degrades gracefully for legacy browsers.</p>
<h2><a id="h1-html"></a>The HTML</h2>
<p>The following <abbr title="Hypertext Markup Language">HTML</abbr> is normal &lt;form&gt; markup. It&#8217;s what we do with the <abbr title="Cascading Style Sheets">CSS</abbr> that really matters.</p>
<pre><code class="language-html">&lt;form id="login"&gt;
    &lt;ul&gt;
        &lt;li&gt;
            &lt;input id="email" name="email" placeholder="Your Email" title="Your Email" type="email" required /&gt;
            &lt;label for="email"&gt;Your Email&lt;/label&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;input id="password" name="password" placeholder="Your Password" title="Your Password" type="password" required /&gt;
            &lt;label for="password"&gt;Your Password&lt;/label&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;input id="submit" name="submit" type="submit" value="Login"&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
&lt;/form&gt;</code></pre>
<h2>The CSS</h2>
<pre><code class="language-css">#login{font-size: 12px; margin: 0 auto; width: 700px;}
#login li{float: left; list-style: none; margin-left: 30px; position: relative;}
#login li:first-child{margin-left: 0;}

label{line-height: 40px; position: absolute; right: 120px; top: 0; bottom: 0;
    -moz-transition: 0.3s right ease;
    -ms-transition: 0.3s right ease;
    -o-transition: 0.3s right ease;
    -webkit-transition: 0.3s right ease;
    transition: 0.3s right ease;
 	z-index: 0}

input{color: transparent; font-size: 12px; height: 35px; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px;
    -moz-transition: 0.3s all ease;
    -ms-transition: 0.3s all ease;
    -o-transition: 0.3s all ease;
    -webkit-transition: 0.3s all ease;
    transition: 0.3s all ease;}

input[type="email"], input[type="password"]{border: 1px solid #ccc; height: 35px; padding: 0 10px; width: 240px; position: relative; 
	-moz-box-shadow: inset 0 0 10px rgba(0,0,0,.06);
	-webkit-box-shadow: inset 0 0 10px rgba(0,0,0,.06);
	box-shadow: inset 0 0 10px rgba(0,0,0,.06);
	z-index: 2;}

input[type="email"]{color: rgba(47,130,194,.8);}
input[type="password"]{color: rgba(237,28,112,.8);}

/* Placeholder */
input[type="email"]:-moz-placeholder{color: rgba(47,130,194,.6);}
input[type="email"]:-ms-input-placeholder{color: rgba(47,130,194,.6);}
input[type="email"]::-webkit-input-placeholder{color: rgba(47,130,194,.6);}

input[type="password"]:-moz-placeholder{color: rgba(237,28,112,.6);}
input[type="password"]:-ms-input-placeholder{color: rgba(237,28,112,.6);}
input[type="password"]::-webkit-input-placeholder{color: rgba(237,28,112,.6);}

/* Label */
input[type="email"] + label{color: rgb(47,130,194);}
input[type="password"] + label{color: rgb(237,28,112);}

input:focus + label{right: 10px;}

input[type="email"]:focus, input[type="password"]:focus{background-color: rgba(255,255,255,.8);}

/* Submit */
input[type="submit"]{
	background-color: #333;
	background: -moz-linear-gradient(bottom, #333, #444);
	background: -ms-linear-gradient(bottom, #333, #444);
	background: -o-linear-gradient(bottom, #333, #444);
	background: -webkit-linear-gradient(bottom, #333, #444);
	background: linear-gradient(bottom, #333, #444);
	border: 1px solid #222; color: #fff; cursor: pointer; height: 35px; width: 110px;
}

input[type="submit"]:hover{color: #ff6937;text-shadow: 0 0 1px rgba(255,255,255,.2);}</code></pre>
<p>The <abbr title="Cascading Style Sheets">CSS</abbr> mostly consists of general styling, I&#8217;d say the most important two lines are:</p>
<pre><code class="language-css">input:focus + label{right: 10px;}
input[type="email"]:focus, input[type="password"]:focus{background-color: rgba(255,255,255,.8);}</code></pre>
<p>So the label is absolutely placed behind the input field. On focus the label moves to the right while the input&#8217;s background fades to a lower opacity. This gives the illusion of the label sliding right while fading in.</p>
<p>That&#8217;s pretty much all there is to it. I think it&#8217;s a neat little trick.</p>
<h2>Let&#8217;s give IE a bit of love</h2>
<p>As always, IE spoils the party, but as always <a href="http://www.modernizr.com/">Modernizr</a> is here to save the day. We can get the form to act almost identically (sans animations) on IE8 and functionally on IE 6 and 7. Firstly, make sure you&#8217;ve given either the &lt;html&gt; or the &lt;body&gt; tag IE specific styles. For example:</p>
<pre><code class="language-html">&lt;!doctype html&gt;
&lt;!--[if lt IE 7 ]&gt; &lt;html class="no-js ie6 ie" lang="en"&gt; &lt;![endif]--&gt;
&lt;!--[if IE 7 ]&gt;    &lt;html class="no-js ie7 ie" lang="en"&gt; &lt;![endif]--&gt;
&lt;!--[if IE 8 ]&gt;    &lt;html class="no-js ie8 ie" lang="en"&gt; &lt;![endif]--&gt;
&lt;!--[if (gte IE 9)|!(IE)]&gt;&lt;!--&gt; &lt;html class="no-js" lang="en"&gt; &lt;!--&lt;![endif]--&gt;
&lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;script src="../../../js/libs/modernizr-2.0.6-min.js"&gt;&lt;/script&gt;</code></pre>
<p>Also, notice I&#8217;ve included Modernizr. I make use of Modernizr on pretty much every project I work on. It allows me to feature detect with javascript and I can make some pretty cool fallbacks with that.</p>
<p>Once we&#8217;ve got that set up we can easily start fixing up IE.</p>
<h3>IE specific CSS</h3>
<pre><code class="language-css">.ie input{line-height: 35px;}
.ie input[type="email"]{color: #2F82C2;}
.ie input[type="password"]{color: #ED1C70;}
.ie label{right: 10px;}

.ie input[type="email"]:focus, .ie input[type="password"]:focus{
    background:transparent;
    -ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#80ffffff,endColorstr=#80ffffff)";
    zoom: 1;
}
.ie7 label, .ie6 label{display: none;}</code></pre>
<p>The <abbr title="Cascading Style Sheets">CSS</abbr> just makes things work in IE. Nothing special really. The weird -ms-filter is to add opacity to the background in IE.</p>
<h3>Placeholder functionality fallback &#8211; jQuery with Modernizr</h3>
<pre><code class="language-javascript">if(!Modernizr.input.placeholder) {
    $("input[placeholder]").each(function() {
        var placeholder = $(this).attr("placeholder");

        $(this).val(placeholder).focus(function() {
            if($(this).val() == placeholder) {
                $(this).val("")
            }
        }).blur(function() {
            if($(this).val() == "") {
                $(this).val(placeholder)
            }
        });
    });
}</code></pre>
<p>This little snippet does the following:</p>
<ol>
<li>Detects for the placeholder attribute support. If no support is found, it continues</li>
<li>It then looks for all input elements with the placeholder attribute</li>
<li>It then takes the placeholder value and puts that within the &#8216;value&#8217; attribute</li>
<li>When focus is given to the element the value is set to none</li>
<li>When blurred, if the value attribute isn&#8217;t nothing, it leaves the text alone</li>
<li>If the value attribute is nothing, it replaces it with the placeholder text again</li>
</ol>
<h2>Foreseeable problems</h2>
<blockquote><p>The user can&#8217;t see the text if the input is full of characters.</p></blockquote>
<p>True story, but the opacity of the label is so low that it doesn&#8217;t really interfere with the readability of the text itself. A way around this would be to add padding-right which covers the length of the label. The only downside to this would be the input field having to be very long.</p>
<p>In general I think this is fine, but if you&#8217;re very worried about this, I&#8217;d say add <code>padding-right</code> to the label and use icons instead of text. This will save a lot of space.</p>
<h2>Conclusion</h2>
<p>I think it&#8217;s a pretty solid technique that will leave your website visitors &mdash; or me at least &mdash; happier and less confused while logging in.</p>
]]></content:encoded>
			<wfw:commentRss>http://css-plus.com/2011/09/make-the-input-placeholder-user-friendly/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
	</channel>
</rss>
