<?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>Wed, 19 Jun 2013 02:19:46 +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>New Poll: Light on Dark or Dark on Light?</title>
		<link>http://css-tricks.com/new-poll-light-on-dark-or-dark-on-light/</link>
		<comments>http://css-tricks.com/new-poll-light-on-dark-or-dark-on-light/#comments</comments>
		<pubDate>Tue, 18 Jun 2013 14:59:39 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=22059</guid>
		<description><![CDATA[<p><p>New poll! Just for funzies. Do you prefer...</p>
<p></p>
Light Code on Dark Background
<p>Like this:</p>

<p>or...</p>
Dark Code on Light Background
<p>Like this:</p>

<p>Those are just examples. Doesn't have to be those exact syntax highlighting themes. But I believe all themes fall into those two categories. &#8230;</p></p><p><hr />

<p><small><a href="http://css-tricks.com/new-poll-light-on-dark-or-dark-on-light/">New Poll: Light on Dark or Dark on Light?</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>New poll! Just for funzies. Do you prefer...</p>
<p><span id="more-22059"></span></p>
<h3>Light Code on Dark Background</h3>
<p>Like this:</p>
<figure id='post-22072 media-22072' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/light-on-dark.png' alt='' /></figure>
<p>or...</p>
<h3>Dark Code on Light Background</h3>
<p>Like this:</p>
<figure id='post-22073 media-22073' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/Screen-Shot-2013-06-18-at-9.48.30-AM.png' alt='' /></figure>
<p>Those are just examples. Doesn't have to be those exact syntax highlighting themes. But I believe all themes fall into those two categories. </p>
<p><hr />

<p><small><a href="http://css-tricks.com/new-poll-light-on-dark-or-dark-on-light/">New Poll: Light on Dark or Dark on Light?</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/new-poll-light-on-dark-or-dark-on-light/feed/</wfw:commentRss>
		<slash:comments>121</slash:comments>
		</item>
		<item>
		<title>A Couple of Best Practices for Tablet-Friendly Design</title>
		<link>http://css-tricks.com/a-couple-of-best-practices-for-tablet-friendly-design/</link>
		<comments>http://css-tricks.com/a-couple-of-best-practices-for-tablet-friendly-design/#comments</comments>
		<pubDate>Mon, 17 Jun 2013 12:33:22 +0000</pubDate>
		<dc:creator>Guest Author</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=22028</guid>
		<description><![CDATA[<p>Ben Terrill shares some things you can do to improve the experience for your visitors using tablet devices.</p><p><hr />

<p><small><a href="http://css-tricks.com/a-couple-of-best-practices-for-tablet-friendly-design/">A Couple of Best Practices for Tablet-Friendly Design</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 Ben Terrill. Ben is co-author of the e-book <a href="http://www.mobify.com/go/tablet-web-design/">Tablet Web Design Best Practices</a> and is the VP of Customer Success at <a href="http://www.mobify.com">Mobify</a>, where he works on big client sites like British Telecom, Starbucks and Expedia.</em></p>
<p>The tablet revolution is upon us. New data from Adobe shows that <a href="http://blogs.adobe.com/digitalmarketing/digital-index/tablets-trump-smartphones-in-global-website-traffic/">global websites now get more traffic from tablets than smartphones</a>. And yet, a standard desktop site doesn’t work very well on a tablet. The typical desktop 12-pixel font is too small, as are buttons. Images aren’t sharp and, worst of all, some features simply don’t work.</p>
<p>The good news is you don’t have to completely revamp your website. A working desktop site is a great place to start building an effective tablet site. In this article, I’ll share six techniques from Mobify’s latest ebook <a href="http://www.mobify.com/go/tablet-web-design/">Tablet Web Design Best Practices</a> for significantly improving desktop websites on tablets.</p>
<h3>Go 100% Touch Friendly</h3>
<p>One of the best ways to make your desktop website sing on a tablet is to make it touch friendly. If website elements look as though they can be swiped, tapped or pinched, then you’ll need to build in that functionality to make your website tablet ready.</p>
<p>Consider adding elements like carousels and accordions, drawers and panels. Mobify has a variety of <a href="http://www.mobify.com/mobifyjs/modules/">open source JavaScript modules</a> you can use for this purpose.</p>
<p><strong>Editor's note:</strong> We recently covered the JavaScript for <a href="http://css-tricks.com/the-javascript-behind-touch-friendly-sliders/">touch-friendly sliders</a>. I also think <a href="http://dimsemenov.com/plugins/royal-slider/">Royal Slider</a> is a nice slider that is touch-friendly and also responsive.  </p>
<h3>Bump Up Default Font Size and Line Height</h3>
<p>Don’t make users double tap or pinch your content. Instead, increase the font size to at least 16px. You can also use a line height of 1.5 to allow for breathing room between text on content-rich pages, as <em>Mashable</em> does in the example below. Remember, text must always be legible, no matter how a user holds their tablet.</p>
<figure id='post-22031 media-22031' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/mashable-font-size.png' alt='' /></figure>
<h3>Be Finger Friendly</h3>
<p>Our fingers are much clumsier than a cursor, so bumping up the spacing between different touch targets will improve user accuracy. And, make those touch targets big! Our fingertips typically require <a href="http://uxdesign.smashingmagazine.com/2012/02/21/finger-friendly-design-ideal-mobile-touchscreen-target-sizes/">upwards of 44px to comfortably fit within a touch target</a> so design for that.</p>
<figure>
<img src="http://cdn.css-tricks.com/wp-content/uploads/2013/06/44px-button.png" /></p>
<figcaption>Make each touch target at least 44px by 44px and use padding rather than margin. Padding increases the actual tappable area, whereas margin simply increases the whitespace around the element.</figcaption>
</figure>
<h3>Enable Contextual Keyboards</h3>
<p>The great thing about software keyboards is that they’re dynamic. That is, you can change their layout to suit context. For instance, if your input field requires an email address, the keyboard should feature the ‘@’ symbol, underscores and hyphens. If the user is asked to input a phone number, provide a numeric keypad. Try using the following input types on form fields:</p>
<ul>
<li>Standard keyboard | <code>&lt;input type="text" /&gt;</code></li>
<li>URL parameters | <code>&lt;input type="url" /&gt;</code></li>
<li>Email-specific keyboard | <code>&lt;input type="email" /&gt;</code></li>
<li>Numeric keyboard | <code>&lt;input type="text" pattern="[0-9]*" /&gt;</code></li>
</ul>
<figure id='post-22033 media-22033' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/telephone_ios_android.png' alt='' /></p>
<figcaption>Example of a better numeric keyboard (iOS on left, Android on right) (<a href="http://blog.teamtreehouse.com/using-html5-input-types-to-enhance-the-mobile-browsing-experience">via</a>)</figcaption>
</figure>
<p><strong>Editor's note:</strong> I also detailed data about <a href="http://www.wufoo.com/html5/">HTML5 input attributes/types/elements</a>. It's getting a smidge old, but still useful.</p>
<h3>Font-Based Icons for the Win</h3>
<p>Resolutions and pixel densities on tablet screens are far greater than on desktop and laptop screens. As a result, graphics can look pixelated if they’re not designed with high resolution screens in mind. For this reason, font-based icons are a good choice because they scale well on super high­ resolution displays; they’re easy to colour and shade using CSS; and they only require one HTTP request to download. Plus, you don’t have to deal with a sprite sheet.</p>
<p><a href="http://www.webdesignerdepot.com/2012/01/how-to-make-your-own-icon-webfont/">Create your own icon font sets</a>, or use existing sets like Font Awesome, glyphish, iconsweets, symbolset, or icnfnt.</p>
<figure id='post-22035 media-22035' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/yydKlLL.png' alt='' /></figure>
<p><strong>Editor's note:</strong> I once did <a href="http://css-tricks.com/flat-icons-icon-fonts/">a massive roundup</a> of icon fonts (which I still have to add to). I'm a fan of using <a href="http://css-tricks.com/html-for-icon-font-usage/">these HTML techniques</a> for adding them to the page, which keep them accessible. I'm also a fan of <a href="http://icomoon.io/">IcoMoon</a> for the creating trimmed down, customized icon font sets.</p>
<h3>Performance is Design</h3>
<p>Modern web design techniques, like responsive design, can cripple website performance. Since <a href="http://www.strangeloopnetworks.com/resources/infographics/web-performance-and-user-expectations/website-abandonment-happens-after-3-seconds/">57% of users are likely to leave your website if it takes 3 seconds to load</a>, performance considerations are critical. Some tips for improving mobile website performance include compressing images and concatenating CSS and JavaScript to reduce the number of HTTP requests and overall page size. With these fixes, you’ll notice significantly speedier page load time and happier, higher converting users. Use tools like <a href="http://lisperator.net/uglifyjs/">Uglify</a>, <a href="http://sass-lang.com/">Sass</a>, <a href="http://compass-style.org/">Compass</a> and <a href="http://www.mobify.com/mobifyjs/">Mobify.js</a> to automate performance improvements.</p>
<p><strong>Editor's note:</strong> I cover some of these performance techniques and some others in <a href="http://css-tricks.com/video-screencasts/114-lets-do-simple-stuff-to-make-our-websites-faster/">#114: Let’s Do Simple Stuff to Make Our Websites Faster</a></p>
<h3>Go Forth!</h3>
<p>With these tablet transformation techniques in your toolbox, there’s no reason to get stressed out about not having a totally tablet-optimized website. For more ways to make your desktop site tablet friendly, read Mobify’s free ebook, <a href="http://www.mobify.com/go/tablet-web-design/">Tablet Web Design Best Practices</a>.</p>
<p><hr />

<p><small><a href="http://css-tricks.com/a-couple-of-best-practices-for-tablet-friendly-design/">A Couple of Best Practices for Tablet-Friendly Design</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/a-couple-of-best-practices-for-tablet-friendly-design/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Making Infield Form Labels Suck Less</title>
		<link>http://viget.com/inspire/making-infield-form-labels-suck-less</link>
		<comments>http://css-tricks.com/making-infield-form-labels-suck-less/#comments</comments>
		<pubDate>Sat, 15 Jun 2013 14:25:19 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Link]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=22013</guid>
		<description><![CDATA[<p><p>Jackson Fox presents some of the options: slide them out of the input, slide them to the right, or move them to tooltips. All to battle the issues with in-input labels like user confusion and lack of context when focused. <a href="http://css-tricks.com/hang-on-placeholders/">I had an idea once too.</a></p>
<p><a href="http://viget.com/inspire/making-infield-form-labels-suck-less" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/making-infield-form-labels-suck-less/">Permalink</a>&#8230;</p></p><p><hr />

<p><small><a href="http://css-tricks.com/making-infield-form-labels-suck-less/">Making Infield Form Labels Suck Less</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>Jackson Fox presents some of the options: slide them out of the input, slide them to the right, or move them to tooltips. All to battle the issues with in-input labels like user confusion and lack of context when focused. <a href="http://css-tricks.com/hang-on-placeholders/">I had an idea once too.</a></p>
<p><a href="http://viget.com/inspire/making-infield-form-labels-suck-less" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/making-infield-form-labels-suck-less/">Permalink</a></p><p><hr />

<p><small><a href="http://css-tricks.com/making-infield-form-labels-suck-less/">Making Infield Form Labels Suck Less</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/making-infield-form-labels-suck-less/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Poll Results: Mobile Web Design Responsibility</title>
		<link>http://css-tricks.com/poll-results-mobile-web-design-responsibility/</link>
		<comments>http://css-tricks.com/poll-results-mobile-web-design-responsibility/#comments</comments>
		<pubDate>Sat, 15 Jun 2013 14:18:28 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21990</guid>
		<description><![CDATA[<p>Between 2008 and 2013, people's opinion on where the majority of responsibility in mobile design lies has shifted.</p><p><hr />

<p><small><a href="http://css-tricks.com/poll-results-mobile-web-design-responsibility/">Poll Results: Mobile Web Design Responsibility</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>In early 2008, I asked the question:</p>
<blockquote><p>What is your opinion as to the web designers role in mobile design?</p></blockquote>
<p>The two choices were:</p>
<ul>
<li>It is my job to make sure the website looks and functions well on mobile devices.</li>
<li>It is the mobile device's job to make sure my website looks and functions well.</li>
</ul>
<p>Back then, <a href="http://css-tricks.com/poll-results-the-responsibility-of-mobile-web-design/">55% thought</a> it was the mobile devices job. The vibe was more "I'm just gonna keep building websites how I have been and these new devices can handle making them work." </p>
<p>In April 2013, <a href="http://css-tricks.com/repoll-whos-responsibility-is-mobile-design/">I started</a> the exact same poll again. Perhaps unsurprisingly, the 55% majority position has shrunk to just 21% of people. The other 79% consider it there job to build websites that look and function well on mobile devices.</p>
<p><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/reponsibility-poll.png' alt='' /></p>
<p>I forced people to choose one or the other to get a sense for where the majority of the responsibility lies, but I'm sure most of us agree that there is shared responsibility. Mobile devices need to support standards and should do all they can do to make the web experience great. But the polls are showing (and I agree) that ultimately the responsibility lies on the people making websites to make them work wherever they are used.</p>
<p><hr />

<p><small><a href="http://css-tricks.com/poll-results-mobile-web-design-responsibility/">Poll Results: Mobile Web Design Responsibility</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/poll-results-mobile-web-design-responsibility/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>JSbooks</title>
		<link>http://jsbooks.revolunet.com/</link>
		<comments>http://css-tricks.com/jsbooks/#comments</comments>
		<pubDate>Sat, 15 Jun 2013 14:08:20 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Link]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=22007</guid>
		<description><![CDATA[<p><p>A big collection of books on JavaScript that are published free on the web.</p>
<p><a href="http://jsbooks.revolunet.com/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/jsbooks/">Permalink</a>&#8230;</p></p><p><hr />

<p><small><a href="http://css-tricks.com/jsbooks/">JSbooks</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>A big collection of books on JavaScript that are published free on the web.</p>
<p><a href="http://jsbooks.revolunet.com/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/jsbooks/">Permalink</a></p><p><hr />

<p><small><a href="http://css-tricks.com/jsbooks/">JSbooks</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/jsbooks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The JavaScript Behind Touch-Friendly Sliders</title>
		<link>http://css-tricks.com/the-javascript-behind-touch-friendly-sliders/</link>
		<comments>http://css-tricks.com/the-javascript-behind-touch-friendly-sliders/#comments</comments>
		<pubDate>Thu, 13 Jun 2013 21:42:16 +0000</pubDate>
		<dc:creator>Guest Author</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21975</guid>
		<description><![CDATA[<p>Kevin Foley explains how to build a swipeable gallery on touch devices.</p><p><hr />

<p><small><a href="http://css-tricks.com/the-javascript-behind-touch-friendly-sliders/">The JavaScript Behind Touch-Friendly Sliders</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/foleyatwork">Kevin Foley</a>. Kevin is a developer at <a href="http://www.squarespace.com/">Squarespace</a> doing cool stuff with their <a href="http://developers.squarespace.com/">developer platform</a>, among other things. He was recently working on a swipeable image gallery and he agreed to share some of that work here!</em></p>
<p>A few weeks ago Chris posted a tutorial for creating a <a href="http://css-tricks.com/slider-with-sliding-backgrounds/">Slider with Sliding Background Images</a>. Around the same time I was working on some new swipeable galleries, so Chris suggested I write up a tutorial for how to add swipe support to his slider. Here it is!</p>
<figure id='post-21978 media-21978' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/slider-with-finger.jpg' alt='' /></figure>
<p>When creating a swipeable gallery there are two techniques — that I know of — you can choose from. You can animate the scroll position, or move the element using <code>translate</code>. There are pros and cons to each.</p>
<h3>Using Translate</h3>
<p>Moving the slider with <code>translate</code> gives you the advantage of hardware acceleration and subpixel animation. However, on the initial touch event you might notice a small delay — only a few tens of milliseconds — before the slider starts moving. This isn’t very well documented, I’ve just noticed it in my experience.</p>
<h3>Using Overflow Scroll</h3>
<p>Overflow scroll is extremely responsive to the initial touch because it’s native to the browser. You don’t have to wait for the event listener in JavaScript. But you lose out on all the smoothness of moving elements with translate.</p>
<p>For this tutorial we’re going to use <code>translate</code> because I think it looks better.</p>
<h3>The HTML</h3>
<p>The HTML in this example is going to differ from Chris’s original example. Instead of setting the image as a background image, we’re going to set it as an element. That will allow us to move the image to gain that cool panning effect using translate instead of animating the background position.</p>
<pre rel="HTML"><code class="language-markup">&lt;div class="slider-wrap"&gt;
  &lt;div class="slider" id="slider"&gt;
    &lt;div class="holder"&gt;
      &lt;div class="slide-wrapper"&gt;
        &lt;div class="slide"&gt;&lt;img class="slide-image" src="http://farm8.staticflickr.com/7347/8731666710_34d07e709e_z.jpg" /&gt;&lt;/div&gt;
        <span class="temp">74</span>
      &lt;/div&gt;
      &lt;div class="slide-wrapper"&gt;
        &lt;div class="slide"&gt;&lt;img class="slide-image" src="http://farm8.staticflickr.com/7384/8730654121_05bca33388_z.jpg" /&gt;&lt;/div&gt;
        <span class="temp">64</span>
      &lt;/div&gt;
      &lt;div class="slide-wrapper"&gt;
        &lt;div class="slide"&gt;&lt;img class="slide-image" src="http://farm8.staticflickr.com/7382/8732044638_9337082fc6_z.jpg" /&gt;&lt;/div&gt;
        <span class="temp">82</span>
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre>
<h3>The CSS</h3>
<p>For the most part the CSS is the same as Chris’ so I won’t rehash how to set up the layout. But there are a few key differences.</p>
<p>Instead of simply adding overflow scroll, we need to animate the slides. So for that we’re going to use a class to set up the transition and add it with JavaScript when we need it.</p>
<pre rel="CSS"><code class="language-css">.animate { transition: transform 0.3s ease-out; }</code></pre>
<p>IE 10 handles touch events differently than mobile Webkit browsers, like Chrome and Safari. We’ll address the Webkit touch events in JavaScript, but in IE10 we can create this entire slider (almost) with nothing but CSS.</p>
<pre rel="CSS"><code class="language-css">.ms-touch.slider {
  overflow-x: scroll;
  overflow-y: hidden;
  
  -ms-overflow-style: none;
  /* Hides the scrollbar. */
  
  -ms-scroll-chaining: none;
  /* Prevents Metro from swiping to the next tab or app. */
  
  -ms-scroll-snap-type: mandatory;
  /* Forces a snap scroll behavior on your images. */
  
  -ms-scroll-snap-points-x: snapInterval(0%, 100%);
  /* Defines the y and x intervals to snap to when scrolling. */
}</code></pre>
<p>Since these properties are probably new to most people (they were to me, too) I’ll walk through each one and what it does.</p>
<h4>-ms-scroll-chaining</h4>
<p>The Surface tablet switches browser tabs when you swipe across the page, rendering all swipe events useless for developers. Luckily it’s really easy to override that behavior by setting scroll chaining to none on any given element.</p>
<h4>-ms-scroll-snap-type</h4>
<p>When set to mandatory, this property overrides the browser’s default scrolling behavior and forces a scrollable element to snap to a certain interval.</p>
<h4>-ms-scroll-snap-points-x</h4>
<p>This property sets the intervals the scrollable element will snap to. It accepts two numbers: the first number is the starting point; the second is the snap interval. In this example, each slide is the full width of the parent element, which means the interval should be 100% — i.e. the element will snap to 100%, 200%, 300%, and so on.</p>
<h4>-ms-overflow-style</h4>
<p>This property lets you hide the scrollbar when you set it to none.</p>
<h3>The JavaScript</h3>
<p>The first thing we have to do in JavaScript is detect what kind of touch device we’re using. IE 10 uses pointer events while Webkit has “touchstart,” “touchmove,” and “touchend.” Since the IE 10 slider is (almost) all in CSS we need to detect that and add a class to the wrapper.</p>
<pre rel="JavaScript"><code class="language-javascript">if (navigator.msMaxTouchPoints) {
  $('#slider').addClass('ms-touch');
}</code></pre>
<p>Pretty simple. If you tested the slider at this point it would be a functioning swipeable slideshow. But we still need to add the panning effect on the images.</p>
<pre rel="JavaScript"><code class="language-javascript">if (navigator.msMaxTouchPoints) {
  $('#slider').addClass('ms-touch');

  // Listed for the scroll event and move the image with translate.
  $('#slider').on('scroll', function() {
    $('.slide-image').css('transform','translate3d(-' + (100-$(this).scrollLeft()/6) + 'px,0,0)');
  });
}</code></pre>
<p>And that’s it for IE 10.</p>
<p>Now for the webkit way. This will all be wrapped in the <code>else</code> statement. First we’ve just got to define a few variables.</p>
<pre rel="JavaScript"><code class="language-javascript">else {
  var slider = {

    // The elements.
    el: {
      slider: $("#slider"),
      holder: $(".holder"),
      imgSlide: $(".slide-image")
    },

    // The stuff that makes the slider work.
    slideWidth: $('#slider').width(), // Calculate the slider width.

    // Define these as global variables so we can use them across the entire script.
    touchstartx: undefined,
    touchmovex: undefined, 
    movex: undefined,
    index: 0,
    longTouch: undefined,
    // etc</code></pre>
<p>Then we need to initialize the function and define the events.</p>
<pre rel="JavaScript"><code class="language-javascript">    // continued

    init: function() {
      this.bindUIEvents();
    },

    bindUIEvents: function() {

      this.el.holder.on("touchstart", function(event) {
        slider.start(event);
      });

      this.el.holder.on("touchmove", function(event) {
        slider.move(event);
      });

      this.el.holder.on("touchend", function(event) {
        slider.end(event);
      });

    },</code></pre>
<p>Now for the fun stuff that actually makes stuff happen when you swipe the slider.</p>
<h4>Touchstart</h4>
<p>On the iPhone (and most other touch sliders) if you move the slider slowly, just a little bit, it will snap back into its original position. But if you do it quickly it will increment to the next slide. That fast movement is called a flick. And there isn’t any native way to test for a flick so we’ve got to use a little hack. On touchstart we intitialize a setTimeout function and set a variable after a certain amount of time.</p>
<pre rel="JavaScript"><code class="language-javascript">this.longTouch = false;
setTimeout(function() {
  // Since the root of setTimout is window we can’t reference this. That’s why this variable says window.slider in front of it.
  window.slider.longTouch = true;
}, 250);</code></pre>
<p>We’ve also got to get the original position of the touch to make out animation work. If you’ve never done this before, it’s a little strange. JavaScript lets you define multitouch events, so you can pass the touches event a number that represents the amount of fingers you’re listening for. For this example I’m really only interested in one finger/thumb so in the code sample below that’s what the [0] is for.</p>
<pre rel="JavaScript"><code class="language-javascript">// Get the original touch position.
this.touchstartx =  event.originalEvent.touches[0].pageX;</code></pre>
<p>Before we start moving the slider I’m going to remove the animate class. I know there is no animate class on the elements right now, but we need this for the subsequent slides. We’ll add it back to an element on touchend.</p>
<pre rel="JQuery"><code class="language-javascript">$('.animate').removeClass('animate');</code></pre>
<h4>Touchmove</h4>
<p>The touchmove event behaves similarly to scroll events in JavaScript. That is, if you do something on scroll it’s going to execute a bunch of times while the scroll is occuring. So we’re going to get the touchmove position continuously while the finger/thumb is moving.</p>
<pre rel="JavaScript"><code class="language-javascript">// Continuously return touch position.
this.touchmovex =  event.originalEvent.touches[0].pageX;</code></pre>
<p>Then we’ll do a quick calculation using the touchstart position we got in the last event and the touchmove position to figure out how to translate the slide.</p>
<pre rel="JavaScript"><code class="language-javascript">// Calculate distance to translate holder.
this.movex = this.index*this.slideWidth + (this.touchstartx - this.touchmovex);</code></pre>
<p>Then we need to pan the image, like Chris did in the original example. We’re going to use the same magic numbers he did.</p>
<pre rel="JavaScript"><code class="language-javascript">// Defines the speed the images should move at.
var panx = 100-this.movex/6;</code></pre>
<p>Now we need to add in some logic to handle edge cases. If you’re on the first slide or the last slide this logic will stop the image panning if you’re scrolling in the wrong direction (i.e. toward no content). This might not be the best way to handle this, but it works for me right now.</p>
<pre rel="JavaScript"><code class="language-javascript">if (this.movex &lt; 600) { // Makes the holder stop moving when there is no more content.
  this.el.holder.css('transform','translate3d(-' + this.movex + 'px,0,0)');
}
if (panx &lt; 100) { // Corrects an edge-case problem where the background image moves without the container moving.
  this.el.imgSlide.css('transform','translate3d(-' + panx + 'px,0,0)');
 }</code></pre>
<h4>Touchend</h4>
<p>In the touchend event we’ve got to figure out how far the user moved the slide, at what speed, and whether or not that action should increment to the next slide.</p>
<p>First we need to see exactly how far the distance of the swipe was. We’re going to calculate the absolute value of the distance moved to see if the user swiped.</p>
<pre rel="JavaScript"><code class="language-javascript">// Calculate the distance swiped.
var absMove = Math.abs(this.index*this.slideWidth - this.movex);</code></pre>
<p>Now we’re going to figure out if the slider should increment. All the other calculations in this example are based on the index variable, so this is the real logic behind the script. It checks if the user swiped the minimum distance to increment the slider, or if the movement was a flick. And if it meets either of those two criteria, which direction did the swipe go in.</p>
<pre rel="JavaScript"><code class="language-javascript">// Calculate the index. All other calculations are based on the index.
if (absMove &gt; this.slideWidth/2 || this.longTouch === false) {
  if (this.movex &gt; this.index*this.slideWidth &amp;&amp; this.index &lt; 2) {
    this.index++;
  } else if (this.movex &lt; this.index*this.slideWidth &amp;&amp; this.index &gt; 0) {
    this.index--;
  }
}</code></pre>
<p>Now we add the animate class and set the new translate position.</p>
<pre rel="JQuery"><code class="language-javascript">// Move and animate the elements.
this.el.holder.addClass('animate').css('transform', 'translate3d(-' + this.index*this.slideWidth + 'px,0,0)');
this.el.imgSlide.addClass('animate').css('transform', 'translate3d(-' + 100-this.index*50 + 'px,0,0)');</code></pre>
<h3>The Conclusion</h3>
<p>So, yea, hooray for IE 10.</p>
<p>But seriously, creating swipeable galleries is kind of a pain, considering it’s such a common idiom on mobile OS’s. And the end result won’t be as good as native swiping. But it will be close.</p>
<p>Here's the complete demo:</p>
<pre class="codepen" data-height="600" data-type="result" data-href="ylwoz" data-user="foleyatwork" data-safe="false"><code></code><a href="http://codepen.io/foleyatwork/pen/ylwoz">Check out this Pen!</a></pre>
<p>But you're best bet is checking it out on your touch device <a href="http://codepen.io/foleyatwork/full/ylwoz">here</a>.</p>
<p><hr />

<p><small><a href="http://css-tricks.com/the-javascript-behind-touch-friendly-sliders/">The JavaScript Behind Touch-Friendly Sliders</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/the-javascript-behind-touch-friendly-sliders/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>IE 10 Specific Styles</title>
		<link>http://css-tricks.com/ie-10-specific-styles/</link>
		<comments>http://css-tricks.com/ie-10-specific-styles/#comments</comments>
		<pubDate>Wed, 12 Jun 2013 15:06:53 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21957</guid>
		<description><![CDATA[<p><p>Conditional comments <a href="http://msdn.microsoft.com/en-us/library/ms537512(v=VS.85).aspx">are gone</a> in IE 10. That's good. IE 10 is a very good browser. Feature detection is a better way to go in nearly all cases. But what if you find some styling situation where you absolutely need to target IE 10? I guess you'll have to do this.</p>
<p></p>
<p>Rogie posted <a href="http://rog.ie/post/9089341529/html5boilerplatejs">a really simple idea</a> a while back that should still work great for this. Add the User Agent to the <code>&#60;html&#62;</code> element with a tiny bit of &#8230;</p></p><p><hr />

<p><small><a href="http://css-tricks.com/ie-10-specific-styles/">IE 10 Specific Styles</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>Conditional comments <a href="http://msdn.microsoft.com/en-us/library/ms537512(v=VS.85).aspx">are gone</a> in IE 10. That's good. IE 10 is a very good browser. Feature detection is a better way to go in nearly all cases. But what if you find some styling situation where you absolutely need to target IE 10? I guess you'll have to do this.</p>
<p><span id="more-21957"></span></p>
<p>Rogie posted <a href="http://rog.ie/post/9089341529/html5boilerplatejs">a really simple idea</a> a while back that should still work great for this. Add the User Agent to the <code>&lt;html&gt;</code> element with a tiny bit of JavaScript:</p>
<pre rel="JavaScript"><code class="language-javascript">var doc = document.documentElement;
doc.setAttribute('data-useragent', navigator.userAgent);</code></pre>
<p>IE 10's User Agent string is:</p>
<pre><code>Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)</code></pre>
<p>Which will result in:</p>
<pre rel="HTML"><code class="language-markup">&lt;html data-useragent="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)"&gt;</code></pre>
<p>And you can then style like:</p>
<pre rel="CSS"><code class="language-css">html[data-useragent*='MSIE 10.0'] h1 {
  color: blue;
}</code></pre>
<pre class="codepen" data-height="300" data-type="result" data-href="Kcmzf" data-user="chriscoyier" data-safe="true"><code></code><a href="http://codepen.io/chriscoyier/pen/Kcmzf">Check out this Pen!</a></pre>
<p><hr />

<p><small><a href="http://css-tricks.com/ie-10-specific-styles/">IE 10 Specific Styles</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/ie-10-specific-styles/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Hitch</title>
		<link>http://hitchjs.com/</link>
		<comments>http://css-tricks.com/hitch/#comments</comments>
		<pubDate>Tue, 11 Jun 2013 14:28:50 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Link]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21955</guid>
		<description><![CDATA[<p><p>It's <em>kinda</em> like a preprocessor (variables, prefixing...) but it can do much more because it's JavaScript that executes on your page. For instance, it can give you a <code>has</code> selector which can test if an element contains another element or selectors that select based on simple math logic (e.g. <code>:-math-greatest(data-price)</code>). </p>
<p><a href="http://hitchjs.com/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/hitch/">Permalink</a>&#8230;</p></p><p><hr />

<p><small><a href="http://css-tricks.com/hitch/">Hitch</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>It's <em>kinda</em> like a preprocessor (variables, prefixing...) but it can do much more because it's JavaScript that executes on your page. For instance, it can give you a <code>has</code> selector which can test if an element contains another element or selectors that select based on simple math logic (e.g. <code>:-math-greatest(data-price)</code>). </p>
<p><a href="http://hitchjs.com/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/hitch/">Permalink</a></p><p><hr />

<p><small><a href="http://css-tricks.com/hitch/">Hitch</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/hitch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crop Top</title>
		<link>http://css-tricks.com/crop-top/</link>
		<comments>http://css-tricks.com/crop-top/#comments</comments>
		<pubDate>Tue, 11 Jun 2013 13:30:00 +0000</pubDate>
		<dc:creator>Guest Author</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21941</guid>
		<description><![CDATA[<p>Sometimes you want an image to resize responsively but restrict its height&#8201;&#8212;&#8201;cropping it then as it widens. Here, we explore three options with various trade-offs.</p><p><hr />

<p><small><a href="http://css-tricks.com/crop-top/">Crop Top</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://parkerbennett.com">Parker Bennett</a> where he explores some different ways to approach the behavior of fluid and responsive images.</em></p>
<p>Sometimes you want an image to resize responsively but restrict its height&#8201;&#8212;&#8201;cropping it then as it widens. Here, we explore three options with various trade-offs.</p>
<figure>
<div class="bg-image bg-image-wedding bg-center-bottom"></div>
<figcaption>The happy couple, front and center: <code>background-position: center bottom</code>.</figcaption>
</figure>
<h3>Option One: background-image</h3>
<p><a href="http://cdpn.io/FcsBI">Edit on CodePen</a></p>
<p>Here, in place of an <code>&lt;img&gt;</code>, we create a div with a <code>background-image</code> and use CSS3's dandy new <code>background-size: cover</code> to have it size proportionally. As a bonus, we can easily crop from the top, center, or bottom using <code>background-position</code>.</p>
<p>One potential issue is we need to specify a height for the <code>div</code> to show up. This gives it a fixed height that doesn't scale proportionally (at least not without CSS media queries). When it gets narrow enough, the sides start cropping (this might be preferable, it depends).</p>
<p>Also, a quick check with <a href="http://caniuse.com/#feat=background-img-opts" target="_blank">caniuse.com</a> shows this will fail conspicuously in IE8 (showing the image full size), but thanks to Louis-R&eacute;mi Bab&eacute;, there's a <a href="http://louisremi.github.io/background-size-polyfill/" target="_blank">background-size polyfill</a> workaround (though it does require a relative or fixed position, and a z-index). IE8 also needs a polyfill for CSS media queries. There are a <a href="https://github.com/scottjehl/Respond" target="_blank">couple</a> <a href="http://code.google.com/p/css3-mediaqueries-js/" target="_blank">options</a>.</p>
<pre rel="CSS"><code class="language-css">.bg-image {
  /* image specified in separate class below */
  height: 240px;
  width: 100%; 
}

.bg-image-wedding {
  background-image: url(img/photo-wedding_1200x800.jpg);

  /* lt ie8 */
  -ms-background-position-x: center;
  -ms-background-position-y: bottom;
  background-position: center bottom;

  /* scale bg image proportionately */
  background-size: cover;
    
  /* ie8 workaround - http://louisremi.github.io/background-size-polyfill/ */
  -ms-behavior: url(/backgroundsize.min.htc);
  /* prevent scaling past src width (or not) */
  /* max-width: 1200px; */
}

/* example media queries */
@media only screen and (min-width : 768px) {
  .bg-image { height: 320px; }
}

@media only screen and (min-width : 1200px) {
  .bg-image { height: 400px; }
}</code></pre>
<figure>
<div class="bg-image bg-image-wedding bg-center-center"></div>
<figcaption>That's me in the middle: <code>background-position: center center</code>.</figcaption>
</figure>
<p>Something to note, <code>background-size: cover</code> will readily upscale larger than the src image's native size (or not, if you set a max-width).*</p>
<p>Still, there are some downsides to using a <code>background-image</code>. It's not as semantic or modular as an <code>img</code>, so it's less straightforward to maintain. You're seemingly stuck with a fixed height or cumbersome CSS media queries. Also, users can't save the image as easily (sometimes preferable).</p>
<h3>Option Two: img with a Twist</h3>
<p><a href="http://cdpn.io/ueidF">Edit on CodePen</a></p>
<p>Here, we use an <code>img</code> with <code>max-width</code> set to a percentage of the containing element so it scales responsively, then wrap it in a div with <code>overflow: hidden</code> and a specified height or <code>max-height</code>.</p>
<figure>
<div class="crop-height">
<img class="scale" src="http://cdn.css-tricks.com/wp-content/uploads/2013/06/photo-wedding_1200x800.jpg" alt="wedding" />
</div>
<p> <!-- end .crop-height --></p>
<figcaption>When you resize past 700px, the bride disappears.</figcaption>
</figure>
<pre rel="CSS"><code class="language-css">.crop-height {
  /* max-width: 1200px; /* img src width (if known) */
  max-height: 320px;
  overflow: hidden; 
}

img.scale {
  /* corrects inline gap in enclosing div */
  display: block;
  max-width: 100%;
  /* just in case, to force correct aspect ratio */
  height: auto !important;
  width: auto\9; /* ie8+9 */
  /* lt ie8 */
  -ms-interpolation-mode: bicubic; 
}</code></pre>
<p>As you can see, the bottom of the image now gets cropped as it widens. But what if you want it to crop from the top? Surprisingly, you can&#8201;&#8212;&#8201;using CSS3's <code>transform:rotate()</code> we add a "flip" class to both <code>img.scale</code> and <code>div.crop-height</code>&#8201;&#8212;&#8201;flipping the img all the way around.</p>
<figure>
<div class="crop-height flip">
<img class="scale flip" src="http://cdn.css-tricks.com/wp-content/uploads/2013/06/photo-wedding_1200x800.jpg" width="2400px" height="1600px" alt="wedding" />
</div>
<p> <!-- end .crop-height --></p>
<figcaption>There's the happy couple! (Unless you're using IE8 or lower.)</figcaption>
</figure>
<pre rel="CSS"><code class="language-css">/* apply to both img.scale and div.crop-height */
.flip {
  -webkit-transform: rotate(180deg);
  -moz-transform:    rotate(180deg);
  -ms-transform:     rotate(180deg);
  -o-transform:      rotate(180deg);
  transform:         rotate(180deg);
  /* needed? not sure */
  zoom: 1;
}

img.flip {
  /* if native or declared width of img.scale
     is less than div.crop-height, this will
     flipped img left */
  float: right;
  /* add clearfix if needed */ 
}</code></pre>
<p>Novel, but limited to top-cropping only. And, as you might expect, this <a href="http://caniuse.com/#search=transform" target="_blank">doesn't work in IE8, either</a>&#8201;&#8212;&#8201;perhaps failing less conspicuously (it will just crop from the bottom as before). The bad news is, I haven't found any <a href="http://www.useragentman.com/blog/2010/03/09/cross-browser-css-transforms-even-in-ie/" target="_blank">polyfill</a> <a href="http://code.google.com/p/jqueryrotate/" target="_blank">options</a> that work because they need a specified height and width.</p>
<h3>Option Three: Hybrid Approach</h3>
<p><a href="http://cdpn.io/CpEGh">Edit on CodePen</a></p>
<p>What if we could have the advantages of specifying an <code>img</code> (e.g., using <code>max-height</code> so we get proportional vertical scaling below a certain height), but also the flexible cropping and IE8 polyfill support afforded a <code>background-image</code>? We can!</p>
<figure>
<div class="crop-height bg-image-wedding bg-center-center">
<img class="invisible" src="http://cdn.css-tricks.com/wp-content/uploads/2013/06/photo-wedding_1200x800.jpg" alt="wedding" />
</div>
<p> <!-- end .crop-height --></p>
<figcaption>The img has <code>visibility: hidden</code>,  the background-image has <code>background-position: center center</code>.</figcaption>
</figure>
<p>The trick is to make the responsively-sizing <code>img</code> <em>invisible</em>. With <code>visibility: hidden</code> it retains layout, so we see the <code>background-image</code> behind it. (Since it's the same image source it shouldn't have to download twice.) If you want user-friendly access, you could instead use <code>opacity: 0</code>. Now users can drag the image or right-click to save. (Opacity and <a href="https://github.com/louisremi/background-size-polyfill" target="_blank">background-size</a> need some extra IE8 workaround bits.)</p>
<figure>
<div class="crop-height bg-image-wedding">
<img class="transparent" src="http://cdn.css-tricks.com/wp-content/uploads/2013/06/photo-wedding_1200x800.jpg" alt="wedding" />
</div>
<p> <!-- end .crop-height --></p>
<figcaption><code>opacity: 0</code>. A background-image you can drag or right-click to save. Works in IE8 (with help).</figcaption>
</figure>
<p>Another thought is to use a more compressed proxy <code>img</code>, and use CSS media queries to serve a higher-resolution <code>background-image</code> as needed. This img could even be a proportionately smaller size (e.g., matching your max-height), or watermarked. Check out this <a href="http://css-tricks.com/snippets/css/retina-display-media-query/" target="_blank">CSS-Tricks post on media queries</a>, and this helpful <a href="http://blog.14islands.com/post/37259603246/sass-resolution-mixin" target="_blank">resolution mixin for Sass</a>.</p>
<figure>
<div class="crop-height bg-image-wedding bg-left-top">
<img class="transparent" height="800px" width="1200px" src="http://cdn.css-tricks.com/wp-content/uploads/2013/06/photo-wedding_600x400.jpg" alt="wedding" />
</div>
<p> <!-- end .crop-height --></p>
<figcaption>Here, a 70 KB half-scale <code>img</code> is holding the space for the higher-res <code>background-image</code>.</figcaption>
</figure>
<pre rel="CSS"><code class="language-css">.crop-height {
    /* max-width: 1200px; /* img src width (if known) */
    max-height: 320px;
    overflow: hidden; }

.bg-image-wedding {
    /* for small devices */
    background-image: url(img/photo-wedding_1200x800.jpg);
    /* lt ie8 */
    -ms-background-position-x: center;
    -ms-background-position-y: bottom;
    background-position: center bottom;
    /* scale bg image proportionately */
    background-size: cover;
    /* ie8 workaround - http://louisremi.github.io/background-size-polyfill/ */
    -ms-behavior: url(/backgroundsize.min.htc);
    */ prevent scaling past src width (or not) */
    /* max-width: 1200px; */ }

.invisible {
    visibility: hidden; }

.transparent {
    /* trigger hasLayout for IE filters below */
    zoom: 1;
    /* 0 opacity in filters still displays layout */
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    filter: alpha(opacity=10);
    opacity: 0; }

/* example media query for smaller non-retina devices */
@media
    only screen and (max-device-width : 600px) and (-webkit-max-device-pixel-ratio: 1),
    only screen and (max-device-width : 600px) and (        max-device-pixel-ratio: 1) {
      
     .bg-image-wedding {
       background-image: url(img/photo-wedding_600x400.jpg); 
     }
}

/* example media query for retina ipad and up */
@media
    only screen and (min-device-width : 768px) and (-webkit-min-device-pixel-ratio: 1.5),
    only screen and (min-device-width : 768px) and (        min-device-pixel-ratio: 1.5) {

      .bg-image-wedding {
        background-image: url(img/photo-wedding_1200x800@1.5x.jpg); 
      }
}</code></pre>
<h3>Wrapping Up</h3>
<p>Until the day where CSS3's <code>object-fit</code> is supported, <a href="http://caniuse.com/#feat=object-fit" target="_blank">which may be a while</a>, this hybrid option seems like the best approach to me. Still, it's nice to have options. I hope you got something out of my way-too-thorough exploration. You can take a look at the source code for more, <a href="http://codepen.io/collection/nwyti" target="_blank">edit on CodePen</a>, or <a href="http://css-tricks.com/examples/croptop.zip">download the example files here</a>. If you have any questions, comments, or corrections, drop me a line: <a href="mailto:&#x70;&#x61;&#x72;&#x6B;&#x65;&#x72;&#x40;&#x70;&#x61;&#x72;&#x6B;&#x65;&#x72;&#x62;&#x65;&#x6E;&#x6E;&#x65;&#x74;&#x74;&#x2E;&#x63;&#x6F;&#x6D;">&#x70;&#x61;&#x72;&#x6B;&#x65;&#x72;&#x40;&#x70;&#x61;&#x72;&#x6B;&#x65;&#x72;&#x62;&#x65;&#x6E;&#x6E;&#x65;&#x74;&#x74;&#x2E;&#x63;&#x6F;&#x6D;</a>.</p>
<hr />
<p>* <small>You can make an img upscale like a background-image if you want. You just need to "pre-enlarge" it, adding a proportionately larger width and height to the img element itself: <code>&lt;img width="2400px" height="1600px" src="img/photo-wedding_1200x800.jpg /&gt;</code> (<a href="http://cdpn.io/knloC">edit on CodePen</a>).</small></p>
<p><hr />

<p><small><a href="http://css-tricks.com/crop-top/">Crop Top</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/crop-top/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Pizza Time Hovers</title>
		<link>http://css-tricks.com/pizza-time-hovers/</link>
		<comments>http://css-tricks.com/pizza-time-hovers/#comments</comments>
		<pubDate>Mon, 10 Jun 2013 17:11:09 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=21913</guid>
		<description><![CDATA[<p><p><a href="http://fuckyeahhovers.tumblr.com/">Hover Maester</a> <a href="http://jennlukas.com/">Jenn Lukas</a> sent me a link to <a href="http://pizzatime.com/">PizzaTime.com</a>. We agreed that 1) those are some pretty neat hovers! and 2) it's pretty cool that there is a quality website at all at a domain like PizzaTime.com - in which that she typed in randomly hoping there would be.</p>
<p></p>
<p>They have a set of navigational boxes that look like this:</p>

<p>Then they go through a neat multi-step transitional thing to essentially turn red:</p>

<p>The red square that the &#8230;</p></p><p><hr />

<p><small><a href="http://css-tricks.com/pizza-time-hovers/">Pizza Time Hovers</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://fuckyeahhovers.tumblr.com/">Hover Maester</a> <a href="http://jennlukas.com/">Jenn Lukas</a> sent me a link to <a href="http://pizzatime.com/">PizzaTime.com</a>. We agreed that 1) those are some pretty neat hovers! and 2) it's pretty cool that there is a quality website at all at a domain like PizzaTime.com - in which that she typed in randomly hoping there would be.</p>
<p><span id="more-21913"></span></p>
<p>They have a set of navigational boxes that look like this:</p>
<figure id='post-21914 media-21914' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/pizzatime-unhover.png' alt='' /></figure>
<p>Then they go through a neat multi-step transitional thing to essentially turn red:</p>
<figure id='post-21915 media-21915' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/pizzatime-hover.png' alt='' /></figure>
<p>The red square that the icon is in expands left/right to fill the parent box, then up/down afterward. The text and border change colors to remain visible over the expanded red box.</p>
<h3>The HTML</h3>
<p>We'll use this:</p>
<pre rel="HTML"><code class="language-markup">&lt;a href="#0" class="pizza-link"&gt;
  &lt;span class="icon maki-embassy"&gt;&lt;/span&gt;
  &lt;h3&gt;Find a Store&lt;/h3&gt;
  &lt;p&gt;We've got a location near you! As far as Bellingham and Lewiston and Yakima and South to Olympia.&lt;/p&gt;
&lt;/a&gt;</code></pre>
<p>In case you haven't gotten the memo yet, it's cool to wrap whatever you want in an anchor tag now, so it's easy to make this whole box a link. In our case we'll use that anchor to style the actual box. </p>
<p>Just for this demo, I used <a href="http://weloveiconfonts.com/">We Love Icon Fonts</a> and picked some random icons to use. That site has you use spans with pre-determined classes to show the icons. If I were to take this concept to production, in this case, I'd probably use a pseudo element instead because these icons hold no content value. Or if I was using a span system, I'd apply it with a <code>data-icon</code> attribute and <code>aria-hidden</code>. <a href="http://css-tricks.com/html-for-icon-font-usage/">Read more.</a></p>
<h3>The CSS</h3>
<p>This is a decent use case for of nesting in Sass. Everything we're working with here is related to this .pizza-time link, so let's just nest under that. Some boring CSS removed...</p>
<pre rel="SCSS"><code class="language-css">.pizza-link {
  display: block;
  float: left;
  /* yadda yadda yadda */
  h3 {
    border-bottom: 1px solid #eee;
    /* relative positioning keeps it on top of :before */
    position: relative;
  }
  p {
    /* relative positioning keeps it on top of :before */
    position: relative;
  }
  h3, p {
    /* "ease" and "all" are implied */
    @include transition(0.2s);
  }
  .icon {
    position: absolute;
    color: white;
    /* position in middle on top */
  }
  &amp;:before {
    content: "";
    background: #D62121;
    /* position in middle on top */
    /* BELOW icon and other content */
    /* :before makes this easier than :after */
    position: absolute;
    width: 50px;
    height: 50px;
    top: 20px;
    left: 50%;
    margin-left: -25px;
    @include transition(
      /* FIRST STEP */
      width 0.2s,
      left 0.2s,
      margin-left 0.2s,
      /* SECOND STEP */
      top 0.2s 0.2s,
      height 0.2s 0.2s
    );
  }
  &amp;:hover, &amp;:active {
    h3 {
      color: white;
      border-bottom-color: #E14646;
    }
    p {
      color: white;
    }
    &amp;:before {
      width: 230px;
      left: 0;
      top: 0;
      margin-left: 0;
      /* hacky, but the parent element */
      /* doesn't have explicit height */
      /* so can't use 100% */
      height: 320px;
    }
  }
}</code></pre>
<p>Three notable points:</p>
<ol>
<li>The "red box" is a pseudo element. In the past I would have used a span or something here, but now we're <a href="http://css-tricks.com/transitions-and-animations-on-css-generated-content/">able to transition pseudo elements</a>, so might as well.</li>
<li>Because the "red box" is an absolutely positioned :before, all we have to do to the other content inside is give it <code>position: relative</code> and it will sit on top of the red box in the natural document stacking order.</li>
<li>We made the transition "multi-step" by comma-separating all the values to be transitioned. The horizontal-related properties go first: <a href="http://css-tricks.com/almanac/properties/w/width/">width</a>, <a href="http://css-tricks.com/almanac/properties/l/left/">left</a>, <a href="http://css-tricks.com/almanac/properties/m/margin/">margin-left</a>. Then the vertical-related properties go "second": <a href="http://css-tricks.com/almanac/properties/t/top/">top</a>, <a href="http://css-tricks.com/almanac/properties/h/height/">height</a>. By specifying a delay value equal to the duration value of the first step values, they will happen in sequence after the "first step" properties.</li>
</ol>
<h3>Demo</h3>
<pre class="codepen" data-height="300" data-type="result" data-href="DrLvb" data-user="chriscoyier" data-safe="true"><code></code><a href="http://codepen.io/chriscoyier/pen/DrLvb">Check out this Pen!</a></pre>
<p>I think we're all aware now that most touch screens don't have hover states. Perhaps users of these devices won't see our little fancy hover. That's OK. They are links. They still work.</p>
<p><hr />

<p><small><a href="http://css-tricks.com/pizza-time-hovers/">Pizza Time Hovers</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/pizza-time-hovers/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

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

 Served from: css-tricks.com @ 2013-06-18 19:31:20 by W3 Total Cache -->
