<?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 14:06:26 +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>Replicating Some Of Google Hangouts Chat Design</title>
		<link>http://css-tricks.com/replicating-google-hangouts-chat/</link>
		<comments>http://css-tricks.com/replicating-google-hangouts-chat/#comments</comments>
		<pubDate>Wed, 19 Jun 2013 13:16:52 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Article]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=22077</guid>
		<description><![CDATA[<p><p>I've been using <a href="http://www.google.com/+/learnmore/hangouts/">Google Hangouts</a> a bunch. It's really pretty great. One on one or group text chat, audio, or video. Text is archived, maintains history, and is searchable. Video / audio is recordable. It works great on desktop and mobile devices and keeps them in sync. It's free. Hard to beat that.</p>
<p>Anyway, on a whim I decided to replicate some of the look of the chat window on desktop. Turns out there is a bunch of interesting stuff &#8230;</p></p><p><hr />

<p><small><a href="http://css-tricks.com/replicating-google-hangouts-chat/">Replicating Some Of Google Hangouts Chat Design</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>I've been using <a href="http://www.google.com/+/learnmore/hangouts/">Google Hangouts</a> a bunch. It's really pretty great. One on one or group text chat, audio, or video. Text is archived, maintains history, and is searchable. Video / audio is recordable. It works great on desktop and mobile devices and keeps them in sync. It's free. Hard to beat that.</p>
<p>Anyway, on a whim I decided to replicate some of the look of the chat window on desktop. Turns out there is a bunch of interesting stuff that comes up! Radial gradients, pseudo elements and animations, flexbox, and more.</p>
<p><span id="more-22077"></span></p>
<figure id='post-22081 media-22081' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/google-hangouts.png' alt='' /></figure>
<p>The image above is what we're going to build.</p>
<h3>Overall Structure</h3>
<p>Everything we see here is related. That calls for a <code>&lt;section&gt;</code> I think. There will probably be others like it, so that calls for a class name. </p>
<pre rel="HTML"><code class="language-markup">&lt;section class="module"&gt;
  &lt;!-- everything --&gt;
&lt;/section&gt;</code></pre>
<p>The top is more of a "header" than a "heading" because it's not just text, it has other stuff going on up there. The conversation happens in a very specific order, so I'm thinking <code>&lt;ol&gt;</code> with each group of text/image being a <code>&lt;li&gt;</code>. Within the list item, stuff like images and paragraphs.</p>
<p>I find little charts like this useful. While not comprehensive, it shows the thought process:</p>
<p><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/structure-of-module.png' alt='' /></p>
<pre rel="HTML"><code class="language-markup">&lt;section class="module"&gt;

  &lt;header class="top-bar"&gt;
    &lt;h1&gt;Hangouts&lt;/h1&gt;
    &lt;!-- likely some spans and stuff --&gt;
  &lt;/header&gt;

  &lt;ol class="conversation"&gt;
    &lt;li&gt;
      &lt;img class="avatar" /&gt;
      &lt;div class="message"&gt;
        &lt;p&gt;Talkie talk talk.&lt;/p&gt;
      &lt;/div&gt;
    &lt;li&gt;
  &lt;/ol&gt;

&lt;/section&gt;</code></pre>
<p>In the header there are some icons. In the demo, I use some quick-and-dirty stuff from <a href="http://weloveiconfonts.com/">We Love Icon Fonts</a>. In production I would use a streamlined icon font made from <a href="http://icomoon.io/">IcoMoon</a> and inserted with <a href="http://css-tricks.com/html-for-icon-font-usage/">this HTML</a>.</p>
<h3>The Pulsing Header</h3>
<p>When you get a new message, the header kinda glows/pulses. The solid-color bar now has essentially a radial gradient in the center of it that becomes more and less intense. At peak intensity, it's like:</p>
<figure id='post-22083 media-22083' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/peak.png' alt='' /></figure>
<p>Which you could picture like this:</p>
<p><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/cut-off.png' alt='' /></p>
<p>Creating that gradient isn't quite as easy as you might hope<sup>1</sup>. You might think it's the most basic syntax of all, from one gray to another:</p>
<pre rel="CSS"><code class="language-css">background: radial-gradient(#666, #999);</code></pre>
<p>But no, that just fills the area with an elliptical gradient (white and black for clarity):</p>
<figure id='post-22085 media-22085' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/elliptical.png' alt='' /></figure>
<p>You can force it into a circle, which gets us pretty close:</p>
<pre rel="CSS"><code class="language-css">background: radial-gradient(circle, #666, #999);</code></pre>
<figure id='post-22086 media-22086' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/circle.png' alt='' /></figure>
<p>But if you really want fine-grained control over how large that gradient in the middle is, you'll want something like:</p>
<p>background: radial-gradient(center center, circle closest-side, #999999, #666666 800%);</p>
<p>Where you can adjust that 800% to get it just how you want it. That syntax is still prefixed at the time of this writing. With all prefixes it's like:</p>
<pre rel="CSS"><code class="language-css">background: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 800, color-stop(0%, #999999), color-stop(800%, #666666));
background: -webkit-radial-gradient(center center, circle closest-side, #999999, #666666 800%);
background: -moz-radial-gradient(center center, circle closest-side, #999999, #666666 800%);
background: -o-radial-gradient(center center, circle closest-side, #999999, #666666 800%);
background: radial-gradient(center center, circle closest-side, #999999, #666666 800%);</code></pre>
<p>And even then it doesn't work in Opera 12.15. So... instead we could use the most simple gradient syntax and apply it to a pseudo element on the header. That way we can animate the opacity to get the pulse effect anyway.</p>
<pre rel="CSS"><code class="language-css">.top-bar {
  background: #666;
  position: relative;
  overflow: hidden; 
}
.top-bar::before {
  content: "";
  position: absolute;
  top: -100%;
  left: 0;
  right: 0;
  bottom: -100%;
  opacity: 0.25;
  background: radial-gradient(white, black);
}</code></pre>
<p>The absolute positioning will make it sit on top of anything inside the header with default static positioning. But we can fix that.</p>
<pre rel="CSS"><code class="language-css">.top-bar &gt; * {
  position: relative;
}</code></pre>
<p>Then animate it:</p>
<pre rel="CSS"><code class="language-css">.top-bar::before {
  animation: pulse 1s ease alternate infinite;
}
@keyframes pulse {
  from { opacity: 0; }
  to { opacity: 0.5; }
}</code></pre>
<p><a href="http://css-tricks.com/transitions-and-animations-on-css-generated-content/">Which won't work in everything</a> but it's a lot better than it was. You'd do it with an extra element / image / jQuery if you deemed the effect critical enough.</p>
<h3>Basic Chat Box Setup</h3>
<p>We already decided the conversation itself is an ordered list. Each person talking is a list item. Each individual message is a <code>&lt;p&gt;</code>, but there can be multiple messages together, so those are all grouped in a <code>&lt;div class="message"&gt;</code>. We'll wrap the avatar as well.</p>
<pre rel="HTML"><code class="language-markup">&lt;li&gt;
  &lt;div class="avatar"&gt;
    &lt;img src="http://s3-us-west-2.amazonaws.com/s.cdpn.io/5/profile/profile-80_9.jpg" /&gt;
  &lt;/div&gt;
  &lt;div class="messages"&gt;
    &lt;p&gt;yeah, they do early flights cause they connect with big airports.  they wanna get u to your connection&lt;/p&gt;
    &lt;time datetime="2009-11-13T20:00"&gt;Timothy • 51 min&lt;/time&gt;
  &lt;/div&gt;
&lt;/li&gt;</code></pre>
<p>Note that <code>&lt;time&gt;</code> element in there. The actual content of the time element can be whatever makes sense. But the <code>datetime</code> attribute is in a specific format. <a href="http://html5doctor.com/the-time-element/">See more.</a></p>
<p>We also need a way to distinquish between our messages and other people's messages. A class will do...</p>
<pre rel="HTML"><code class="language-markup">&lt;li class="self"&gt;
  &lt;!-- ... --&gt;
&lt;/li&gt;
&lt;li class="other"&gt;
  &lt;!-- ... --&gt;
&lt;/li&gt;</code></pre>
<h3>The Variable Width Chat Bubbles</h3>
<p>An interesting design feature of this chat design is that the chat "bubble" is only as wide as the longest sentence it contains. It's a nice feature as it makes very short messages less visually intense and gives rhythm to the conversation.</p>
<p><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/wide-as-sentence.png' alt='' /></p>
<p>If (avatar + messages = full width) every time, floats would work fine. There is a way we could get this working with floats, but it would require extra non-semantic wrappers. Instead, let's make this a super-progressive demo and use flexbox for layout<sup>2</sup>. This is going to make a couple of other things awesomely easy, which we will get to in a moment. </p>
<p><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/flex-stuff.png' alt='' /></p>
<p>Flex items, by their nature, are just as wide as they need to be. They also exhibit no natural desire to fill their flex container. If they do, they do, if they don't, they don't. You can even have them wrap if you want, but we don't in this case. </p>
<p>So our CSS becomes:</p>
<pre rel="CSS"><code class="language-css">.discussion li {
  display: flex;
}
.avatar {
  width: 40px;
}
.avatar img {
  width: 100%;
  display: block;
}</code></pre>
<p>Deliciously easy.</p>
<h3>The Switcheroo</h3>
<p>I'm sure you noticed the flip-flop design. Messages from others have the avatar on the left, messages by you have the avatar on the right. Again, do-able with floats but kinda janky. Flexbox makes this extremely easy.</p>
<p>In our markup, we put the avatar first, so that will be the default ("other people"). In list items with the class name "self" (our own messages) we'll switch the order of layout.</p>
<pre rel="CSS"><code class="language-css">.self {
  justify-content: flex-end;
}</code></pre>
<p>WELL THAT WAS EASY. But wait. It's not just the horizontal alignment that switches, it's the vertical alignment too.</p>
<p><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/alignment.png' alt='' /></p>
<p>Floats would never be able to help us here. Things would get freaky with some placeholder elements and absolutely positioning and who knows what. With flexbox...</p>
<pre rel="CSS"><code class="language-css">.self {
  /* switch horizontal layout */
  justify-content: flex-end;
  /* switch vertical layout */
  align-items: flex-end;
}</code></pre>
<p>Wipes hands.</p>
<h3>The Message Bubble Triangles</h3>
<p>This has been covered a million times, so I'll keep it brief. <a href="http://css-tricks.com/snippets/css/css-triangle/">You can make triangles in CSS</a> with zero-width zero-height elements and borders. The borders on elements will meet each other at an angle. So if one is colored and the other is transparent, it will look like a shape.</p>
<p>Here, we'll color the top and right borders, and leave the bottom and left borders transparent. This makes the type of triangle you see here:</p>
<p><img src='http://cdn.css-tricks.com/wp-content/uploads/2013/06/triangle.png' alt='' /></p>
<pre rel="CSS"><code class="language-css">.other .avatar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border: 5px solid white;
  border-left-color: transparent;
  border-bottom-color: transparent;
}</code></pre>
<p>Then just switch up the positioning of it and which borders are colored for "self" messages:</p>
<pre rel="CSS"><code class="language-css">.self .avatar::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border: 5px solid white;
  border-right-color: transparent;
  border-top-color: transparent;
}</code></pre>
<p>The message bubbles have little box-shadows under them. We didn't cover it, but you can see in the demo. In the "self" messages, the triangle meets the bubble where the shadow is most pronounced, so it looks weird if it's not there. We can apply the shadow to it to fix it. </p>
<pre rel="CSS"><code class="language-css">.self .avatar::after {
  box-shadow: 1px 1px 2px rgba(black, 0.2);
}</code></pre>
<h3>The Demo</h3>
<pre class="codepen" data-height="500" data-type="result" data-href="FCIap" data-user="chriscoyier" data-safe="true"><code></code><a href="http://codepen.io/chriscoyier/pen/FCIap">Check out this Pen!</a></pre>
<p><script async src="http://codepen.io/assets/embed/ei.js"></script></p>
<hr />
<p><sup>1</sup> <small>Here's a couple of more resources on radial gradients: <a href="http://www.impressivewebs.com/css3-radial-gradient-syntax/">Impressive Webs</a>, <a href="http://www.webdirections.org/blog/css3-radial-gradients/">Web Directions</a></small></p>
<p><sup>2</sup> <small>I went totally un-prefixed and new-school with all the flexbox stuff in this article, Here's some resources on that: <a href="http://css-tricks.com/using-flexbox/">CSS-Tricks</a>, <a href="http://dev.opera.com/articles/view/advanced-cross-browser-flexbox/">Dev.Opera</a>. It's a good time for flexbox right now. IE 10 has a prefixed semi-old version, but IE 11 will be un-prefixed and new. Firefox has supported various versions forever but will be un-prefixed and new in 22 (late June 2013). Safari has old version prefixed in 6 but going unprefixed and new in 7. Chrome has new verison prefixed but <a href="https://groups.google.com/a/chromium.org/forum/?fromgroups#!topic/blink-dev/YJd-kkDYtiw">is unprefixing</a> in (30?). iOS and Blackberry are prefixing, but at least new syntax. Android at least has old prefixed version.</small></p>
<p><hr />

<p><small><a href="http://css-tricks.com/replicating-google-hangouts-chat/">Replicating Some Of Google Hangouts Chat 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/replicating-google-hangouts-chat/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Speaker Notes</title>
		<link>http://ladiesintech.com/speaker-notes/</link>
		<comments>http://css-tricks.com/speaker-notes/#comments</comments>
		<pubDate>Wed, 19 Jun 2013 12:58:57 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Link]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=22105</guid>
		<description><![CDATA[<p><p>Rebecca Murphey with tips on speaking. While posted on “Ladies in Tech,” the advice is good for anyone.</p>
<p>I’ve learned that my ability to give the “elevator pitch” for a talk is a great measure of my preparedness.</p>
<p><a href="http://ladiesintech.com/speaker-notes/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/speaker-notes/">Permalink</a>&#8230;</p></p><p><hr />

<p><small><a href="http://css-tricks.com/speaker-notes/">Speaker Notes</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>Rebecca Murphey with tips on speaking. While posted on “Ladies in Tech,” the advice is good for anyone.</p>
<blockquote><p>I’ve learned that my ability to give the “elevator pitch” for a talk is a great measure of my preparedness.</p></blockquote>
<p><a href="http://ladiesintech.com/speaker-notes/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/speaker-notes/">Permalink</a></p><p><hr />

<p><small><a href="http://css-tricks.com/speaker-notes/">Speaker Notes</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/speaker-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intro to Web Workers</title>
		<link>https://zapier.com/engineering/intro-to-web-workers/</link>
		<comments>http://css-tricks.com/intro-to-web-workers/#comments</comments>
		<pubDate>Wed, 19 Jun 2013 12:56:48 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Link]]></category>

		<guid isPermaLink="false">http://css-tricks.com/?p=22103</guid>
		<description><![CDATA[<p><p>Brian Cooksey goes from "I don't really know what Web Workers are" to "OK I totally get Web Workers." on one short article.</p>
<p>...they are scripts that run in their own background thread. Independence from the regular JavaScript event loop means that a worker can churn away at something for a long time and your UI will remain responsive.</p>
<p><a href="https://zapier.com/engineering/intro-to-web-workers/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/intro-to-web-workers/">Permalink</a>&#8230;</p></p><p><hr />

<p><small><a href="http://css-tricks.com/intro-to-web-workers/">Intro to Web Workers</a> is a post from <a href="http://css-tricks.com">CSS-Tricks</a></small></p></p>]]></description>
				<content:encoded><![CDATA[<p>Brian Cooksey goes from "I don't really know what Web Workers are" to "OK I totally get Web Workers." on one short article.</p>
<blockquote><p>...they are scripts that run in their own background thread. Independence from the regular JavaScript event loop means that a worker can churn away at something for a long time and your UI will remain responsive.</p></blockquote>
<p><a href="https://zapier.com/engineering/intro-to-web-workers/" title="Direct link to featured article">Direct Link to Article</a> &#8212; <a href="http://css-tricks.com/intro-to-web-workers/">Permalink</a></p><p><hr />

<p><small><a href="http://css-tricks.com/intro-to-web-workers/">Intro to Web Workers</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/intro-to-web-workers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>160</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>12</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>
	</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-19 07:21:48 by W3 Total Cache -->
