<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>CSS-Tricks</title>
	
	<link>http://css-tricks.com</link>
	<description>Tips, Tricks, and Techniques on using Cascading Style Sheets.</description>
	<lastBuildDate>Tue, 21 May 2013 14:04:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CssTricks" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="csstricks" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">CssTricks</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Prepros</title>
		<link>http://alphapixels.com/prepros/</link>
		<comments>http://css-tricks.com/prepros/#comments</comments>
		<pubDate>Mon, 20 May 2013 14:14:03 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Link]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21695</guid>
		<description><![CDATA[<p><p>Is an open-source app modeled after <a href="http://incident57.com/codekit/">CodeKit</a>. Prepros runs on Windows where CodeKit is Mac only. From people who have <a href="http://shoogledesigns.com/blog/blog/2013/05/18/codekit-for-windows-prepros/">tried it</a>, it seems good.</p>
<p><a href="http://alphapixels.com/prepros/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/prepros/">Permalink</a>&#8230;</p></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/prepros/">Prepros</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>Is an open-source app modeled after <a href="http://incident57.com/codekit/">CodeKit</a>. Prepros runs on Windows where CodeKit is Mac only. From people who have <a href="http://shoogledesigns.com/blog/blog/2013/05/18/codekit-for-windows-prepros/">tried it</a>, it seems good.</p>
<p><a href="http://alphapixels.com/prepros/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/prepros/">Permalink</a></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/prepros/">Prepros</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></content:encoded>
			<wfw:commentRss>http://css-tricks.com/prepros/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chrome’s requestAutocomplete()</title>
		<link>http://blog.alexmaccaw.com/requestautocomplete</link>
		<comments>http://css-tricks.com/chromes-requestautocomplete/#comments</comments>
		<pubDate>Mon, 20 May 2013 14:09:55 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Link]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21693</guid>
		<description><![CDATA[<p><p>Auto-filling forms is nice because it saves time and is less prone to user error. Even better is not even needing to see a form in the first place.</p>
<p><a href="http://blog.alexmaccaw.com/requestautocomplete" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/chromes-requestautocomplete/">Permalink</a>&#8230;</p></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/chromes-requestautocomplete/">Chrome’s requestAutocomplete()</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>Auto-filling forms is nice because it saves time and is less prone to user error. Even better is not even needing to see a form in the first place.</p>
<p><a href="http://blog.alexmaccaw.com/requestautocomplete" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/chromes-requestautocomplete/">Permalink</a></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/chromes-requestautocomplete/">Chrome’s requestAutocomplete()</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></content:encoded>
			<wfw:commentRss>http://css-tricks.com/chromes-requestautocomplete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replace the Image in an &lt;img&gt; with CSS</title>
		<link>http://css-tricks.com/replace-the-image-in-an-img-with-css/</link>
		<comments>http://css-tricks.com/replace-the-image-in-an-img-with-css/#comments</comments>
		<pubDate>Mon, 20 May 2013 12:43:13 +0000</pubDate>
		<dc:creator>Guest Author</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21673</guid>
		<description><![CDATA[<p><p><em class="explanation">The following is a guest post by <a href="https://twitter.com/marcelshields">Marcel Shields</a>. Marcel in a difficult place where he needed to change the image on a page but didn't have access to the HTML. Rare, but I'm sure we've all be in weird situations like this. He explains how he managed to replace that image without needing to access the HTML or JavaScript. Also turns out to be a pretty good way to replace <strong>anything</strong> with an image.</em></p>
<p></p>
<p>I just wanted to &#8230;</p></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/replace-the-image-in-an-img-with-css/">Replace the Image in an &lt;img> with CSS</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p><em class="explanation">The following is a guest post by <a href="https://twitter.com/marcelshields">Marcel Shields</a>. Marcel in a difficult place where he needed to change the image on a page but didn't have access to the HTML. Rare, but I'm sure we've all be in weird situations like this. He explains how he managed to replace that image without needing to access the HTML or JavaScript. Also turns out to be a pretty good way to replace <strong>anything</strong> with an image.</em></p>
<p><span id="more-21673"></span></p>
<p>I just wanted to share something I found really cool about using CSS <a href="http://css-tricks.com/almanac/properties/b/box-sizing/">box-sizing</a>. Chris wrote a <a href="http://css-tricks.com/box-sizing/">really good introduction</a> a few years back if you're not familiar with the property. It makes things a lot more sane when thinking about layout. People love it so much, they <a href="http://paulirish.com/2012/box-sizing-border-box-ftw/">put it on everything</a> like hot sauce. I wanted to share how I found it useful as (yet) another image replacement technique.</p>
<p>A few days ago at work, I was asked to replace an <code>&lt;img&gt;</code> on our site with another image hosted elsewhere. Simple right? But the catch was I would not be able to replace the markup as it was already deployed to production, but could inject CSS or JS through our CMS. For whichever technology I chose, it would be inserted on all site pages. I only needed on one specific page, and the attributes of parent containers were non-specific to the desired page.</p>
<pre rel="HTML"><code class="language-markup">&lt;head&gt;
  &lt;title&gt;Really Cool Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;!-- .header would be across site on other pages with different children, so no background image adding --&gt;
  &lt;div class="header"&gt;
    &lt;img class="banner" src="http://notrealdomain1.com/banner.png"&gt;
  &lt;/div&gt;
&lt;/body&gt;</code></pre>
<p>This is simple to do with JavaScript, but I wanted to see if there was another, even simpler, way. After a few iterations in Chrome Dev Tools, I thought to use the <code>box-sizing</code> property to keep dimensions strict, add the new image as a background image, and just push the inline image out of the way with padding and see what happened.</p>
<pre rel="CSS"><code class="language-css">/* All in one selector */
.banner {
  display: block;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  background: url(http://notrealdomain2.com/newbanner.png) no-repeat;
  width: 180px; /* Width of new image */
  height: 236px; /* Height of new image */
  padding-left: 180px; /* Equal to width of new image */
}</code></pre>
<p>It worked beautifully. Here's what's cool:</p>
<ul>
<li>It works on just about any element, even empty ones like <code>&lt;img&gt;</code> or <code>&lt;hr&gt;</code></li>
<li>Browser support is excellent (Chrome, Firefox, Opera, Safari, IE8+) <a href="http://caniuse.com/#feat=css3-boxsizing">http://caniuse.com/#feat=css3-boxsizing</a></li>
<li>Refrains from using SEO unfriendly <code>display: none</code> or other properties</li>
</ul>
<p>That last point seemed important, as it works really well for text replacement too without any adjustment. Check it out!</p>
<pre class="codepen" data-height="300" data-type="result" data-href="cJEjs" data-user="chriscoyier" data-safe="true"><code></code><a href="http://codepen.io/chriscoyier/pen/cJEjs">Check out this Pen!</a></pre>
<p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/replace-the-image-in-an-img-with-css/">Replace the Image in an &lt;img> with CSS</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></content:encoded>
			<wfw:commentRss>http://css-tricks.com/replace-the-image-in-an-img-with-css/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Slider with Sliding Backgrounds</title>
		<link>http://css-tricks.com/slider-with-sliding-backgrounds/</link>
		<comments>http://css-tricks.com/slider-with-sliding-backgrounds/#comments</comments>
		<pubDate>Fri, 17 May 2013 15:14:52 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21656</guid>
		<description><![CDATA[<p><p>Among the many super nice design features of the <a href="https://itunes.apple.com/us/app/yahoo!-weather/id628677149?mt=8">Yahoo! Weather app for iOS</a> is the transition between city screens. The background image doesn't just move away as the screen moves from one screen to the next, the background image itself slides. It appears to be hiding some of the "old" screen and revealing more of the "new" screen those closer you have it to being in full view. </p>
<p>Let's try and pull it off on the web.</p>
<p>&#8230;</p>
The HTML</p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/slider-with-sliding-backgrounds/">Slider with Sliding Backgrounds</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>Among the many super nice design features of the <a href="https://itunes.apple.com/us/app/yahoo!-weather/id628677149?mt=8">Yahoo! Weather app for iOS</a> is the transition between city screens. The background image doesn't just move away as the screen moves from one screen to the next, the background image itself slides. It appears to be hiding some of the "old" screen and revealing more of the "new" screen those closer you have it to being in full view. </p>
<p>Let's try and pull it off on the web.</p>
<p><span id="more-21656"></span></p>
<h3>The HTML</h3>
<p>Like any slider, there are three main components:</p>
<ul>
<li>The container that holds everything into shape</li>
<li>A sliding container that is as wide as all the slides in a row</li>
<li>Each individual side container</li>
</ul>
<p>We won't bother too much with content inside the slide. I'll just add the temperature to show each slide can indeed hold content on top.</p>
<pre rel="HTML"><code class="language-markup">&lt;div class="slider" id="slider"&gt;
  &lt;div class="holder"&gt;
    &lt;div class="slide" id="slide-0"&gt;&lt;span class="temp"&gt;74°&lt;/span&gt;&lt;/div&gt;
    &lt;div class="slide" id="slide-1"&gt;&lt;span class="temp"&gt;64°&lt;/span&gt;&lt;/div&gt;
    &lt;div class="slide" id="slide-2"&gt;&lt;span class="temp"&gt;82°&lt;/span&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre>
<p>The container might be a <code>&lt;section&gt;</code>, slides might be <code>&lt;article&gt;</code>. It really depends. I'll let you make the semantic choices for your own needs.</p>
<p>The layout plan is like this:</p>
<figure id='post-21657 media-21657' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/05/layout.png' alt='' /></figure>
<h3>The CSS</h3>
<p>The "slider" (visual container) and the slides need to have explicity the same size. We'll use pixels here but you could make it work with anything.</p>
<pre rel="CSS"><code class="language-css">.slider {
  width: 300px;
  height: 500px;
  overflow-x: scroll;
}
.slide {
  float: left;
  width: 300px;
  height: 500px;
}</code></pre>
<p>Floating those slides to the left isn't going to make them line up in a row, because the parent element of the slides isn't wide enough to let them do that. That's one of the reasons we need the holder element. It will be 300% wide (Num. of slides × 100%) which will fit three slides exactly.</p>
<pre rel="CSS"><code class="language-css">.holder {
  width: 300%;
}</code></pre>
<p>Each one of our slides has a unique ID. This is useful because, if we choose, we can create anchor links that link to those ID's and the slider will "jump" to those slides. We'll add JavaScript to do some actual "sliding", but our slider will work even without that. ID's make that possible, so let's use them here to drop in some lovely background images.</p>
<pre rel="CSS"><code class="language-css">#slide-0 {
  background-image: url(http://farm8.staticflickr.com/7347/8731666710_34d07e709e_z.jpg);
}
#slide-1 {
  background-image: url(http://farm8.staticflickr.com/7384/8730654121_05bca33388_z.jpg);
}
#slide-2 {
  background-image: url(http://farm8.staticflickr.com/7382/8732044638_9337082fc6_z.jpg);
}</code></pre>
<p>With all this in place, our layout comes into shape:</p>
<figure id='post-21658 media-21658' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/05/css-layout.jpg' alt='' /></figure>
<p>The CSS (black fading)</p>
<p>Just as a small detail, the temperature set in white may be in danger of not being visible depending on the photo behind it. To ensure that it is, we can make the photo subtly fade to black toward the bottom. A pseudo element will do nicely.</p>
<pre rel="CSS"><code class="language-css">.slide:before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40%;
  background: linear-gradient(transparent, black);
}</code></pre>
<p>A picture explanation is in order here:</p>
<figure id='post-21663 media-21663' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/05/white-text.jpg' alt='' /></figure>
<h3>The JavaScript (background sliding)</h3>
<p>We're going to use jQuery here because we love life. Our goal is the adjust the background-position of the slides as we scroll. We can set background-position in percentages in CSS, but that alone doesn't do the cool hide/reveal more effect we're looking for. Based the amount scrolled (which we can measure in JavaScript), we'll adjust the background-position. Alone, that would look something like this:</p>
<pre rel="jQuery"><code class="language-javascript">$("#slider").on("scroll", function() {
  $(".slides").css({
    "background-position": $(this).scrollLeft()/6-100+ "px 0"
  });  
});</code></pre>
<p>The "6" and "-100" in there are magic numbers. Not <a href="http://css-tricks.com/magic-numbers-in-css/">CSS magic numbers</a> that are prone to frailty, but traditional magic numbers. Just some numbers that happen to make the effect work. A bummer, perhaps, but not that big of a deal. Design-y things are sometimes like that. Perhaps best to leave a comment in the code to that effect. These particular numbers are based on the images I used and their size and what looked good.</p>
<p>The effect here is the background shifting we're after:</p>
<figure id='post-21662 media-21662' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/05/slideeffect.jpg' alt='' /></p>
<figcaption>Notice the less of the yellow streetcar is visible when the slide is almost out of view.</figcaption>
</figure>
<h3>The JavaScript (imparting structure)</h3>
<p>That little snippet of JavaScript looks lonely up there without any structure behind it. A slider is a great excuse to look at a simple way to structure JavaScript.</p>
<p>We can make everything slider-related one object.</p>
<pre rel="JavaScript"><code class="language-javascript">var slider = {

};</code></pre>
<p>Then we'll group up the related elements into one area, bind our events together, and write little functions that do very specific things.</p>
<pre rel="jQuery"><code class="language-javascript">var slider = {
  
  el: {
    slider: $("#slider"),
    allSlides: $(".slide")
  },
 
  init: function() {
    // manual scrolling
    this.el.slider.on("scroll", function(event) {
      slider.moveSlidePosition(event);
    });
  },
  
  moveSlidePosition: function(event) {
    // Magic Numbers
    this.el.allSlides.css({
      "background-position": $(event.target).scrollLeft()/6-100+ "px 0"
    });  
  }
  
};

slider.init();</code></pre>
<h3>The HTML (adding navigation)</h3>
<p>Adding swipe stuff would be super (super) sweet (hint). But for now let's add little press-able links to change slides, rather than relying on the scrollbar. You might even remove the scrollbar in real life (straight up overflow: hidden; on the container). What we need is anchor links that link to the ID's of the individual slides.</p>
<pre rel="HTML"><code class="language-markup">&lt;nav class="slider-nav"&gt;
  &lt;a href="#slide-0" class="active"&gt;Slide 0&lt;/a&gt; 
  &lt;a href="#slide-1"&gt;Slide 1&lt;/a&gt; 
  &lt;a href="#slide-2"&gt;Slide 2&lt;/a&gt; 
&lt;/nav&gt;</code></pre>
<p>Style those as you will. For <a href="http://codepen.io/chriscoyier/pen/Fkczq">the demo</a>, I make them little tiny gray circles with the text hidden.</p>
<h3>The JavaScript (adding navigation)</h3>
<p>Our structure is more useful now. We simply add a few more elements we're dealing with, add a new event we're watching for (clicks on nav), and write a little function to deal with that event.</p>
<p>We know how far to animate the scroll position when a nav link is clicked from the ID on the link itself. The link might be href="#slide-1", which we can get "1" from easily. Then the position we need to scroll to is (1 × width of slide), so 300 in our case. We'll store that 300 value right in the JavaScript.</p>
<pre rel="jQuery"><code class="language-javascript">var slider = {
  
  el: {
    slider: $("#slider"),
    allSlides: $(".slide"),
    sliderNav: $(".slider-nav"),
    allNavButtons: $(".slider-nav &gt; a")
  },
  
  timing: 800,
  slideWidth: 300, // could measure this
  
  init: function() {
    // You can either manually scroll...
    this.el.slider.on("scroll", function(event) {
      slider.moveSlidePosition(event);
    });
    // ... or click a thing
    this.el.sliderNav.on("click", "a", function(event) {
      slider.handleNavClick(event, this);
    });
  },
  
  moveSlidePosition: function(event) {
    // Magic Numbers
    this.el.allSlides.css({
      "background-position": $(event.target).scrollLeft()/6-100+ "px 0"
    });  
  },
  
  handleNavClick: function(event, el) {
    // Don't change URL to a hash, remove if you want that
    event.preventDefault();

    // Get "1" from "#slide-1", for example
    var position = $(el).attr("href").split("-").pop();
    
    this.el.slider.animate({
      scrollLeft: position * this.slideWidth
    }, this.timing);
    
    this.changeActiveNav(el);
  },
  
  changeActiveNav: function(el) {
    // Remove active from all links
    this.el.allNavButtons.removeClass("active");
    // Add back to the one that was pressed
    $(el).addClass("active");
  }
  
};

slider.init();</code></pre>
<p>We have an "active" class on the nav links just to use in CSS to visually indicate which slide is active. We handle that by removing "active" from all links and then adding it back to the one that was clicked.</p>
<h3>Demo!</h3>
<pre class="codepen" data-height="630" data-type="result" data-href="Fkczq" data-user="chriscoyier" data-safe="true"><code></code><a href="http://codepen.io/chriscoyier/pen/Fkczq">Check out this Pen!</a></pre>
<p><script async src="http://codepen.io/assets/embed/ei.js"></script></p>
<p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/slider-with-sliding-backgrounds/">Slider with Sliding Backgrounds</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></content:encoded>
			<wfw:commentRss>http://css-tricks.com/slider-with-sliding-backgrounds/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>Photo Swivel</title>
		<link>http://css-tricks.com/photo-swivel/</link>
		<comments>http://css-tricks.com/photo-swivel/#comments</comments>
		<pubDate>Wed, 15 May 2013 12:06:33 +0000</pubDate>
		<dc:creator>Guest Author</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21627</guid>
		<description><![CDATA[<p><p><em class="explanation">The following is a guest post by <a href="http://www.alexandery.net/">Alex Young</a> (<a href="http://twitter.com/the_alexyoung">@the_alexyoung</a>). Alex has created a simple technique to "rotate" the subject of a photo simply by hiding and showing multiple stacked photographs taken at different angles. Enjoy!</em></p>
<p></p>
<p>Web designers and developers have always fascinated us with fun and engaging ways we interact with their websites. I love discovering new techniques that these designers/developers have come up with. One technique in particular that sparked my interest is something that I &#8230;</p></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/photo-swivel/">Photo Swivel</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p><em class="explanation">The following is a guest post by <a href="http://www.alexandery.net/">Alex Young</a> (<a href="http://twitter.com/the_alexyoung">@the_alexyoung</a>). Alex has created a simple technique to "rotate" the subject of a photo simply by hiding and showing multiple stacked photographs taken at different angles. Enjoy!</em></p>
<p><span id="more-21627"></span></p>
<p>Web designers and developers have always fascinated us with fun and engaging ways we interact with their websites. I love discovering new techniques that these designers/developers have come up with. One technique in particular that sparked my interest is something that I saw on <a href="http://www.warbyparker.com/">Warby Parker’s website</a>. They were able to create a cool effect where model follows the user’s mouse, showing off the different angles of the frames. </p>
<p>I’ve seen this technique mainly used for showing off sunglasses, but I’m interested to see what you guys can come up with for other real-world applications.</p>
<p>Before we begin, you will need a few things. Well, seven things to be exact. You are going to need seven photos of something taken at seven different angles. </p>
<h3>HTML Setup</h3>
<p>What we are setting up is a container called “faces”, then have created an area that we are going to use to display the photos – “face-area”.  We also have a <code>div</code> to hold each of the seven individual images. </p>
<pre rel="HTML"><code class="language-markup">&lt;div id="faces"&gt;

  &lt;div id="face-area"&gt;

    &lt;div id="image-1" style="display: none;"&gt;
      &lt;img src="http://cdn.css-tricks.com/images/look-left-3.jpg"&gt;
    &lt;/div&gt;

    &lt;div id="image-2" style="display: none;"&gt;
      &lt;img src="http://cdn.css-tricks.com/images/look-left-2.jpg"&gt;
    &lt;/div&gt;

    &lt;div id="image-3" style="display: none;"&gt;
      &lt;img src="http://cdn.css-tricks.com/images/look-left-1.jpg"&gt;
    &lt;/div&gt;

    &lt;div id="image-4" style="display: none;"&gt;
      &lt;img src="http://cdn.css-tricks.com/images/look-center.jpg"&gt;
    &lt;/div&gt;

    &lt;div id="image-5" style="display: none;"&gt;
      &lt;img src="http://cdn.css-tricks.com/images/look-right-1.jpg"&gt;
    &lt;/div&gt;

    &lt;div id="image-6" style="display: none;"&gt;
      &lt;img src="http://cdn.css-tricks.com/images/look-right-2.jpg"&gt;
    &lt;/div&gt;

    &lt;div id="image-7" style="display: none;"&gt;
      &lt;img src="http://cdn.css-tricks.com/images/look-right-3.jpg"&gt;
    &lt;/div&gt;</code></pre>
<p>Now we'll create a <code>div</code> that is going to do exactly what the name implies. It is going to lay on top of the other <code>div</code>. We can divide this <code>div</code> into 7 small columns and divide them equally across it. These 7 columns will be used to listen for when the mouse is hovering over that specific one. Adding “data-number” to each <code>div</code> will allow us to refer to each in jQuery later on.</p>
<pre rel="HTML"><code class="language-markup">    &lt;div id="the_faces_overlay"&gt;
      &lt;div class="the_faces" data-number="1"&gt;&lt;/div&gt;
      &lt;div class="the_faces" data-number="2"&gt; &lt;/div&gt;
      &lt;div class="the_faces" data-number="3"&gt;&lt;/div&gt;
      &lt;div class="the_faces" data-number="4"&gt;&lt;/div&gt;
      &lt;div class="the_faces" data-number="5"&gt;&lt;/div&gt;
      &lt;div class="the_faces" data-number="6"&gt;&lt;/div&gt;
      &lt;div class="the_faces" data-number="7"&gt;&lt;/div&gt;
    &lt;/div&gt; 

  &lt;/div&gt;&lt;!-- END #face-area --&gt;

&lt;/div&gt; &lt;!-- END #faces --&gt; </code></pre>
<h3>CSS Setup</h3>
<p>Most of the CSS is pretty self-explanatory. There is one thing I need to mention that is important, make sure that the 7 columns fit perfectly together across the <code>span</code> of the <code>div</code>.</p>
<pre rel="CSS"><code class="language-css">body {
  background: #333 
}

#faces {
  height: 333px;
  width: 500px;
  margin: 0 auto;
  border: 8px solid white;
}

#face-area {
  height: 500px;
  width: 333px;
  position: relative;
}

#the_faces_overlay {
  position: absolute;
  width: 500px;
  top: 0;
  left: 0;
}

#faces .the_faces {
  height: 333px;
  width: 14.2857143%;
  float: left;
  margin: 0;
  padding: 0;
}</code></pre>
<h3>jQuery Setup</h3>
<p>We need to listen for when each of the columns are hovered over. This is where those “data-numbers” come in handy. If we wanted to add more columns down the road we wouldn't have to add any more JavaScript.</p>
<pre rel="jQuery"><code class="language-javascript">// Reveal the "center" image
var centerImage = $("#image-4").show();

// Bind hovers to each column
$(".the_faces").each(function() {

  $(this).on("mouseover", function() {
  
    $("#image-" + $(this).attr("data-number")).show();
  
  }).on("mouseout",function() {
  
    $("#image-" + $(this).attr("data-number")).hide();

  });
  
});

// Reset center image
$("#face-area").on("mouseleave", function() {
  centerImage.show();
}).on("mouseenter", function() {
  centerImage.hide();
});</code></pre>
<h3>Tada!</h3>
<pre class="codepen" data-height="600" data-type="result" data-href="IJGxk" data-user="AlexanderY" data-safe="false"><code></code><a href="http://codepen.io/AlexanderY/pen/IJGxk">Check out this Pen!</a></pre>
<p>There you have it! Now you have your very own, head turning model. Use it to show off your very own products. There are tons of uses for this out there. Let me know what you come up with.</p>
<p><strong>Editor's note:</strong> this would be a fun demo to work on adding touch support, wouldn't it? Follows a swipe or something.</p>
<p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/photo-swivel/">Photo Swivel</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></content:encoded>
			<wfw:commentRss>http://css-tricks.com/photo-swivel/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Media Query Change Detection in JavaScript Through CSS Animations</title>
		<link>http://css-tricks.com/media-query-change-detection-in-javascript-through-css-animations/</link>
		<comments>http://css-tricks.com/media-query-change-detection-in-javascript-through-css-animations/#comments</comments>
		<pubDate>Tue, 14 May 2013 12:55:36 +0000</pubDate>
		<dc:creator>Guest Author</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21614</guid>
		<description><![CDATA[<p><p><em class="explanation">The following is a guest post by <a href="http://avedesign.me/">Alessandro Vendruscolo</a>. Media queries are relevant to both CSS and JS. The need and desire to manage those in one place is real. There have been some clever ways to do this, like Jeremy Keith's <a href="http://adactio.com/journal/5429/">Conditional CSS</a>. But in that case, the onus is on you to test after window state changes. You can get a true listener with MediaQueryList, but then you're maintaining the media queries in both places again. </em>&#8230;</p></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/media-query-change-detection-in-javascript-through-css-animations/">Media Query Change Detection in JavaScript Through CSS Animations</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p><em class="explanation">The following is a guest post by <a href="http://avedesign.me/">Alessandro Vendruscolo</a>. Media queries are relevant to both CSS and JS. The need and desire to manage those in one place is real. There have been some clever ways to do this, like Jeremy Keith's <a href="http://adactio.com/journal/5429/">Conditional CSS</a>. But in that case, the onus is on you to test after window state changes. You can get a true listener with MediaQueryList, but then you're maintaining the media queries in both places again. Ah well, I'll let Alessandro explain.</em></p>
<p><span id="more-21614"></span></p>
<p>Media queries were first introduced more than <a href="http://www.w3.org/TR/2001/WD-css3-mediaqueries-20010404/">twelve years ago</a> (yes, the first draft dates back to 4 April 2001!) and were introduced to <em>limit the scope of a style sheet</em>:</p>
<blockquote><p>A media query consists of a media type and one or more expressions to limit the scope of a certain style sheet. […] By using media queries, content presentations can be tailored to a range of devices without changing the content itself.</p></blockquote>
<p>With media queries in CSS we can selectively use styles depending on, for example, the width of browser screen:</p>
<pre rel="CSS"><code class="language-css">@media screen and (min-width: 960px) {
  body {
    padding: 50px;
  }
}</code></pre>
<p>In the example above, if your browser screen is wider than or equal to 960px, the body will have 50px of <a href="http://css-tricks.com/almanac/properties/p/padding/">padding</a>.</p>
<h3>DOM events triggered from CSS animations</h3>
<p>A simple click event:</p>
<pre rel="JavaScript"><code class="language-javascript">document.querySelector('a.button').addEventListener('click', function(event) {
  // do something
});</code></pre>
<p></code></p>
<p>Nothing fancy here, just standard DOM programming. The <code>click</code> event, among many other events, are generated when the user interacts with the page: clicks, moves the cursor, scrolls the page and so on.</p>
<p>All of these events are related to the DOM, and generates as a consequence of user&#39;s interactions. There are also some events which are specifically related to CSS <a href="http://css-tricks.com/almanac/properties/a/animation/">animations</a>: <code>animationStart</code>, <code>animationEnd</code> (and their <a href="http://css-tricks.com/almanac/properties/t/transition/">transition</a> cousins, <code>transitionStart</code>, <code>transitionEnd</code>).</p>
<p>If we insert a new element onto the page and it has an animation, we know that CSS animation will start as soon as it is inserted. So if we watch for the animationstart event of that animation, we can know when it was inserted.</p>
<pre rel="CSS"><code class="language-css">@keyframes nodeInserted {
  from { clip: rect(1px, auto, auto, auto); }
  to { clip: rect(0px, auto, auto, auto); }
}
.an-element {
  animation-duration: 0.001s;
  animation-name: nodeInserted;
}</code></pre>
<pre rel="JavaScript"><code class="language-javascript">document.addEventListener("animationstart", function (event) {
  if (event.animationName == "nodeInserted") {
    // an element with class an-element has been inserted in the DOM
  }
}, false);</code></pre>
<p>Thanks to <a href="http://davidwalsh.name/detect-node-insertion">David Walsh</a>, <a href="http://www.backalleycoder.com/2012/04/25/i-want-a-damnodeinserted/">Daniel Buchner</a>, and <a href="http://blog.streak.com/2012/11/how-to-detect-dom-changes-in-css.html">Omar Ismail</a> for blogging about this around a year ago.</p>
<h3>Putting together media queries and animations</h3>
<p>Perhaps you can see where this is going. If we trigger the animation when a media query changes (rather than on node insertion), we can also detect when that media query change happened in our JavaScript.</p>
<pre rel="CSS"><code class="language-css">body {
  animation-duration: 0.001s;
}
@media screen and (min-width: 1000px) {
  body {
    animation-name: min-width-1000px;
  }
}
@media screen and (min-width: 700px) {
  body {
    animation-name: min-width-700px;
  }
}

@keyframes min-width-700px {
  from { clip: rect(1px, auto, auto, auto); }
  to { clip: rect(0px, auto, auto, auto); }
}

@keyframes min-width-1000px {
  from { clip: rect(1px, auto, auto, auto); }
  to { clip: rect(0px, auto, auto, auto); }
}</code></pre>
<pre rel="JavaScript"><code class="language-javascript">document.addEventListener(animationEnd, dispatchEvent, false);

// check the animation name and operate accordingly
function dispatchEvent(event) {
  if (event.animationName === 'min-width-700px') {
    document.body.innerHTML = 'Min width is 700px';
  } else if (event.animationName === 'min-width-1000px') {
    document.body.innerHTML = 'Min width is 1000px';
  }
}</code></pre>
<p>Editor's note: <a href="http://css-tricks.com/naming-media-queries/">choose your names wisely.</a></p>
<p><a href="http://codepen.io/vendruscolo/pen/Dpijq">Demo on CodePen:</a></p>
<pre class="codepen" data-height="150" data-type="result" data-href="Dpijq" data-user="vendruscolo" data-safe="false"></pre>
<p>We have the same simple animation that doesn&#39;t actually do anything, but this time, the animation is inside an <code>@media</code> block.</p>
<p>If the window becomes wider than 700px, the <code>min-width-700px</code> animation will trigger, and our <code>dispatchEvent</code> will get this information. Think of it like a callback. We can then adapt our page by showing new widgets, destroying others, or whatever else you need to do to adapt to the new screen size.</p>
<p>The cool thing is that we don&#39;t need to use the window resize event, which can be slow and fire too many times (throttling is normally needed). The <code>animationstart</code> event will trigger as soon as the Media query matches, even if we didn&#39;t resize the window. If we then resize the window, the event will fire just when the media query matches.</p>
<h3>The right way to do these things</h3>
<p>Now we've talked about how to get JavaScript callbacks of window width changes, without relying the <code>resize</code> event.</p>
<p>But I wouldn&#39;t suggest you to put this in production code. It works, but the right way to do this should be to use the <a href="https://developer.mozilla.org/en-US/docs/DOM/window.matchMedia"><code>matchMedia</code> method</a>, which returns a <code>MediaQueryList</code>. <code>MediaQueryList</code> objects can have listeners, and thus we can use the <code>addListener</code> method to get notified when a Media query matches or not.</p>
<p><a href="http://wicky.nillia.ms/enquire.js/">Enquire.js</a> has recently reached version 2, and wraps the <code>matchMedia</code> method, which gives us a clean and robust wrapper.</p>
<p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/media-query-change-detection-in-javascript-through-css-animations/">Media Query Change Detection in JavaScript Through CSS Animations</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></content:encoded>
			<wfw:commentRss>http://css-tricks.com/media-query-change-detection-in-javascript-through-css-animations/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Naming Media Queries</title>
		<link>http://css-tricks.com/naming-media-queries/</link>
		<comments>http://css-tricks.com/naming-media-queries/#comments</comments>
		<pubDate>Fri, 10 May 2013 00:55:47 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21568</guid>
		<description><![CDATA[<p><p>It would be pretty cool if we could do this someday in CSS. The best idea for it that I've come across is to define it in a <code>&#60;meta&#62;</code> tag in the <code>&#60;head&#62;</code>. That way (perhaps) CSS could use it and JS could use it. Like <code>window.matchMedia(nameOfMyMediaQuery)</code> or <code>@media (nameOfMyMediaQuery) { }</code>. But since we can't, Sass has our back. Now the question is, how do we name them?</p>
<p></p>
<p>In Sass, the @mixin would look something like this:&#8230;</p></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/naming-media-queries/">Naming Media Queries</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>It would be pretty cool if we could do this someday in CSS. The best idea for it that I've come across is to define it in a <code>&lt;meta&gt;</code> tag in the <code>&lt;head&gt;</code>. That way (perhaps) CSS could use it and JS could use it. Like <code>window.matchMedia(nameOfMyMediaQuery)</code> or <code>@media (nameOfMyMediaQuery) { }</code>. But since we can't, Sass has our back. Now the question is, how do we name them?</p>
<p><span id="more-21568"></span></p>
<p>In Sass, the @mixin would look something like this:</p>
<pre rel="SCSS"><code class="language-css">@mixin breakpoint($point) {
  @if $point == papa-bear {
    @media (max-width: 1600px) { @content; }
  }
  @else if $point == mama-bear {
    @media (max-width: 1250px) { @content; }
  }
  @else if $point == baby-bear {
    @media (max-width: 650px)  { @content; }
  }
}</code></pre>
<p>And you'd use it like:</p>
<pre rel="SCSS"><code class="language-css">.module {
  width: 25%;
  @include breakpoint(baby-bear) {
    width: 100%;
  }
}</code></pre>
<p>Although in reality I prefer something like "bp" just because it's shorter and you need to type it all the time. Which is why "+" would be so ideal instead of "@include". But I digress. Or you could go <a href="http://codepen.io/imathis/pen/BDzcI">Brandon Mathis style</a>:</p>
<pre rel="SCSS"><code class="language-css">$name1:  320px;
$name2:  500px;
$name3:  600px;
$name4:  992px;

@mixin at-least($device-width) {
  @media screen and (min-width: $device-width) {
    @content 
  }
}

@mixin until($device-width) {
  @media screen and (max-width: $device-width - 1) {
    @content 
  }
}</code></pre>
<p>The names should avoid actual numbers. The point here is to assign a name with abstracted meaning, so the numbers can change but the names stay the same. I'd avoid device names like "iPad" or whatever too, because that just sets up bad expectations and will date itself quickly.</p>
<p>Better are naming schemes that suggest relationships between the names themselves. Where one is obviously bigger or smaller than another. Of course this is assuming width queries, which are certainly the most common. But of course your media queries could be different or more complex, and the naming scheme should represent that.</p>
<p>Here's some ideas:</p>
<p>baby-bear<br />
mama-bear<br />
papa-bear</p>
<p>straw-house<br />
stick-house<br />
brick-house</p>
<p>private<br />
corporal<br />
sergeant<br />
captain<br />
major<br />
lieutenant<br />
colonel<br />
general</p>
<p>alpha<br />
beta<br />
gamma<br />
delta<br />
epsilon</p>
<p>very-small<br />
small<br />
medium<br />
large<br />
very-large</p>
<p>-<br />
--<br />
---<br />
----<br />
------</p>
<p>>-<<br />
[---]<br />
<-----></p>
<p>seed<br />
seedling<br />
sprout<br />
plant</p>
<p>pebble<br />
stone<br />
rock<br />
boulder</p>
<p>pawn<br />
knight<br />
queen<br />
king</p>
<p>bishop<br />
archbishop<br />
cardinal<br />
pope</p>
<p>eddard<br />
catelyn<br />
robb<br />
sansa<br />
arya<br />
bran<br />
rickon</p>
<p>knife<br />
dagger<br />
scimitar<br />
claidmore</p>
<p>A<br />
B<br />
C<br />
D<br />
E</p>
<p>From <a href="http://dribbble.com/shots/1062821-What-do-you-name-your-media-queries#comment-2526418">Vince Speelman</a></p>
<p>lil-bowow<br />
eminem<br />
jay-z<br />
krs-one<br />
rick-ross</p>
<p>From <a href="http://dribbble.com/shots/1062821-What-do-you-name-your-media-queries#comment-2526457">James Nowland</a></p>
<p>matryoshka-doll<br />
the-one-inside-matryoshka-doll<br />
the-one-inside-the-one-inside-matryoshka-doll<br />
the-one-inside-the-one-inside-the-one-inside-matryoshka-doll</p>
<p>From <a href="http://dribbble.com/shots/1062821-What-do-you-name-your-media-queries#comment-2527018">Philip Brown</a></p>
<p>michael<br />
jermaine<br />
jackie<br />
marlon<br />
tito</p>
<p>From <a href="http://dribbble.com/shots/1062821-What-do-you-name-your-media-queries#comment-2532074">Rob Stinogle</a></p>
<p>gandalf-the-gray<br />
gandalf-the-white</p>
<p>From <a href="https://twitter.com/darbybrown/status/332179179909046272">Darby Brown</a></p>
<p>stewie<br />
brian<br />
chris<br />
lois<br />
peter<br />
(I leave out Meg)</p>
<p>Got some other ideas?</p>
<p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/naming-media-queries/">Naming Media Queries</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></content:encoded>
			<wfw:commentRss>http://css-tricks.com/naming-media-queries/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>Line Clampin’</title>
		<link>http://css-tricks.com/line-clampin/</link>
		<comments>http://css-tricks.com/line-clampin/#comments</comments>
		<pubDate>Wed, 08 May 2013 01:48:04 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21560</guid>
		<description><![CDATA[<p><p>You want X lines of text. Anything after that, gracefully cut off. That's "line clamping" and it is a perfectly legit desire. When you can count on text being a certain number of lines, you can create stronger and more reliable grids from the elements that contain that text, as well as achieve some symmetric aesthetic harmony. </p>
<p>There are a couple of ways to get it done, none of them spectacular.</p>
<p></p>
<p>In case that explanation wasn't clean, imagine you have &#8230;</p></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/line-clampin/">Line Clampin&#8217;</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>You want X lines of text. Anything after that, gracefully cut off. That's "line clamping" and it is a perfectly legit desire. When you can count on text being a certain number of lines, you can create stronger and more reliable grids from the elements that contain that text, as well as achieve some symmetric aesthetic harmony. </p>
<p>There are a couple of ways to get it done, none of them spectacular.</p>
<p><span id="more-21560"></span></p>
<p>In case that explanation wasn't clean, imagine you have some HTML like this:</p>
<pre rel="HTML"><code class="language-markup">&lt;div class="module"&gt;
  &lt;p&gt;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.&lt;/p&gt;
&lt;/div&gt;</code></pre>
<p>And you want to limit it to exactly three lines in a container. Like this:</p>
<figure id='post-21561 media-21561' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/05/clamped.png' alt='' /></figure>
<p>In all these examples, let's assume we have a "module".</p>
<pre rel="CSS"><code class="language-css">.module {
  width: 250px;
  overflow: hidden;
}</code></pre>
<h3>Weird WebKit Flexbox Way</h3>
<p>David DeSandro showed us <a href="http://dropshado.ws/post/1015351370/webkit-line-clamp">this little ditty</a> a few years ago. </p>
<pre rel="CSS"><code class="language-css">.line-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;  
}</code></pre>
<p>One one hand, this is awesome and exactly what we need. CSS the perfect place for this. It's a real need and it should be this simple. </p>
<p>On the other hand... it's weird. why does it need to be a flexbox thing (the old version at that)? It doesn't work without that. And it's extremely fragile. Let's say you want the module (or the paragraph) to have some padding. You can't, because the padding will expose extra lines. That's what we get with half-baked non-standardized properties.</p>
<h3>The Fade Out Way</h3>
<p>The root of this technique is just setting the height of the module in a predictable way. Let's say you set the <code>line-height</code> to <code>1.2em</code>. If we want to expose three lines of text, we can just make the height of the container <code>3.6em</code> (1.2em × 3). The hidden overflow will hide the rest. </p>
<p>But it can be a bit awkward to just the text off like that. Ideally we would add ellipsis, but we can't reliably position them. So instead we'll fade out the text achieving the same kind of communication ("there is more...").</p>
<p>To fade out the last line, we make a box (a pseudo element will work great) and overlay a transparent-to-background-color gradient over the top. Making it nearly as wide as the container is best in case the last line is short. Because we know the line-height, we can make the pseudo element box exactly one line tall.</p>
<pre rel="CSS"><code class="language-css">.fade {
  position: relative;
  height: 3.6em; /* exactly three lines */
}
.fade:after {
  content: "";
  text-align: right;
  position: absolute;
  bottom: 0;
  right: 0;
  width: 70%;
  height: 1.2em;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 50%);
}</code></pre>
<h3>The Opera Overflow Way</h3>
<p>Like WebKit, Opera has their own way to handle this. They apply ellipsis on the line you wish to. Of course the clock is ticking for Presto (Opera's rendering engine pre-Blink) so this isn't particularly useful. Perhaps it can still inform a future implementation though.</p>
<pre rel="CSS"><code class="language-css">.last-line {
  height: 3.6em; /* exactly three lines */
  text-overflow: -o-ellipsis-lastline;
}</code></pre>
<h3>The Clamp.js Way</h3>
<p>Where there is a will there is a way (with JavaScript). I think that's a saying. Joseph J. Schmitt has an excellent library-free JavaScript thingy called <a href="http://github.com/josephschmitt/Clamp.js">Clamp.js</a> for making this happen in a cross-browser way.</p>
<pre rel="JavaScript"><code class="language-javascript">var module = document.getElementById("clamp-this-module");

$clamp(module, {clamp: 3});</code></pre>
<p>Make sure you target the element with the text directly inside of it. Originally I tried putting the ID on the module, which worked in Chrome/Safari, but failed in Firefox. Putting it on the <code>&lt;p&gt;</code> made it work in both (Thx <a href="http://css-tricks.com/line-clampin/#comment-436850">Merri</a>).</p>
<h3>The Demos</h3>
<pre class="codepen" data-height="660" data-type="result" data-href="iBtep" data-user="chriscoyier" data-safe="true"><code></code><a href="http://codepen.io/chriscoyier/pen/iBtep">Check out this Pen!</a></pre>
<h3>Updates</h3>
<p>Vesa Piittinen created <a href="http://codepen.io/Merri/pen/Dsuim">an alternative method to Clamp.js</a>.</p>
<blockquote><p>Unlike Clamp.js it retains all the text within the clamped element and uses text-overflow to do the magic.</p></blockquote>
<p>FT Labs also <a href="https://github.com/ftlabs/ftellipsis">has created a JavaScript plugin</a> to do the job. It's nice in that you don't have to specify the number of lines, it just happens when the text overflows the container, so the design decision stay in the CSS.</p>
<p>Both of these examples have been added to <a href="http://codepen.io/chriscoyier/pen/iBtep">the main Pen</a>.</p>
<p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/line-clampin/">Line Clampin&#8217;</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></content:encoded>
			<wfw:commentRss>http://css-tricks.com/line-clampin/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>CSS Zen Garden</title>
		<link>http://mezzoblue.com/archives/2013/05/07/10_years/</link>
		<comments>http://css-tricks.com/css-zen-garden/#comments</comments>
		<pubDate>Tue, 07 May 2013 20:32:45 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Link]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21558</guid>
		<description><![CDATA[<p><p>It's back.</p>
<p><a href="http://mezzoblue.com/archives/2013/05/07/10_years/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/css-zen-garden/">Permalink</a>&#8230;</p></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/css-zen-garden/">CSS Zen Garden</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>It's back.</p>
<p><a href="http://mezzoblue.com/archives/2013/05/07/10_years/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/css-zen-garden/">Permalink</a></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/css-zen-garden/">CSS Zen Garden</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></content:encoded>
			<wfw:commentRss>http://css-tricks.com/css-zen-garden/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to mark up subtitles</title>
		<link>http://html5doctor.com/howto-subheadings/</link>
		<comments>http://css-tricks.com/how-to-mark-up-subtitles/#comments</comments>
		<pubDate>Mon, 06 May 2013 15:14:49 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Link]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21542</guid>
		<description><![CDATA[<p><p>Now that <code>&#60;hgroup&#62;</code> is gone, use a <code>&#60;span&#62;</code> inside the main header, or group them with <code>&#60;header&#62;</code> and use a <code>&#60;p&#62;</code> for the subtitle.</p>
<p><a href="http://html5doctor.com/howto-subheadings/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/how-to-mark-up-subtitles/">Permalink</a>&#8230;</p></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/how-to-mark-up-subtitles/">How to mark up subtitles</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>Now that <code>&lt;hgroup&gt;</code> is gone, use a <code>&lt;span&gt;</code> inside the main header, or group them with <code>&lt;header&gt;</code> and use a <code>&lt;p&gt;</code> for the subtitle.</p>
<p><a href="http://html5doctor.com/howto-subheadings/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/how-to-mark-up-subtitles/">Permalink</a></p><p><hr>

<p><a href="http://events.jquery.org/2013/portland/"><img src="http://cdn.css-tricks.com/images/jquery-portland.jpg"></a></p>

<p><a href="http://events.jquery.org/2013/portland/">jQuery Conference Portland 2013</a> has a limited number of regular tickets still available. Two days. Two tracks. Fresh speakers. Jun 13-14. $50 off for members of the jQuery Foundation. <a href="https://jquery.org/join/">Join today</a> and get your first year of fan dues paid for with purchase of both a training and conference ticket. Training provided by Bocoup on Jun 12. Use coupon code <strong>CSSTricks25off</strong> for $25 off.</p>

<hr>

<p><small><a href="http://css-tricks.com/how-to-mark-up-subtitles/">How to mark up subtitles</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></content:encoded>
			<wfw:commentRss>http://css-tricks.com/how-to-mark-up-subtitles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Content Delivery Network via cdn.css-tricks.com

 Served from: css-tricks.com @ 2013-05-21 11:51:35 by W3 Total Cache -->
