<?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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
   <channel>
      <title>CSS-Tricks Snippet Feed</title>
      <description>Pipes Output</description>
      <link>http://pipes.yahoo.com/pipes/pipe.info?_id=ed5d0448a663b3bb5c22cafea4c13d1a</link>
      <atom:link rel="next" href="http://pipes.yahoo.com/pipes/pipe.run?_id=ed5d0448a663b3bb5c22cafea4c13d1a&amp;_render=rss&amp;page=2" />
      <pubDate>Wed, 22 May 2013 01:48:06 +0000</pubDate>
      <generator>http://pipes.yahoo.com/pipes/</generator>
      <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CSS-TricksSnippets" /><feedburner:info uri="css-trickssnippets" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
         <title>Momentum Scrolling on iOS Overflow Elements</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/6eKz55s4crg/</link>
         <description>&lt;p&gt;Web pages on iOS by default have a "momentum" style scrolling where a flick of the finger sends the web page scrolling and it keeps going until eventually slowing down and stopping as if friction is slowing it down. Like if you were to push a hockey puck across the ice or something. You might think that any element with scrolling would have this behavior as well, but it doesn't. You can add it back with a special property.&lt;/p&gt;
&lt;code class="language-css"&gt;.module &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=21524</guid>
         <pubDate>Sat, 04 May 2013 13:26:53 +0000</pubDate>
         <content:encoded><![CDATA[<p>Web pages on iOS by default have a "momentum" style scrolling where a flick of the finger sends the web page scrolling and it keeps going until eventually slowing down and stopping as if friction is slowing it down. Like if you were to push a hockey puck across the ice or something. You might think that any element with scrolling would have this behavior as well, but it doesn't. You can add it back with a special property.</p>
<pre><code class="language-css">.module {
  width: 300px;
  height: 200px;

  overflow-y: scroll; /* has to be scroll, not auto */
  -webkit-overflow-scrolling: touch;
}</code></pre>
<pre class="codepen"><code></code><a rel="nofollow" target="_blank" href="http://codepen.io/chriscoyier/pen/nHEDj">Check out this Pen!</a></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/6eKz55s4crg" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/css/momentum-scrolling-on-ios-overflow-elements/</feedburner:origLink></item>
      <item>
         <title>Spam Comments with Very Long URL’s</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/rjrv3g7kDCk/</link>
         <description>&lt;p&gt;Super long URL's are a sure fire sign the comment is spammy. This will mark comments with URL's (as the author URL, not just in the text) longer than 50 characters as spam, otherwise leave their state the way it is.&lt;/p&gt;
&lt;code class="language-markup"&gt;&amp;#60;?php

  function rkv_url_spamcheck( $approved , $commentdata ) {
    return ( strlen( $commentdata['comment_author_url'] ) &amp;#62; 50 ) ? 'spam' : $approved;
  }

  add_filter( 'pre_comment_approved', 'rkv_url_spamcheck', 99, 2 );

?&amp;#62;&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=21465</guid>
         <pubDate>Sun, 28 Apr 2013 13:09:20 +0000</pubDate>
         <content:encoded><![CDATA[<p>Super long URL's are a sure fire sign the comment is spammy. This will mark comments with URL's (as the author URL, not just in the text) longer than 50 characters as spam, otherwise leave their state the way it is.</p>
<pre><code class="language-markup">&lt;?php

  function rkv_url_spamcheck( $approved , $commentdata ) {
    return ( strlen( $commentdata['comment_author_url'] ) &gt; 50 ) ? 'spam' : $approved;
  }

  add_filter( 'pre_comment_approved', 'rkv_url_spamcheck', 99, 2 );

?&gt;</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/rjrv3g7kDCk" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/wordpress/spam-comments-with-very-long-urls/</feedburner:origLink></item>
      <item>
         <title>Mover Cursor to End of Textarea</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/Ir9MVyXUJLo/</link>
         <description>&lt;p&gt;Setting the value of a textarea moves the cursor to the end. So you just need to save the value, clear it, focus it, and re-apply the value and you're good. &lt;/p&gt;
&lt;code class="language-javascript"&gt;$("button").on("click", function() {
  
  // cache textarea as we need it more than once
  var textarea = $("textarea"),
      
      // save old value as we need to clear it
      val = textarea.val();
  
  // focus textarea, clear value, re-apply
  textarea
    .focus()
    .val("")
    .val(val);
});&lt;/code&gt;
&lt;p&gt;This demo does that but also applies a &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=21353</guid>
         <pubDate>Sat, 20 Apr 2013 17:47:14 +0000</pubDate>
         <content:encoded><![CDATA[<p>Setting the value of a textarea moves the cursor to the end. So you just need to save the value, clear it, focus it, and re-apply the value and you're good. </p>
<pre><code class="language-javascript">$("button").on("click", function() {
  
  // cache textarea as we need it more than once
  var textarea = $("textarea"),
      
      // save old value as we need to clear it
      val = textarea.val();
  
  // focus textarea, clear value, re-apply
  textarea
    .focus()
    .val("")
    .val(val);
});</code></pre>
<p>This demo does that but also applies a little bit of UX. If the textarea's current value doesn't end in a space, add one. Just so you can click-and-keep-typing as you might.</p>
<pre class="codepen"><code></code><a rel="nofollow" target="_blank" href="http://codepen.io/chriscoyier/pen/gBdLE">Check out this Pen!</a></pre>
<p>You could make it a plugin as well:</p>
<pre><code class="language-javascript">$.fn.focusToEnd = function() {
   return this.each(function() {
       var v = $(this).val();
       $(this).focus().val("").val(v);
   });
};</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/Ir9MVyXUJLo" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/jquery/mover-cursor-to-end-of-textarea/</feedburner:origLink></item>
      <item>
         <title>A Complete Guide to Flexbox</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/xF5lU44p338/</link>
         <description>&lt;p&gt;The &lt;code&gt;Flexbox Layout&lt;/code&gt; (Flexible Box) module (currently a W3C Candidate Recommandation) aims at providing a more efficient way to lay out, align and distribute space among items in a container, even when their size is unknown and/or dynamic (thus the word "flex"). &lt;/p&gt;
&lt;p&gt;The main idea behind the flex layout is to give the container the ability to alter its items' width/height (and order) to best fill the available space (mostly to accomodate to all kind of display devices and screen &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=21059</guid>
         <pubDate>Mon, 08 Apr 2013 18:46:57 +0000</pubDate>
         <content:encoded><![CDATA[<p>The <code>Flexbox Layout</code> (Flexible Box) module (currently a W3C Candidate Recommandation) aims at providing a more efficient way to lay out, align and distribute space among items in a container, even when their size is unknown and/or dynamic (thus the word "flex"). </p>
<p>The main idea behind the flex layout is to give the container the ability to alter its items' width/height (and order) to best fill the available space (mostly to accomodate to all kind of display devices and screen sizes). A flex container expands items to fill available free space, or shrinks them to prevent overflow.</p>
<p>Most importantly, the flexbox layout is direction-agnostic as opposed to the regular layouts (block which is vertically-based and inline which is horizontally-based). While those work well for pages, they lack flexibility (no pun intended) to support large or complex applications (especially when it comes to orientation changing, resizing, stretching, shrinking, etc.). </p>
<p><strong>Note:</strong> Flexbox layout is most appropriate to the components of an application, and small-scale layouts, while the <a rel="nofollow" target="_blank" href="http://css-tricks.com/almanac/properties/g/grid/">Grid</a> layout is intended for larger scale layouts.</p>
<h3>Basics</h3>
<p>Since flexbox is a whole module and not a single property, it involves a lot of things including its whole set of properties. Some of them are meant to be set on the container (parent element, known as "flex container") whereas the others are meant to be set on the children (said "flex items").</p>
<p>If regular layout is based on both block and inline flow directions, the flex layout is based on "flex-flow directions". Please have a look at this figure from the specification, explaining the main idea behind the flex layout.</p>
<p><img src='http://cdn.css-tricks.com/wp-content/uploads/2011/08/flexbox.png' alt=''/></p>
<p>Basically, items will be layed out following either the <code>main axis</code> (from <code>main-start</code> to <code>main-end</code>) or the cross axis (from <code>cross-start</code> to <code>cross-end</code>).</p>
<ul>
<li><strong>main axis</strong> - The main axis of a flex container is the primary axis along which flex items are laid out. Beware, it is not necessarily horizontal; it depends on the <code>justify-content</code> property (see below).</li>
<li><strong>main-start | main-end</strong> - The flex items are placed within the container starting from main-start and going to main-end.</li>
<li><strong>main size</strong> - A flex item's width or height, whichever is in the main dimension, is the item's main size. The flex item's main size property is either the ‘width’ or ‘height’ property, whichever is in the main dimension.</li>
<li><strong>cross axis</strong> - The axis perpendicular to the main axis is called the cross axis. Its direction depends on the main axis direction.</li>
<li><strong>cross-start | cross-end</strong> - Flex lines are filled with items and placed into the container starting on the cross-start side of the flex container and going toward the cross-end side.</li>
<li><strong>cross size</strong> - The width or height of a flex item, whichever is in the cross dimension, is the item's cross size. The cross size property is whichever of ‘width’ or ‘height’ that is in the cross dimension.</li>
</ul>
<h3>Properties</h3>
<h4>display: flex | inline-flex; (Applies to: parent flex container element)</h4>
<p>This defines a flex container; inline or block depending on the given value. Thus, it enables a flex context for all its direct children.</p>
<pre><code class="language-css">display: other values | flex | inline-flex;</code></pre>
<p>Please note that:</p>
<ul>
<li>CSS columns have no effect on a flex container</li>
<li><code>float</code>, <code>clear</code> and <code>vertical-align</code> have no effect on a flex item</li>
</ul>
<h4>flex-direction (Applies to: parent flex container element) </h4>
<p>This establishes the main-axis, thus defining the direction flex items are placed in the flex container.</p>
<pre><code class="language-css">flex-direction: row | row-reverse | column | column-reverse</code></pre>
<ul>
<li><code>row</code> (default): left to right in <code>ltr</code>; right to left in <code>rtl</code></li>
<li><code>row-reverse</code>: right to left in <code>ltr</code>; left to right in <code>rtl</code></li>
<li><code>column</code>: same as <code>row</code> but top to bottom</li>
<li><code>column-reverse</code>: same as <code>row-reverse</code> but top to bottom</li>
</ul>
<h4>flex-wrap (Applies to: parent flex container element)</h4>
<p>This defines whether the flex container is single-line or multi-line, and the direction of the cross-axis, which determines the direction new lines are stacked in.</p>
<pre><code class="language-css">flex-wrap: nowrap | wrap | wrap-reverse</code></pre>
<ul>
<li><code>nowrap</code> (default): single-line / left to right in <code>ltr</code>; right to left in <code>rtl</code></li>
<li><code>wrap</code>: multi-line / left to right in <code>ltr</code>; right to left in <code>rtl</code></li>
<li><code>wrap-reverse</code>: multi-line / right to left in <code>ltr</code>; left to right in <code>rtl</code></li>
</ul>
<h4>flex-flow (Applies to: parent flex container element)</h4>
<p>This is a shorthand `flex-direction` and `flex-wrap` properties, which together define the flex container's main and cross axes. Default is `row nowrap`;</p>
<pre><code class="language-css">flex-flow: &lt;‘flex-direction’&gt; || &lt;‘flex-wrap’&gt;</code></pre>
<h4>justify-content (Applies to: parent flex container element)</h4>
<p>This defines the alignment along the main axis. It helps distribute extra free space leftover when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow the line.</p>
<pre><code class="language-css">justify-content: flex-start | flex-end | center | space-between | space-around</code></pre>
<ul>
<li><code>flex-start</code> (default): items are packed toward the start line</li>
<li><code>flex-end</code>: items are packed toward to end line</li>
<li><code>center</code>: items are centered along the line</li>
<li><code>space-between</code>: items are evenly distributed in the line; first item is on the start line, last item on the end line</li>
<li><code>space-around</code>: items are evenly distributed in the line with equal space around them</li>
</ul>
<img src='http://cdn.css-tricks.com/wp-content/uploads/2011/08/justify-contetnt.png' alt=''/> 
<h4>align-items (Applies to: parent flex container element)</h4>
<p>This defines the default behaviour for how flex items are laid out along the cross axis on the current line. Think of it as the <code>justify-content</code> version for the cross-axis (perpendicular to the main-axis).</p>
<pre><code class="language-css">align-items: flex-start | flex-end | center | baseline | stretch</code></pre>
<ul>
<li><code>flex-start</code>: cross-start margin edge of the items is placed on the cross-start line</li>
<li><code>flex-end</code>: cross-end margin edge of the items is placed on the cross-end line</li>
<li><code>center</code>: items are centered in the cross-axis</li>
<li><code>baseline</code>: items are aligned such as their baselines align</li>
<li><code>stretch</code> (default): stretch to fill the container (still respect min-width/max-width)</li>
</ul>
<img src='http://cdn.css-tricks.com/wp-content/uploads/2011/08/align-items.png' alt=''/> 
<h4>align-content (Applies to: parent flex container element)</h4>
<p>This aligns a flex container's lines within when there is extra space in the cross-axis, similar to how <code>justify-content</code> aligns individual items within the main-axis. </p>
<p><strong>Note:</strong> this property has no effect when the flexbox has only a single line.</p>
<pre><code class="language-css">align-content: flex-start | flex-end | center | space-between | space-around | stretch</code></pre>
<ul>
<li><code>flex-start</code>: lines packed to the start of the container</li>
<li><code>flex-end</code>: lines packed to the end of the container</li>
<li><code>center</code>: lines packed to the center of the container</li>
<li><code>space-between</code>: lines evenly distributed; the first line is at the start of the container while the last one is at the end</li>
<li><code>space-around</code>: lines evenly distributed with equal space between them</li>
<li><code>stretch</code> (default): lines stretch to take up the remaining space</li>
</ul>
<img src='http://cdn.css-tricks.com/wp-content/uploads/2011/08/align-content.png' alt=''/> 
<hr />
<h4>order (Applies to: child element / flex item)</h4>
<p>By default, flex items are layed out in the source order. However, the <code>order</code> property controls the order in which they appear in their container.</p>
<pre><code class="language-css">order: &lt;integer&gt;</code></pre>
<h4>flex-grow (Applies to: child element / flex item)</h4>
<p>This defines the ability for a flex item to grow if necessary. It accepts a unitless value that serves as a proportion. It dictates what amount of the available space inside the flex container the item should take up. </p>
<p>If all items have <code>flex-gro</code>w set to 1, every child will set to an equal size inside the container. If you were to give one of the children a value of 2, that child would take up twice as much space as the others.</p>
<pre><code class="language-css">flex-grow: &lt;number&gt; (default 0)</code></pre>
<p>Negative numbers are invalid.</p>
<h4>flex-shrink (Applies to: child element / flex item)</h4>
<p>This defines the ability for a flex item to shrink if necessary.</p>
<pre><code class="language-css">flex-shrink: &lt;number&gt; (default 1)</code></pre>
<p>Negative numbers are invalid.</p>
<h4>flex-basis (Applies to: child element / flex item)</h4>
<p>This defines the default size of an element before the remaining space is distributed.</p>
<pre><code class="language-css">flex-basis: &lt;length&gt; | auto (default auto)</code></pre>
<h4>flex (Applies to: child element / flex item)</h4>
<p>This is the shorthand for <code>flex-grow,</code> <code>flex-shrink</code> and <code>flex-basis</code>. The second and third parameters (<code>flex-shrink</code>, <code>flex-basis</code>) are optional. Default is <code>0 1 auto</code>.</p>
<pre><code class="language-css">flex: none | [ &lt;'flex-grow'&gt; &lt;'flex-shrink'&gt;? || &lt;'flex-basis'&gt; ]</code></pre>
<h4>align-self  (Applies to: child element / flex item)</h4>
<p>This allows the default alignment or the one specified by <code>align-items</code> to be overridden for individual flex items.</p>
<p>Please see the <code>align-items</code> explanation to understand the available values.</p>
<pre><code class="language-css">align-self: auto | flex-start | flex-end | center | baseline | stretch</code></pre>
<h3>Examples</h3>
<p>Let's start with a very very simple example, solving an almost daily problem: perfect centering. It couldn't be any simpler if you use flexbox.</p>
<pre><code class="language-css">.parent {
  display: flex;
  height: 300px; /* Or whatever */
}

.child {
  width: 100px;  /* Or whatever */
  height: 100px; /* Or whatever */
  margin: auto;  /* Magic! */
}</code></pre>
<p>This relies on the fact a margin set to `auto` in a flex container absorb extra space. So setting a vertical margin of <code>auto</code> will make the item perfectly centered in both axis.</p>
<p>Now let's use some more properties. Consider a list of 6 items, all with a fixed dimensions in a matter of aesthetics but they could be auto-sized. We want them to be evenly and nicely distributed on the horizontal axis so that when we resize the browser, everything is fine (without media queries!).</p>
<pre><code class="language-css">.flex-container {
  /* We first create a flex layout context */
  display: flex;
  
  /* Then we define the flow direction and if we allow the items to wrap 
   * Remember this is the same as:
   * flex-direction: row;
   * flex-wrap: wrap;
   */
  flex-flow: row wrap;
  
  /* Then we define how is distributed the remaining space */
  justify-content: space-around;
}</code></pre>
<p>Done. Everything else is just some styling concern. Below is a pen featuring this example. Be sure to go to CodePen and try resizing your windows to see what happen.</p>
<pre class="codepen"><code></code><a rel="nofollow" target="_blank" href="http://codepen.io/HugoGiraudel/pen/LklCv">Check out this Pen!</a></pre>
<p>Let's try something else. Imagine we have a right-aligned navigation on the very top of our website, but we want it to be centered on medium-sized screens and single-columned on small devices. Easy enough.</p>
<pre><code class="language-css">/* Large */
.navigation {
  display: flex;
  flex-flow: row wrap;
  /* This aligns items to the end line on main-axis */
  justify-content: flex-end;
}

/* Medium screens */
@media all and (max-width: 800px) {
  .navigation {
    /* When on medium sized screens, we center it by evenly distributing empty space around items */
    justify-content: space-around;
  }
}

/* Small screens */
@media all and (max-width: 500px) {
  .navigation {
    /* On small screens, we are no longer using row direction but column */
    flex-direction: column;
  }
}</code></pre>
<pre class="codepen"><code></code><a rel="nofollow" target="_blank" href="http://codepen.io/HugoGiraudel/pen/pkwqH">Check out this Pen!</a></pre>
<p>Let's try something even better by playing with flex items flexibility! What about a mobile-first 3-columns layout with full-width header and footer. And independent from source order.</p>
<pre><code class="language-css">.wrapper {
  display: flex;
  flex-flow: row wrap;
}

/* We tell all items to be 100% width */
.header, .main, .nav, .aside, .footer {
  flex: 1 100%;
}

/* We rely on source order for mobile-first approach
 * in this case:
 * 1. header
 * 2. nav
 * 3. main
 * 4. aside
 * 5. footer
 */

/* Medium screens */
@media all and (min-width: 600px) {
  /* We tell both sidebars to share a row */
  .aside { flex: 1 auto; }
}

/* Large screens */
@media all and (min-width: 800px) {
  /* We invert order of first sidebar and main
   * And tell the main element to take twice as much width as the other two sidebars 
   */
  .main { flex: 2 0px; }
  
  .aside-1 { order: 1; }
  .main    { order: 2; }
  .aside-2 { order: 3; }
  .footer  { order: 4; }
}</code></pre>
<pre class="codepen"><code></code><a rel="nofollow" target="_blank" href="http://codepen.io/HugoGiraudel/pen/qIAwr">Check out this Pen!</a></pre>
<h3>Related Properties</h3>
<ul>
<li><a rel="nofollow" target="_blank" href="http://css-tricks.com/almanac/properties/g/grid/">Grid</a></li>
</ul>
<h3>Other Resources</h3>
<ul>
<li><a rel="nofollow" target="_blank" href="http://www.w3.org/TR/css3-flexbox/">Flexbox in the CSS specifications</a></li>
<li><a rel="nofollow" target="_blank" href="https://developer.mozilla.org/en-US/docs/CSS/Tutorials/Using_CSS_flexible_boxes">Flexbox at MDN</a></li>
<li><a rel="nofollow" target="_blank" href="http://dev.opera.com/articles/view/flexbox-basics/">Flexbox at Opera</a></li>
<li><a rel="nofollow" target="_blank" href="http://weblog.bocoup.com/dive-into-flexbox/">Diving into Flexbox by Bocoup</a></li>
<li><a rel="nofollow" target="_blank" href="http://css-tricks.com/using-flexbox/">Mixing syntaxes for best browser support on CSS-Tricks</a></li>
<li><a rel="nofollow" target="_blank" href="http://www.alsacreations.com/tuto/lire/1493-css3-flexbox-layout-module.html">Flexbox by Raphael Goetter (FR)</a></li>
<li><a rel="nofollow" target="_blank" href="http://bennettfeely.com/flexplorer/">Flexplorer by Bennett Feely</a></li>
</ul>
<h3 id="browser-support">Browser Support</h3>
<ul>
<li>(modern) means the recent syntax from the specification (e.g. <code>display: flex;</code>)</li>
<li>(hybrid) means an odd unofficial syntax from 2011 (e.g. <code>display: flexbox;</code>)</li>
<li>(old) means the old syntax from 2009 (e.g. <code>display: box;</code>)</li>
</ul>
<table class="browser-support-table">
<thead>
<tr>
<th class="chrome"><span>Chrome</span></th>
<th class="safari"><span>Safari</span></th>
<th class="firefox"><span>Firefox</span></th>
<th class="opera"><span>Opera</span></th>
<th class="ie"><span>IE</span></th>
<th class="android"><span>Android</span></th>
<th class="iOS"><span>iOS</span></th>
</tr>
</thead>
<tbody>
<tr>
<td class="yep">21+ (modern)<br />20- (old)</td>
<td class="yep">3.1+ (old)</td>
<td class="yep">2-21 (old)<br /> 22+ (new)</td>
<td class="yep">12.1+ (modern)</td>
<td class="yep">10+ (hybrid)</td>
<td class="yep">2.1+ (old)</td>
<td class="yep">3.2+ (old)</td>
</tr>
</tbody>
</table>
<p>Blackberry browser 10+ supports the new syntax.</p>
<p>For more informations about how to mix syntaxes in order to get the best browser support, please refer to <a rel="nofollow" target="_blank" href="http://css-tricks.com/using-flexbox/">this article (CSS-Tricks)</a> or <a rel="nofollow" target="_blank" href="http://dev.opera.com/articles/view/advanced-cross-browser-flexbox/#fallbacks">this article (DevOpera)</a>.</p>
<p>A Sass @mixin to help ease the pain:</p>
<pre><code class="language-css">@mixin flexbox() {
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}

@mixin flex($values) {
  -webkit-box-flex: $values;
  -moz-box-flex:  $values;
  -webkit-flex:  $values;
  -ms-flex:  $values;
  flex:  $values;
}

@mixin order($val) {
  -webkit-box-ordinal-group: $val;  
  -moz-box-ordinal-group: $val;     
  -ms-flex-order: $val;     
  -webkit-order: $val;  
  order: $val;
}

.wrapper {
  @include flexbox();
}

.item {
  @include flex(1 200px);
  @include order(2);
}</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/xF5lU44p338" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/css/a-guide-to-flexbox/</feedburner:origLink></item>
      <item>
         <title>Track Window Resizes through Google Analytics</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/uyhlYYk-Q-U/</link>
         <description>&lt;p&gt;Sparkbox &lt;a rel="nofollow" target="_blank" href="http://seesparkbox.com/foundry/google_analytics_and_the_resize_event"&gt;has this snippet&lt;/a&gt; to help figure out how often browser windows really are resized.&lt;/p&gt;
&lt;code class="language-javascript"&gt;(function() {
  var resizeTimer;
  
  // Assuming we have jQuery present
  $( window ).on( "resize", function() {
    
    // Use resizeTimer to throttle the resize handler
    clearTimeout( resizeTimer );
    resizeTimer = setTimeout(function() {

     /* Send the event to Google Analytics
      *
      * https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEventTracking
      * _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)   
      */
      var $window = $( window );
      _gaq.push( [ "_trackEvent", "User Actions", "Browser Resize", $window.width() + " x &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=21004</guid>
         <pubDate>Wed, 03 Apr 2013 17:24:09 +0000</pubDate>
         <content:encoded><![CDATA[<p>Sparkbox <a rel="nofollow" target="_blank" href="http://seesparkbox.com/foundry/google_analytics_and_the_resize_event">has this snippet</a> to help figure out how often browser windows really are resized.</p>
<pre><code class="language-javascript">(function() {
  var resizeTimer;
  
  // Assuming we have jQuery present
  $( window ).on( "resize", function() {
    
    // Use resizeTimer to throttle the resize handler
    clearTimeout( resizeTimer );
    resizeTimer = setTimeout(function() {

     /* Send the event to Google Analytics
      *
      * https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEventTracking
      * _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)   
      */
      var $window = $( window );
      _gaq.push( [ "_trackEvent", "User Actions", "Browser Resize", $window.width() + " x " + $window.height() ] );
    }, 1000);
  });
})();</code></pre>
<p>Note how easy it is to track events in Google Analytics. That can be used for just about anything.</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/uyhlYYk-Q-U" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/jquery/track-window-resizes-through-google-analytics/</feedburner:origLink></item>
      <item>
         <title>Test if dragenter/dragover Event Contains Files</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/Spe5kq0JU3Y/</link>
         <description>&lt;p&gt;HTML5 drag and drop is great for handling file uploads. But if that's the only thing you are using it for, it's nice to know if any particular &lt;code&gt;dragenter&lt;/code&gt; or &lt;code&gt;dragover&lt;/code&gt; event actually has files. Unlike, for example, just the dragging of some selected text.&lt;/p&gt;
&lt;p&gt;Send the event object to this function and it will return the truth (assuming you are in a browser that &lt;a rel="nofollow" target="_blank" href="http://caniuse.com/#feat=dragndrop"&gt;supports all this&lt;/a&gt;):&lt;/p&gt;
&lt;code class="language-javascript"&gt;function containsFiles(event) {

    if (event.dataTransfer.types) {
        for (var i = 0; &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=20786</guid>
         <pubDate>Tue, 26 Mar 2013 00:20:28 +0000</pubDate>
         <content:encoded><![CDATA[<p>HTML5 drag and drop is great for handling file uploads. But if that's the only thing you are using it for, it's nice to know if any particular <code>dragenter</code> or <code>dragover</code> event actually has files. Unlike, for example, just the dragging of some selected text.</p>
<p>Send the event object to this function and it will return the truth (assuming you are in a browser that <a rel="nofollow" target="_blank" href="http://caniuse.com/#feat=dragndrop">supports all this</a>):</p>
<pre><code class="language-javascript">function containsFiles(event) {

    if (event.dataTransfer.types) {
        for (var i = 0; i &lt; event.dataTransfer.types.length; i++) {
            if (event.dataTransfer.types[i] == "Files") {
                return true;
            }
        }
    }
    
    return false;

}</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/Spe5kq0JU3Y" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/javascript/test-if-dragenterdragover-event-contains-files/</feedburner:origLink></item>
      <item>
         <title>Shrink the Admin Bar / Expand on Hover</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/twMuMxshWBs/</link>
         <description>&lt;p&gt;A mini plugin:&lt;/p&gt;
&lt;code class="language-markup"&gt;&amp;#60;?php
/*
 * Plugin Name: Mini Admin Bar
 * Plugin URI: http://www.netyou.co.il/
 * Description: Makes the admin bar a small button on the left and expands on hover.
 * Version: 1.0
 * Author: NetYou
 * Author URI: http://www.netyou.co.il/
 * License: MIT
 * Copyright: NetYou
*/
 
add_action('get_header', 'my_filter_head');
function my_filter_head() { remove_action('wp_head', '_admin_bar_bump_cb'); }
 
function my_admin_css() {
        if ( is_user_logged_in() ) {
        ?&amp;#62;
        &amp;#60;style type="text/css"&amp;#62;
            #wpadminbar {
                width: 47px;
                min-width: auto;
                overflow: hidden;
                -webkit-transition: .4s width;
                -webkit-transition-delay: 1s;
                &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=20775</guid>
         <pubDate>Mon, 25 Mar 2013 21:36:48 +0000</pubDate>
         <content:encoded><![CDATA[<p>A mini plugin:</p>
<pre><code class="language-markup">&lt;?php
/*
 * Plugin Name: Mini Admin Bar
 * Plugin URI: http://www.netyou.co.il/
 * Description: Makes the admin bar a small button on the left and expands on hover.
 * Version: 1.0
 * Author: NetYou
 * Author URI: http://www.netyou.co.il/
 * License: MIT
 * Copyright: NetYou
*/
 
add_action('get_header', 'my_filter_head');
function my_filter_head() { remove_action('wp_head', '_admin_bar_bump_cb'); }
 
function my_admin_css() {
        if ( is_user_logged_in() ) {
        ?&gt;
        &lt;style type="text/css"&gt;
            #wpadminbar {
                width: 47px;
                min-width: auto;
                overflow: hidden;
                -webkit-transition: .4s width;
                -webkit-transition-delay: 1s;
                -moz-transition: .4s width;
                -moz-transition-delay: 1s;
                -o-transition: .4s width;
                -o-transition-delay: 1s;
                -ms-transition: .4s width;
                -ms-transition-delay: 1s;
                transition: .4s width;
                transition-delay: 1s;
            }
            
            #wpadminbar:hover {
                width: 100%;
                overflow: visible;
                -webkit-transition-delay: 0;
                -moz-transition-delay: 0;
                -o-transition-delay: 0;
                -ms-transition-delay: 0;
                transition-delay: 0;
            }
        &lt;/style&gt;
        &lt;?php }
}
add_action('wp_head', 'my_admin_css');

?&gt;</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/twMuMxshWBs" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/wordpress/shrink-the-admin-bar-expand-on-hover/</feedburner:origLink></item>
      <item>
         <title>Fix IE 10 on Windows Phone 8 Viewport</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/wuyZxxmKD_k/</link>
         <description>&lt;code class="language-javascript"&gt;(function() {
  if (navigator.userAgent.match(/IEMobile&amp;#92;/10&amp;#92;.0/)) {
    var msViewportStyle = document.createElement("style");
    msViewportStyle.appendChild(
      document.createTextNode("@-ms-viewport{width:auto!important}")
    );
    document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
  }
})();&lt;/code&gt;
&lt;h4&gt;Quick backstory&lt;/h4&gt;
&lt;p&gt;For IE 10 (desktop) to work in it's new "snap mode" you need to use this:&lt;/p&gt;
&lt;code class="language-css"&gt;@-ms-viewport {
  width: device-width;
}&lt;/code&gt;
&lt;p&gt;But that screws up some Windows Phone 8 phones, overriding the meta viewport tag and rendering as far too large on small screens. So the answer, for now, is this gnarly device detection/injection script.&lt;/p&gt;
&lt;h4&gt;Longer backstory&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Matt Stow: &lt;a rel="nofollow" target="_blank" href="http://mattstow.com/responsive-design-in-ie10-on-windows-phone-8.html"&gt;Responsive Design in IE10 &lt;/a&gt;&lt;/li&gt;&amp;#8230;&lt;/ul&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=19994</guid>
         <pubDate>Sun, 27 Jan 2013 17:02:36 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code class="language-javascript">(function() {
  if (navigator.userAgent.match(/IEMobile&#92;/10&#92;.0/)) {
    var msViewportStyle = document.createElement("style");
    msViewportStyle.appendChild(
      document.createTextNode("@-ms-viewport{width:auto!important}")
    );
    document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
  }
})();</code></pre>
<h4>Quick backstory</h4>
<p>For IE 10 (desktop) to work in it's new "snap mode" you need to use this:</p>
<pre><code class="language-css">@-ms-viewport {
  width: device-width;
}</code></pre>
<p>But that screws up some Windows Phone 8 phones, overriding the meta viewport tag and rendering as far too large on small screens. So the answer, for now, is this gnarly device detection/injection script.</p>
<h4>Longer backstory</h4>
<ul>
<li>Matt Stow: <a rel="nofollow" target="_blank" href="http://mattstow.com/responsive-design-in-ie10-on-windows-phone-8.html">Responsive Design in IE10 on Windows Phone 8</a></li>
<li>Tim Kadlec: <a rel="nofollow" target="_blank" href="http://timkadlec.com/2013/01/windows-phone-8-and-device-width/">Windows Phone 8 and Device-Width</a></li>
</ul><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/wuyZxxmKD_k" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/javascript/fix-ie-10-on-windows-phone-8-viewport/</feedburner:origLink></item>
      <item>
         <title>Clear a File Input</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/jN9s2n1e5yI/</link>
         <description>&lt;p&gt;You can just clone it and replace it with itself, with all events still attached.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;code class="language-javascript"&gt;var input = $("#control");

function something_happens() {
    input.replaceWith(input.val('').clone(true));
};&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=19886</guid>
         <pubDate>Wed, 16 Jan 2013 21:20:28 +0000</pubDate>
         <content:encoded><![CDATA[<p>You can just clone it and replace it with itself, with all events still attached.</p>
<p><input type="file" id="control"></p>
<pre><code class="language-javascript">var input = $("#control");

function something_happens() {
    input.replaceWith(input.val('').clone(true));
};</code></pre>
<pre class="codepen"></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/jN9s2n1e5yI" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/jquery/clear-a-file-input/</feedburner:origLink></item>
      <item>
         <title>Strip Whitespace From String</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/W2f37pchJJI/</link>
         <description>&lt;p&gt;Whitespace, meaning tabs and spaces.&lt;/p&gt;
&lt;code class="language-javascript"&gt;// Remove leading and trailing whitespace
// Requires jQuery
var str = " a b    c d e f g ";
var newStr = $.trim(str);
// "a b c d e f g"

// Remove leading and trailing whitespace
// JavaScript RegEx
var str = "   a b    c d e f g ";
var newStr = str.replace(/(^&amp;#92;s+&amp;#124;&amp;#92;s+$)/g,'');
// "a b c d e f g"

// Remove all whitespace
// JavaScript RegEx
var str &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=19750</guid>
         <pubDate>Sat, 05 Jan 2013 14:46:36 +0000</pubDate>
         <content:encoded><![CDATA[<p>Whitespace, meaning tabs and spaces.</p>
<pre><code class="language-javascript">// Remove leading and trailing whitespace
// Requires jQuery
var str = " a b    c d e f g ";
var newStr = $.trim(str);
// "a b c d e f g"

// Remove leading and trailing whitespace
// JavaScript RegEx
var str = "   a b    c d e f g ";
var newStr = str.replace(/(^&#92;s+|&#92;s+$)/g,'');
// "a b c d e f g"

// Remove all whitespace
// JavaScript RegEx
var str = " a b    c d e   f g   ";
var newStr = str.replace(/&#92;s+/g, '');
// "abcdefg"</code></pre>
<pre class="codepen"><code></code></pre>
<p>Doesn't work with other types of whitespace though, for instance &amp;#8239; (thin space) or &amp;nbsp; (non-breaking space)</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/W2f37pchJJI" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/javascript/strip-whitespace-from-string/</feedburner:origLink></item>
      <item>
         <title>Lighten / Darken Color</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/H3GhsqgbxVE/</link>
         <description>&lt;p&gt;The CSS preprocessors Sass and LESS can take any color and darken() or lighten() it by a specific value. But no such ability is built into JavaScript. This function takes colors in hex format (i.e. #F06D06, with or without hash) and lightens or darkens them with a value.&lt;/p&gt;
&lt;code class="language-javascript"&gt;function LightenDarkenColor(col, amt) {
  
    var usePound = false;
  
    if (col[0] == "#") {
        col = col.slice(1);
        usePound = true;
    }
 
    var num = parseInt(col,16);
 
    var r = (num &amp;#62;&amp;#62; 16) + amt;
 
    &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=19646</guid>
         <pubDate>Tue, 01 Jan 2013 14:45:54 +0000</pubDate>
         <content:encoded><![CDATA[<p>The CSS preprocessors Sass and LESS can take any color and darken() or lighten() it by a specific value. But no such ability is built into JavaScript. This function takes colors in hex format (i.e. #F06D06, with or without hash) and lightens or darkens them with a value.</p>
<pre><code class="language-javascript">function LightenDarkenColor(col, amt) {
  
    var usePound = false;
  
    if (col[0] == "#") {
        col = col.slice(1);
        usePound = true;
    }
 
    var num = parseInt(col,16);
 
    var r = (num &gt;&gt; 16) + amt;
 
    if (r &gt; 255) r = 255;
    else if  (r &lt; 0) r = 0;
 
    var b = ((num &gt;&gt; 8) &amp; 0x00FF) + amt;
 
    if (b &gt; 255) b = 255;
    else if  (b &lt; 0) b = 0;
 
    var g = (num &amp; 0x0000FF) + amt;
 
    if (g &gt; 255) g = 255;
    else if (g &lt; 0) g = 0;
 
    return (usePound?"#":"") + (g | (b &lt;&lt; 8) | (r &lt;&lt; 16)).toString(16);
  
}</code></pre>
<h4>Usage</h4>
<pre><code class="language-javascript">// Lighten
var NewColor = LightenDarkenColor("#F06D06", 20); 

// Darken
var NewColor = LightenDarkenColor("#F06D06", -20); </code></pre>
<h4>Demo</h4>
<pre class="codepen"><code></code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/H3GhsqgbxVE" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/javascript/lighten-darken-color/</feedburner:origLink></item>
      <item>
         <title>Inject New CSS Rules</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/Y3r8r-zaZBg/</link>
         <description>&lt;p&gt;If you need to change the style of an element with JavaScript, it's typically better to change a class name and have the CSS already on the page take effect and change the style. However, there are exceptions to every rule. For instance, you might want to programmatically change the a pseudo class (e.g. &lt;code&gt;:hover&lt;/code&gt;). You can't do that through JavaScript for the same reason inline &lt;code&gt;style=""&lt;/code&gt; attributes can't change pseudo classes.&lt;/p&gt;
&lt;p&gt;You'll need to inject a new &lt;code&gt;&amp;#60;style&amp;#62;&lt;/code&gt;&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=19644</guid>
         <pubDate>Tue, 01 Jan 2013 14:35:29 +0000</pubDate>
         <content:encoded><![CDATA[<p>If you need to change the style of an element with JavaScript, it's typically better to change a class name and have the CSS already on the page take effect and change the style. However, there are exceptions to every rule. For instance, you might want to programmatically change the a pseudo class (e.g. <code>:hover</code>). You can't do that through JavaScript for the same reason inline <code>style=""</code> attributes can't change pseudo classes.</p>
<p>You'll need to inject a new <code>&lt;style&gt;</code> element onto the page with the correct styles in it. Best to inject it at the bottom of the page so it overrides your CSS above it. Easy with jQuery:</p>
<pre><code class="language-javascript">function injectStyles(rule) {
  var div = $("&lt;div /&gt;", {
    html: '&amp;shy;&lt;style&gt;' + rule + '&lt;/style&gt;'
  }).appendTo("body");    
}</code></pre>
<h4>Usage</h4>
<pre><code class="language-javascript">injectStyles('a:hover { color: red; }');</code></pre>
<h4>Demo</h4>
<pre class="codepen"><code></code></pre>
<h4>More Information</h4>
<ul>
<li><a rel="nofollow" target="_blank" href="http://www.thecssninja.com/javascript/noscope">Style injection quirks in IE</a> (Ryan Seddon).</li>
<li><a rel="nofollow" target="_blank" href="http://stackoverflow.com/questions/311052/setting-css-pseudo-class-rules-from-javascript/14106897">Stack Overflow thread</a>.</li>
</ul><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/Y3r8r-zaZBg" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/javascript/inject-new-css-rules/</feedburner:origLink></item>
      <item>
         <title>Insert Images within Figure Element from Media Uploader</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/CxKZeqRYesw/</link>
         <description>&lt;p&gt;For your functions.php file or a functionality plugin:&lt;/p&gt;
&lt;code class="language-javascript"&gt;function html5_insert_image($html, $id, $caption, $title, $align, $url) {
  $html5 = "&amp;#60;figure id='post-$id media-$id' class='align-$align'&amp;#62;";
  $html5 .= "&amp;#60;img src='$url' alt='$title' /&amp;#62;";
  if ($caption) {
    $html5 .= "&amp;#60;figcaption&amp;#62;$caption&amp;#60;/figcaption&amp;#62;";
  }
  $html5 .= "&amp;#60;/figure&amp;#62;";
  return $html5;
}
add_filter( 'image_send_to_editor', 'html5_insert_image', 10, 9 );&lt;/code&gt;
&lt;p&gt;It also takes what you enter as a caption and inserts it within the &lt;code&gt;&amp;#60;figure&amp;#62;&lt;/code&gt; tag as a &lt;code&gt;&amp;#60;figcaption&amp;#62;&lt;/code&gt;. Example inserted code:&lt;/p&gt;
&lt;code class="language-markup"&gt;&amp;#60;figure id='post-18838 media-18838' class='align-none'&amp;#62;
  &amp;#60;img src='http://youresite.com/wp-content/uploads/2012/10/image.png' alt='Title of image'&amp;#62;
  &amp;#60;figcaption&amp;#62;Caption &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=18895</guid>
         <pubDate>Fri, 12 Oct 2012 15:32:21 +0000</pubDate>
         <content:encoded><![CDATA[<p>For your functions.php file or a functionality plugin:</p>
<pre><code class="language-javascript">function html5_insert_image($html, $id, $caption, $title, $align, $url) {
  $html5 = "&lt;figure id='post-$id media-$id' class='align-$align'&gt;";
  $html5 .= "&lt;img src='$url' alt='$title' /&gt;";
  if ($caption) {
    $html5 .= "&lt;figcaption&gt;$caption&lt;/figcaption&gt;";
  }
  $html5 .= "&lt;/figure&gt;";
  return $html5;
}
add_filter( 'image_send_to_editor', 'html5_insert_image', 10, 9 );</code></pre>
<p>It also takes what you enter as a caption and inserts it within the <code>&lt;figure&gt;</code> tag as a <code>&lt;figcaption&gt;</code>. Example inserted code:</p>
<pre><code class="language-markup">&lt;figure id='post-18838 media-18838' class='align-none'&gt;
  &lt;img src='http://youresite.com/wp-content/uploads/2012/10/image.png' alt='Title of image'&gt;
  &lt;figcaption&gt;Caption for image&lt;/figcaption&gt;
&lt;/figure&gt;</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/CxKZeqRYesw" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/wordpress/insert-images-within-figure-element-from-media-uploader/</feedburner:origLink></item>
      <item>
         <title>Remove Admin Bar For Subscribers</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/wNnul--2-TI/</link>
         <description>&lt;p&gt;You might want open registration on your WordPress site so that (for one small example) people can log in and leave comments on things without needing to type their name/url/email every time. But these users probably don't need to see the whole top admin bar as there likely isn't much use in it for them. Although do be sure to provide a link to edit their profile and log out.&lt;/p&gt;
&lt;p&gt;This would be for your functions.php file or functionality plugin:&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=18892</guid>
         <pubDate>Fri, 12 Oct 2012 15:25:54 +0000</pubDate>
         <content:encoded><![CDATA[<p>You might want open registration on your WordPress site so that (for one small example) people can log in and leave comments on things without needing to type their name/url/email every time. But these users probably don't need to see the whole top admin bar as there likely isn't much use in it for them. Although do be sure to provide a link to edit their profile and log out.</p>
<p>This would be for your functions.php file or functionality plugin:</p>
<pre><code class="language-javascript">add_action('set_current_user', 'cc_hide_admin_bar');
function cc_hide_admin_bar() {
  if (!current_user_can('edit_posts')) {
    show_admin_bar(false);
  }
}</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/wNnul--2-TI" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/wordpress/remove-admin-bar-for-subscribers/</feedburner:origLink></item>
      <item>
         <title>Allow SVG through WordPress Media Uploader</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/BZsjp3H4aJQ/</link>
         <description>&lt;p&gt;For your functions.php file or a functionality plugin:&lt;/p&gt;
&lt;code class="language-javascript"&gt;function cc_mime_types( $mimes ){
	$mimes['svg'] = 'image/svg+xml';
	return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );&lt;/code&gt;
&lt;p&gt;Without this, SVG files will be rejected when attempting to upload them through the media uploader.&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=18883</guid>
         <pubDate>Fri, 12 Oct 2012 00:20:24 +0000</pubDate>
         <content:encoded><![CDATA[<p>For your functions.php file or a functionality plugin:</p>
<pre><code class="language-javascript">function cc_mime_types( $mimes ){
	$mimes['svg'] = 'image/svg+xml';
	return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );</code></pre>
<p>Without this, SVG files will be rejected when attempting to upload them through the media uploader.</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/BZsjp3H4aJQ" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/wordpress/allow-svg-through-wordpress-media-uploader/</feedburner:origLink></item>
      <item>
         <title>Turn Off Number Input Spinners</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/ghTuLXNV-NA/</link>
         <description>&lt;p&gt;WebKit desktop browsers add little up down arrows to number inputs called spinners. You can turn them off visually like this:&lt;/p&gt;
&lt;code class="language-css"&gt;input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}&lt;/code&gt;
&lt;p&gt;Note that some other functionality still exists, like being able to increment the number via the scroll wheel on a mouse.&amp;#8230;&lt;/p&gt;

Top, on, Bottom, off.</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=18880</guid>
         <pubDate>Fri, 12 Oct 2012 00:11:17 +0000</pubDate>
         <content:encoded><![CDATA[<p>WebKit desktop browsers add little up down arrows to number inputs called spinners. You can turn them off visually like this:</p>
<pre><code class="language-css">input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}</code></pre>
<p>Note that some other functionality still exists, like being able to increment the number via the scroll wheel on a mouse.</p>
<img src='http://cdn.css-tricks.com/wp-content/uploads/2012/10/Screen-Shot-2012-10-11-at-5.09.17-PM.png' alt='Screen Shot 2012-10-11 at 5.09.17 PM'/>
 Top, on, Bottom, off.<img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/ghTuLXNV-NA" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/css/turn-off-number-input-spinners/</feedburner:origLink></item>
      <item>
         <title>HTTP or HTTPS</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/F8wNBX25-Ys/</link>
         <description>&lt;code class="language-markup"&gt;if (!empty($_SERVER['HTTPS']) &amp;#38;&amp;#38; $_SERVER['HTTPS'] !== 'off'
    &amp;#124;&amp;#124; $_SERVER['SERVER_PORT'] == 443) {

  // HTTPS

} else {

  // HTTP

}&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=18098</guid>
         <pubDate>Fri, 07 Sep 2012 23:11:37 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code class="language-markup">if (!empty($_SERVER['HTTPS']) &amp;&amp; $_SERVER['HTTPS'] !== 'off'
    || $_SERVER['SERVER_PORT'] == 443) {

  // HTTPS

} else {

  // HTTP

}</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/F8wNBX25-Ys" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/php/http-or-https/</feedburner:origLink></item>
      <item>
         <title>Get Width/Height of Image</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/CNsoFdYClTY/</link>
         <description>&lt;p&gt;If all you have for an image is the URL, you can still find the dimensions:&lt;/p&gt;
&lt;code&gt;&amp;#60;?php

  list($width, $height, $type, $attr) = getimagesize("url/to/image.jpg");

  echo "Image width " . $width;
  echo "Image height " . $height;
  echo "Image type " . $type;
  echo "Attribute " . $attr;

?&amp;#62;&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17780</guid>
         <pubDate>Sat, 18 Aug 2012 17:19:22 +0000</pubDate>
         <content:encoded><![CDATA[<p>If all you have for an image is the URL, you can still find the dimensions:</p>
<pre class="lang-php"><code>&lt;?php

  list($width, $height, $type, $attr) = getimagesize("url/to/image.jpg");

  echo "Image width " . $width;
  echo "Image height " . $height;
  echo "Image type " . $type;
  echo "Attribute " . $attr;

?&gt;</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/CNsoFdYClTY" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/php/get-widthheight-of-image/</feedburner:origLink></item>
      <item>
         <title>Retina Display Media Query</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/mU8nI5r5ws4/</link>
         <description>&lt;p&gt;For including high-res graphics, but only for screens that can make use of them. "Retina" being "2x":&lt;/p&gt;
&lt;code class="language-css"&gt;@media 
(-webkit-min-device-pixel-ratio: 2), 
(min-resolution: 192dpi) { 
    /* Retina-specific stuff here */
}&lt;/code&gt;
&lt;p&gt;Or other highish-res:&lt;/p&gt;
&lt;code class="language-css"&gt;/* 1.25 dpr */
@media 
(-webkit-min-device-pixel-ratio: 1.25), 
(min-resolution: 120dpi){ 
    /* Retina-specific stuff here */
}

/* 1.3 dpr */
@media 
(-webkit-min-device-pixel-ratio: 1.3), 
(min-resolution: 124.8dpi){ 
    /* Retina-specific stuff here */
}

/* 1.5 dpr */
@media 
(-webkit-min-device-pixel-ratio: 1.5), 
(min-resolution: 144dpi){ 
    /* Retina-specific stuff here */
}&amp;#8230;&lt;/code&gt;
Old Stuff (don't</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17757</guid>
         <pubDate>Thu, 16 Aug 2012 03:53:27 +0000</pubDate>
         <content:encoded><![CDATA[<p>For including high-res graphics, but only for screens that can make use of them. "Retina" being "2x":</p>
<pre><code class="language-css">@media 
(-webkit-min-device-pixel-ratio: 2), 
(min-resolution: 192dpi) { 
    /* Retina-specific stuff here */
}</code></pre>
<p>Or other highish-res:</p>
<pre><code class="language-css">/* 1.25 dpr */
@media 
(-webkit-min-device-pixel-ratio: 1.25), 
(min-resolution: 120dpi){ 
    /* Retina-specific stuff here */
}

/* 1.3 dpr */
@media 
(-webkit-min-device-pixel-ratio: 1.3), 
(min-resolution: 124.8dpi){ 
    /* Retina-specific stuff here */
}

/* 1.5 dpr */
@media 
(-webkit-min-device-pixel-ratio: 1.5), 
(min-resolution: 144dpi){ 
    /* Retina-specific stuff here */
}</code></pre>
<h3>Old Stuff (don't use, keeping for posterity)</h3>
<pre class="lang-css"><code>@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (   min--moz-device-pixel-ratio: 2),
only screen and (     -o-min-device-pixel-ratio: 2/1) { 
  
  /* Retina-specific stuff here */

}</code></pre>
<p>This is more future proof...</p>
<pre class="lang-css"><code>@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (   min--moz-device-pixel-ratio: 2),
only screen and (     -o-min-device-pixel-ratio: 2/1),
only screen and (        min-device-pixel-ratio: 2),
only screen and (                min-resolution: 192dpi),
only screen and (                min-resolution: 2dppx) { 
  
  /* Retina-specific stuff here */

}</code></pre>
<p>Notes:</p>
<ul>
<li>The super weird <code>min--moz-device-pixel-ratio</code> is probably a bug, might wanna put in <code>-moz-min-device-pixel-ratio</code> also in case they fix it but leave it prefixed.</li>
<li>Here's the <a rel="nofollow" target="_blank" href="http://www.w3.org/TR/css3-values/#resolution">spec on resolution units</a>.</li>
</ul>
<p>Example:</p>
<p>Let's say you had three major breakpoints in a design. This design also had a large background graphic and you wanted it looking it's best on any screen (retina or not) and not waste any bandwidth. You'd set up 6 media queries, one for each breakpoint and one for each one of those breakpoints on retina. Then you'd override the background image all the way down.</p>
<pre><code class="language-css">@media only screen and (min-width: 320px) {

  /* Small screen, non-retina */

}

@media
only screen and (-webkit-min-device-pixel-ratio: 2)      and (min-width: 320px),
only screen and (   min--moz-device-pixel-ratio: 2)      and (min-width: 320px),
only screen and (     -o-min-device-pixel-ratio: 2/1)    and (min-width: 320px),
only screen and (        min-device-pixel-ratio: 2)      and (min-width: 320px),
only screen and (                min-resolution: 192dpi) and (min-width: 320px),
only screen and (                min-resolution: 2dppx)  and (min-width: 320px) { 

  /* Small screen, retina, stuff to override above media query */

}

@media only screen and (min-width: 700px) {

  /* Medium screen, non-retina */

}

@media
only screen and (-webkit-min-device-pixel-ratio: 2)      and (min-width: 700px),
only screen and (   min--moz-device-pixel-ratio: 2)      and (min-width: 700px),
only screen and (     -o-min-device-pixel-ratio: 2/1)    and (min-width: 700px),
only screen and (        min-device-pixel-ratio: 2)      and (min-width: 700px),
only screen and (                min-resolution: 192dpi) and (min-width: 700px),
only screen and (                min-resolution: 2dppx)  and (min-width: 700px) { 

  /* Medium screen, retina, stuff to override above media query */

}

@media only screen and (min-width: 1300px) {

  /* Large screen, non-retina */

}

@media
only screen and (-webkit-min-device-pixel-ratio: 2)      and (min-width: 1300px),
only screen and (   min--moz-device-pixel-ratio: 2)      and (min-width: 1300px),
only screen and (     -o-min-device-pixel-ratio: 2/1)    and (min-width: 1300px),
only screen and (        min-device-pixel-ratio: 2)      and (min-width: 1300px),
only screen and (                min-resolution: 192dpi) and (min-width: 1300px),
only screen and (                min-resolution: 2dppx)  and (min-width: 1300px) { 

  /* Large screen, retina, stuff to override above media query */

}</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/mU8nI5r5ws4" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/css/retina-display-media-query/</feedburner:origLink></item>
      <item>
         <title>Transparent Background Images</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/afGzBqQE1ls/</link>
         <description>&lt;p&gt;There is no CSS property background-opacity, but you can fake it by inserting a pseudo element with regular opacity the exact size of the element behind it. &lt;/p&gt;
&lt;code&gt;div {
    width: 200px;
    height: 200px;
    display: block;
    position: relative;
}

div:after {
    content: "";
    background: url(http://subtlepatterns.com/patterns/bo_play_pattern.png);
    opacity: 0.5;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    position: absolute;
    z-index: -1;   
}&lt;/code&gt;
&lt;code&gt;&lt;/code&gt;
&lt;p&gt;&lt;br /&gt;
​&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17657</guid>
         <pubDate>Sun, 05 Aug 2012 15:07:31 +0000</pubDate>
         <content:encoded><![CDATA[<p>There is no CSS property background-opacity, but you can fake it by inserting a pseudo element with regular opacity the exact size of the element behind it. </p>
<pre class="lang-css"><code>div {
    width: 200px;
    height: 200px;
    display: block;
    position: relative;
}

div:after {
    content: "";
    background: url(http://subtlepatterns.com/patterns/bo_play_pattern.png);
    opacity: 0.5;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    position: absolute;
    z-index: -1;   
}</code></pre>
<pre class="codepen"><code></code></pre>
<p><br />
​</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/afGzBqQE1ls" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/css/transparent-background-images/</feedburner:origLink></item>
      <item>
         <title>Import CSV into MySQL</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/rdxK4kHfOGQ/</link>
         <description>&lt;code&gt;&amp;#60;?php

$databasehost = "localhost";
$databasename = "test";
$databasetable = "sample";
$databaseusername ="test";
$databasepassword = "";
$fieldseparator = ",";
$lineseparator = "&amp;#92;n";
$csvfile = "filename.csv";

/********************************/
/* Would you like to add an ampty field at the beginning of these records?
/* This is useful if you have a table with the first field being an auto_increment integer
/* and the csv file does not have such as empty field before the records.
/* Set 1 for yes and 0 for &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17655</guid>
         <pubDate>Sun, 05 Aug 2012 14:51:53 +0000</pubDate>
         <content:encoded><![CDATA[<pre class="lang-php"><code>&lt;?php

$databasehost = "localhost";
$databasename = "test";
$databasetable = "sample";
$databaseusername ="test";
$databasepassword = "";
$fieldseparator = ",";
$lineseparator = "&#92;n";
$csvfile = "filename.csv";

/********************************/
/* Would you like to add an ampty field at the beginning of these records?
/* This is useful if you have a table with the first field being an auto_increment integer
/* and the csv file does not have such as empty field before the records.
/* Set 1 for yes and 0 for no. ATTENTION: don't set to 1 if you are not sure.
/* This can dump data in the wrong fields if this extra field does not exist in the table
/********************************/
$addauto = 0;
/********************************/

/* Would you like to save the mysql queries in a file? If yes set $save to 1.
/* Permission on the file should be set to 777. Either upload a sample file through ftp and
/* change the permissions, or execute at the prompt: touch output.sql &amp;&amp; chmod 777 output.sql
/********************************/
$save = 1;
$outputfile = "output.sql";
/********************************/

if (!file_exists($csvfile)) {
        echo "File not found. Make sure you specified the correct path.&#92;n";
        exit;
}

$file = fopen($csvfile,"r");

if (!$file) {
        echo "Error opening data file.&#92;n";
        exit;
}

$size = filesize($csvfile);

if (!$size) {
        echo "File is empty.&#92;n";
        exit;
}

$csvcontent = fread($file,$size);

fclose($file);

$con = @mysql_connect($databasehost,$databaseusername,$databasepassword) or die(mysql_error());
@mysql_select_db($databasename) or die(mysql_error());

$lines = 0;
$queries = "";
$linearray = array();

foreach(split($lineseparator,$csvcontent) as $line) {

        $lines++;

        $line = trim($line," &#92;t");

        $line = str_replace("&#92;r","",$line);

        /************************************
        This line escapes the special character. remove it if entries are already escaped in the csv file
        ************************************/
        $line = str_replace("'","&#92;'",$line);
        /*************************************/

        $linearray = explode($fieldseparator,$line);

        $linemysql = implode("','",$linearray);

        if($addauto)
                $query = "insert into $databasetable values('','$linemysql');";
        else
                $query = "insert into $databasetable values('$linemysql');";

        $queries .= $query . "&#92;n";

        @mysql_query($query);
}

@mysql_close($con);

if ($save) {

        if (!is_writable($outputfile)) {
                echo "File is not writable, check permissions.&#92;n";
        }

        else {
                $file2 = fopen($outputfile,"w");

                if(!$file2) {
                        echo "Error writing to the output file.&#92;n";
                }
                else {
                        fwrite($file2,$queries);
                        fclose($file2);
                }
        }

}

echo "Found a total of $lines records in this csv file.&#92;n";

?&gt;</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/rdxK4kHfOGQ" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/php/import-csv-into-mysql/</feedburner:origLink></item>
      <item>
         <title>Meta Tag to Prevent Search Engine Bots</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/OjXpMajEaF4/</link>
         <description>&lt;p&gt;To prevent all search bots from indexing a page:&lt;/p&gt;
&lt;code&gt;&amp;#60;meta name="robots" content="noindex"&amp;#62;&lt;/code&gt;
&lt;p&gt;To prevent just Google:&lt;/p&gt;
&lt;code&gt;&amp;#60;meta name="googlebot" content="noindex"&amp;#62;&lt;/code&gt;
&lt;p&gt;If you have control over it, you probably want to add nofollow to links that point to that page as well:&lt;/p&gt;
&lt;code&gt;&amp;#60;a href="privatepage.html" rel="nofollow"&amp;#62;Link to private page&amp;#60;/a&amp;#62;&lt;/code&gt;
&lt;p&gt;Theoretically that's not needed for Google, which claims to drop all pages with noindex from their directory. But there are more search engines out there and it doesn't hurt.&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17645</guid>
         <pubDate>Thu, 02 Aug 2012 02:17:17 +0000</pubDate>
         <content:encoded><![CDATA[<p>To prevent all search bots from indexing a page:</p>
<pre class="lang-html"><code>&lt;meta name="robots" content="noindex"&gt;</code></pre>
<p>To prevent just Google:</p>
<pre class="lang-html"><code>&lt;meta name="googlebot" content="noindex"&gt;</code></pre>
<p>If you have control over it, you probably want to add nofollow to links that point to that page as well:</p>
<pre class="lang-html"><code>&lt;a href="privatepage.html" rel="nofollow"&gt;Link to private page&lt;/a&gt;</code></pre>
<p>Theoretically that's not needed for Google, which claims to drop all pages with noindex from their directory. But there are more search engines out there and it doesn't hurt.</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/OjXpMajEaF4" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/html/meta-tag-to-prevent-search-engine-bots/</feedburner:origLink></item>
      <item>
         <title>Draggable without jQuery UI</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/LibSqUSZy3g/</link>
         <description>&lt;p&gt;It doesn't have all the fancy callbacks and options, but hey, it makes things draggable (and with a specified handle optionally). &lt;/p&gt;
&lt;code&gt;(function($) {
    $.fn.drags = function(opt) {

        opt = $.extend({handle:"",cursor:"move"}, opt);

        if(opt.handle === "") {
            var $el = this;
        } else {
            var $el = this.find(opt.handle);
        }

        return $el.css('cursor', opt.cursor).on("mousedown", function(e) {
            if(opt.handle === "") {
                var $drag = $(this).addClass('draggable');
            } else {
                var $drag = $(this).addClass('active-handle').parent().addClass('draggable');
            }
            var z_idx = $drag.css('z-index'),
                drg_h = $drag.outerHeight(),
                drg_w = $drag.outerWidth(),
                pos_y = &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17603</guid>
         <pubDate>Fri, 27 Jul 2012 17:38:46 +0000</pubDate>
         <content:encoded><![CDATA[<p>It doesn't have all the fancy callbacks and options, but hey, it makes things draggable (and with a specified handle optionally). </p>
<pre class="lang-js"><code>(function($) {
    $.fn.drags = function(opt) {

        opt = $.extend({handle:"",cursor:"move"}, opt);

        if(opt.handle === "") {
            var $el = this;
        } else {
            var $el = this.find(opt.handle);
        }

        return $el.css('cursor', opt.cursor).on("mousedown", function(e) {
            if(opt.handle === "") {
                var $drag = $(this).addClass('draggable');
            } else {
                var $drag = $(this).addClass('active-handle').parent().addClass('draggable');
            }
            var z_idx = $drag.css('z-index'),
                drg_h = $drag.outerHeight(),
                drg_w = $drag.outerWidth(),
                pos_y = $drag.offset().top + drg_h - e.pageY,
                pos_x = $drag.offset().left + drg_w - e.pageX;
            $drag.css('z-index', 1000).parents().on("mousemove", function(e) {
                $('.draggable').offset({
                    top:e.pageY + pos_y - drg_h,
                    left:e.pageX + pos_x - drg_w
                }).on("mouseup", function() {
                    $(this).removeClass('draggable').css('z-index', z_idx);
                });
            });
            e.preventDefault(); // disable selection
        }).on("mouseup", function() {
            if(opt.handle === "") {
                $(this).removeClass('draggable');
            } else {
                $(this).removeClass('active-handle').parent().removeClass('draggable');
            }
        });

    }
})(jQuery);</code></pre>
<h4>Usage</h4>
<pre class="lang-js"><code>$('div').drags();</code></pre>
<h4>Demo</h4>
<pre class="codepen"><code></code></pre>
<p></p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/LibSqUSZy3g" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/jquery/draggable-without-jquery-ui/</feedburner:origLink></item>
      <item>
         <title>Add Active Navigation Class Based on URL</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/PkMT4GOQgT0/</link>
         <description>&lt;p&gt;Ideally you output this class from the server side, but if you can't...   &lt;/p&gt;
&lt;p&gt;Let's say you have navigation like this:&lt;/p&gt;
&lt;code&gt;&amp;#60;nav&amp;#62;
	&amp;#60;ul&amp;#62;
		&amp;#60;li&amp;#62;&amp;#60;a href="/"&amp;#62;Home&amp;#60;/a&amp;#62;&amp;#60;/li&amp;#62;
		&amp;#60;li&amp;#62;&amp;#60;a href="/about/"&amp;#62;About&amp;#60;/a&amp;#62;&amp;#60;/li&amp;#62;
		&amp;#60;li&amp;#62;&amp;#60;a href="/clients/"&amp;#62;Clients&amp;#60;/a&amp;#62;&amp;#60;/li&amp;#62;
		&amp;#60;li&amp;#62;&amp;#60;a href="/contact/"&amp;#62;Contact Us&amp;#60;/a&amp;#62;&amp;#60;/li&amp;#62;
	&amp;#60;/ul&amp;#62;
&amp;#60;/nav&amp;#62;	&lt;/code&gt;
&lt;p&gt;And you are at the URL:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;http://yoursite.com/about/team/&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And you want the About link to get a class of "active" so you can visually indicate it's the active navigation.&lt;/p&gt;
&lt;code&gt;$(function() {
  $('nav a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active');
});&lt;/code&gt;
&lt;p&gt;Essentially that will match links in the nav who's href &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17550</guid>
         <pubDate>Tue, 17 Jul 2012 14:06:40 +0000</pubDate>
         <content:encoded><![CDATA[<p>Ideally you output this class from the server side, but if you can't...   </p>
<p>Let's say you have navigation like this:</p>
<pre class="lang-html"><code>&lt;nav&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href="/"&gt;Home&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="/about/"&gt;About&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="/clients/"&gt;Clients&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="/contact/"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/nav&gt;	</code></pre>
<p>And you are at the URL:</p>
<p><strong>http://yoursite.com/about/team/</strong></p>
<p>And you want the About link to get a class of "active" so you can visually indicate it's the active navigation.</p>
<pre class="lang-js"><code>$(function() {
  $('nav a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active');
});</code></pre>
<p>Essentially that will match links in the nav who's href attribute begins with "/about" (or whatever the secondary directory happens to be).</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/PkMT4GOQgT0" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/jquery/add-active-navigation-class-based-on-url/</feedburner:origLink></item>
      <item>
         <title>Video For Everybody (HTML5 Video with Flash Fallback)</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/AORm50bWcrs/</link>
         <description>&lt;code&gt;&amp;#60;!-- first try HTML5 playback: if serving as XML, expand `controls` to `controls="controls"` and autoplay likewise --&amp;#62;
&amp;#60;!-- warning: playback does not work on iOS3 if you include the poster attribute! fixed in iOS4.0 --&amp;#62;
&amp;#60;video width="640" height="360" controls&amp;#62;
	&amp;#60;!-- MP4 must be first for iPad! --&amp;#62;
	&amp;#60;source src="__VIDEO__.MP4" type="video/mp4" /&amp;#62;&amp;#60;!-- Safari / iOS video    --&amp;#62;
	&amp;#60;source src="__VIDEO__.OGV" type="video/ogg" /&amp;#62;&amp;#60;!-- Firefox / Opera / Chrome10 --&amp;#62;
	&amp;#60;!-- fallback to Flash: --&amp;#62;
	&amp;#60;object width="640" height="360" type="application/x-shockwave-flash" data="__FLASH__.SWF"&amp;#62;
		&amp;#60;!-- Firefox uses the &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17533</guid>
         <pubDate>Mon, 16 Jul 2012 00:04:05 +0000</pubDate>
         <content:encoded><![CDATA[<pre class="lang-html"><code>&lt;!-- first try HTML5 playback: if serving as XML, expand `controls` to `controls="controls"` and autoplay likewise --&gt;
&lt;!-- warning: playback does not work on iOS3 if you include the poster attribute! fixed in iOS4.0 --&gt;
&lt;video width="640" height="360" controls&gt;
	&lt;!-- MP4 must be first for iPad! --&gt;
	&lt;source src="__VIDEO__.MP4" type="video/mp4" /&gt;&lt;!-- Safari / iOS video    --&gt;
	&lt;source src="__VIDEO__.OGV" type="video/ogg" /&gt;&lt;!-- Firefox / Opera / Chrome10 --&gt;
	&lt;!-- fallback to Flash: --&gt;
	&lt;object width="640" height="360" type="application/x-shockwave-flash" data="__FLASH__.SWF"&gt;
		&lt;!-- Firefox uses the `data` attribute above, IE/Safari uses the param below --&gt;
		&lt;param name="movie" value="__FLASH__.SWF" /&gt;
		&lt;param name="flashvars" value="controlbar=over&amp;amp;image=__POSTER__.JPG&amp;amp;file=__VIDEO__.MP4" /&gt;
		&lt;!-- fallback image. note the title field below, put the title of the video there --&gt;
		&lt;img src="__VIDEO__.JPG" width="640" height="360" alt="__TITLE__"
		     title="No video playback capabilities, please download the video below" /&gt;
	&lt;/object&gt;
&lt;/video&gt;
&lt;!-- you *must* offer a download link as they may be able to play the file locally. customise this bit all you want --&gt;
&lt;p&gt;	&lt;strong&gt;Download Video:&lt;/strong&gt;
	Closed Format:	&lt;a href="__VIDEO__.MP4"&gt;"MP4"&lt;/a&gt;
	Open Format:	&lt;a href="__VIDEO__.OGV"&gt;"Ogg"&lt;/a&gt;
&lt;/p&gt;</code></pre>
<p><a rel="nofollow" target="_blank" href="http://camendesign.com/code/video_for_everybody">A complete explanation</a> at Kroc Camen's site, the originator of this technique.</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/AORm50bWcrs" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/html/video-for-everybody-html5-video-with-flash-fallback/</feedburner:origLink></item>
      <item>
         <title>Generate Expiring Amazon S3 Link</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/jUMpT8QZnbI/</link>
         <description>&lt;p&gt;You don't have to make files on Amazon S3 public (they aren't by default). But you can generate special keys to allow access to private files. These keys are passed through the URL and can be made to expire. &lt;/p&gt;
&lt;code&gt;&amp;#60;?php 

  if(!function_exists('el_crypto_hmacSHA1')){
    /**
    * Calculate the HMAC SHA1 hash of a string.
    *
    * @param string $key The key to hash against
    * @param string $data The data to hash
    * @param int $blocksize Optional blocksize
    * @return string HMAC SHA1
    &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17382</guid>
         <pubDate>Tue, 03 Jul 2012 13:39:21 +0000</pubDate>
         <content:encoded><![CDATA[<p>You don't have to make files on Amazon S3 public (they aren't by default). But you can generate special keys to allow access to private files. These keys are passed through the URL and can be made to expire. </p>
<pre class="lang-php"><code>&lt;?php 

  if(!function_exists('el_crypto_hmacSHA1')){
    /**
    * Calculate the HMAC SHA1 hash of a string.
    *
    * @param string $key The key to hash against
    * @param string $data The data to hash
    * @param int $blocksize Optional blocksize
    * @return string HMAC SHA1
    */
    function el_crypto_hmacSHA1($key, $data, $blocksize = 64) {
        if (strlen($key) &gt; $blocksize) $key = pack('H*', sha1($key));
        $key = str_pad($key, $blocksize, chr(0x00));
        $ipad = str_repeat(chr(0x36), $blocksize);
        $opad = str_repeat(chr(0x5c), $blocksize);
        $hmac = pack( 'H*', sha1(
        ($key ^ $opad) . pack( 'H*', sha1(
          ($key ^ $ipad) . $data
        ))
      ));
        return base64_encode($hmac);
    }
  }

  if(!function_exists('el_s3_getTemporaryLink')){
    /**
    * Create temporary URLs to your protected Amazon S3 files.
    *
    * @param string $accessKey Your Amazon S3 access key
    * @param string $secretKey Your Amazon S3 secret key
    * @param string $bucket The bucket (bucket.s3.amazonaws.com)
    * @param string $path The target file path
    * @param int $expires In minutes
    * @return string Temporary Amazon S3 URL
    * @see http://awsdocs.s3.amazonaws.com/S3/20060301/s3-dg-20060301.pdf
    */
    
    function el_s3_getTemporaryLink($accessKey, $secretKey, $bucket, $path, $expires = 5) {
      // Calculate expiry time
      $expires = time() + intval(floatval($expires) * 60);
      // Fix the path; encode and sanitize
      $path = str_replace('%2F', '/', rawurlencode($path = ltrim($path, '/')));
      // Path for signature starts with the bucket
      $signpath = '/'. $bucket .'/'. $path;
      // S3 friendly string to sign
      $signsz = implode("&#92;n", $pieces = array('GET', null, null, $expires, $signpath));
      // Calculate the hash
      $signature = el_crypto_hmacSHA1($secretKey, $signsz);
      // Glue the URL ...
      $url = sprintf('http://%s.s3.amazonaws.com/%s', $bucket, $path);
      // ... to the query string ...
      $qs = http_build_query($pieces = array(
        'AWSAccessKeyId' =&gt; $accessKey,
        'Expires' =&gt; $expires,
        'Signature' =&gt; $signature,
      ));
      // ... and return the URL!
      return $url.'?'.$qs;
    }
  }

?&gt;</code></pre>
<h4>Usage</h4>
<pre class="lang-php"><code>&lt;?php echo el_s3_getTemporaryLink('your-access-key', 'your-secret-key', 'bucket-name', '/path/to/file.mov'); ?&gt;</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/jUMpT8QZnbI" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/php/generate-expiring-amazon-s3-link/</feedburner:origLink></item>
      <item>
         <title>Get Current Page URL</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/t-XFdfIl-_M/</link>
         <description>&lt;code&gt;function getUrl() {
  $url  = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] :  'https://'.$_SERVER["SERVER_NAME"];
  $url .= ( $_SERVER["SERVER_PORT"] !== 80 ) ? ":".$_SERVER["SERVER_PORT"] : "";
  $url .= $_SERVER["REQUEST_URI"];
  return $url;
}&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17223</guid>
         <pubDate>Mon, 18 Jun 2012 13:08:31 +0000</pubDate>
         <content:encoded><![CDATA[<pre class="lang-html"><code>function getUrl() {
  $url  = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] :  'https://'.$_SERVER["SERVER_NAME"];
  $url .= ( $_SERVER["SERVER_PORT"] !== 80 ) ? ":".$_SERVER["SERVER_PORT"] : "";
  $url .= $_SERVER["REQUEST_URI"];
  return $url;
}</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/t-XFdfIl-_M" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/php/get-current-page-url/</feedburner:origLink></item>
      <item>
         <title>Base64 Encode of 1x1px Transparent GIF</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/ITLu1jTl5bk/</link>
         <description>&lt;p&gt;Just in case you need one. You can stretch it out to fill space as needed.&lt;/p&gt;
&lt;code&gt;&amp;#60;img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"&amp;#62;&lt;/code&gt;
&lt;p&gt;Or a black one:&lt;/p&gt;
&lt;code&gt;&amp;#60;img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="&amp;#62;&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=15547</guid>
         <pubDate>Mon, 12 Dec 2011 20:02:58 +0000</pubDate>
         <content:encoded><![CDATA[<p>Just in case you need one. You can stretch it out to fill space as needed.</p>
<pre><code>&lt;img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"&gt;</code></pre>
<p>Or a black one:</p>
<pre><code>&lt;img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="&gt;</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/ITLu1jTl5bk" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/html/base64-encode-of-1x1px-transparent-gif/</feedburner:origLink></item>
      <item>
         <title>Post Data to an iframe</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/iPAc6MawsOs/</link>
         <description>&lt;p&gt;Doesn't take any JavaScript or anything. You just have the form's target attribute match the iframe's name attribute.&lt;/p&gt;
&lt;code&gt;&amp;#60;form action="iframe.php" target="my-iframe" method="post"&amp;#62;
			
  &amp;#60;label for="text"&amp;#62;Some text:&amp;#60;/label&amp;#62;
  &amp;#60;input type="text" name="text" id="text"&amp;#62;
			
  &amp;#60;input type="submit" value="post"&amp;#62;
			
&amp;#60;/form&amp;#62;
		
&amp;#60;iframe name="my-iframe" src="iframe.php"&amp;#62;&amp;#60;/iframe&amp;#62;&lt;/code&gt;
&lt;p&gt;The outer page doesn't even reload. But it might appear to at first glance since many browsers run the page-loading spinner in the tab when an iframe reloads.&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=15365</guid>
         <pubDate>Fri, 02 Dec 2011 03:59:39 +0000</pubDate>
         <content:encoded><![CDATA[<p>Doesn't take any JavaScript or anything. You just have the form's target attribute match the iframe's name attribute.</p>
<pre><code>&lt;form action="iframe.php" target="my-iframe" method="post"&gt;
			
  &lt;label for="text"&gt;Some text:&lt;/label&gt;
  &lt;input type="text" name="text" id="text"&gt;
			
  &lt;input type="submit" value="post"&gt;
			
&lt;/form&gt;
		
&lt;iframe name="my-iframe" src="iframe.php"&gt;&lt;/iframe&gt;</code></pre>
<p>The outer page doesn't even reload. But it might appear to at first glance since many browsers run the page-loading spinner in the tab when an iframe reloads.</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/iPAc6MawsOs" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/html/post-data-to-an-iframe/</feedburner:origLink></item>
      <item>
         <title>Append / Prepend Files</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/EGM1GMtfP-M/</link>
         <description>&lt;p&gt;Rather than having to call / include a file you need on every single page, you can have them automatically prepended (top of file) or appended (bottom of file) automatically through your .htaccess file.&lt;/p&gt;
&lt;code&gt;php_value auto_prepend_file "/real/path/to/file/functions.php"
php_value auto_append_file "/real/path/to/file/footer.php"&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=14472</guid>
         <pubDate>Wed, 05 Oct 2011 12:26:04 +0000</pubDate>
         <content:encoded><![CDATA[<p>Rather than having to call / include a file you need on every single page, you can have them automatically prepended (top of file) or appended (bottom of file) automatically through your .htaccess file.</p>
<pre><code>php_value auto_prepend_file "/real/path/to/file/functions.php"
php_value auto_append_file "/real/path/to/file/footer.php"</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/EGM1GMtfP-M" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/htaccess/append-prepend-files/</feedburner:origLink></item>
      <item>
         <title>Button With Line Breaks</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/qay9SNfy0Us/</link>
         <description>&lt;p&gt;You can use carriage return characters to break the line: &amp;#38;#x00A;&lt;/p&gt;
&lt;code&gt;&amp;#60;input type="button" value="Really&amp;#38;#x00A;Tall&amp;#38;#x00A; Button"&amp;#62;&lt;/code&gt;
&lt;p&gt;&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=14438</guid>
         <pubDate>Tue, 27 Sep 2011 16:16:08 +0000</pubDate>
         <content:encoded><![CDATA[<p>You can use carriage return characters to break the line: &amp;#x00A;</p>
<pre><code>&lt;input type="button" value="Really&amp;#x00A;Tall&amp;#x00A; Button"&gt;</code></pre>
<p><input type="button" value="Really&#x00A;Tall&#x00A; Button"></p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/qay9SNfy0Us" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/html/button-with-line-breaks/</feedburner:origLink></item>
      <item>
         <title>Subdirectories URL Internally Redirect to Query String</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/cZYOG4YoyI8/</link>
         <description>&lt;p&gt;&lt;strong&gt;The URL in the browser would be:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;http://css-tricks.com/index.php/teachers/a/&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The actual page rendered by the server would be:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;http://css-tricks.com/index.php?search=teachers&amp;#038;sort=a&lt;/p&gt;
&lt;code class="htaccess"&gt;RewriteEngine on
RewriteRule ^index/([^/]+)/([^/]+).php /page.php?search=$1&amp;#38;sort=$2 [NC]&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/</guid>
         <pubDate>Fri, 06 Aug 2010 03:17:13 +0000</pubDate>
         <content:encoded><![CDATA[<p><strong>The URL in the browser would be:</strong></p>
<p>http://css-tricks.com/index.php/teachers/a/</p>
<p><strong>The actual page rendered by the server would be:</strong></p>
<p>http://css-tricks.com/index.php?search=teachers&#038;sort=a</p>
<pre><code class="htaccess">RewriteEngine on
RewriteRule ^index/([^/]+)/([^/]+).php /page.php?search=$1&amp;sort=$2 [NC]</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/cZYOG4YoyI8" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/htaccess/subdirectories-redirect-query-string/</feedburner:origLink></item>
      <item>
         <title>PHP Error Logging</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/zvqsuL3j1Xw/</link>
         <description>&lt;p&gt;Log errors to a file, and prevent showing them to the user. Make sure that the file exists and youre able to write to it.&lt;/p&gt;
&lt;code class="htaccess"&gt;# display no errs to user
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
# log to file
php_flag log_errors on
php_value error_log /location/to/php_error.log&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=6589</guid>
         <pubDate>Mon, 14 Jun 2010 00:29:45 +0000</pubDate>
         <content:encoded><![CDATA[<p>Log errors to a file, and prevent showing them to the user. Make sure that the file exists and youre able to write to it.</p>
<pre><code class="htaccess"># display no errs to user
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
# log to file
php_flag log_errors on
php_value error_log /location/to/php_error.log</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/zvqsuL3j1Xw" height="1" width="1"/>]]></content:encoded>
         <category>Article</category>
      <feedburner:origLink>http://css-tricks.com/snippets/htaccess/php-error-logging/</feedburner:origLink></item>
      <item>
         <title>iPad Detection</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/0cAiaFMmUm4/</link>
         <description>&lt;p&gt;Of course, the iPad is a pretty large screen and a fully capable browser, so most websites don't need to have iPad specific versions of them. But if you need to, you can detect for it with .htaccess&lt;/p&gt;
&lt;code class="htaccess"&gt;RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://ipad.yourdomain.com [R=301]&lt;/code&gt;
&lt;p&gt;This will redirect iPad users to a URL you specify. This is probably the best way to do it (assuming you are running an Apache server), but if you aren't, there are &lt;a rel="nofollow" target="_blank" href="http://davidwalsh.name/detect-ipad"&gt;PHP and JavaScript &lt;/a&gt;&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=6256</guid>
         <pubDate>Fri, 23 Apr 2010 19:22:48 +0000</pubDate>
         <content:encoded><![CDATA[<p>Of course, the iPad is a pretty large screen and a fully capable browser, so most websites don't need to have iPad specific versions of them. But if you need to, you can detect for it with .htaccess</p>
<pre><code class="htaccess">RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://ipad.yourdomain.com [R=301]</code></pre>
<p>This will redirect iPad users to a URL you specify. This is probably the best way to do it (assuming you are running an Apache server), but if you aren't, there are <a rel="nofollow" target="_blank" href="http://davidwalsh.name/detect-ipad">PHP and JavaScript methods here</a>. </p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/0cAiaFMmUm4" height="1" width="1"/>]]></content:encoded>
         <category>Article</category>
      <feedburner:origLink>http://css-tricks.com/snippets/htaccess/ipad-detection/</feedburner:origLink></item>
      <item>
         <title>Force Correct content-type for XHTML Documents</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/0vGap980cBY/</link>
         <description>&lt;p&gt;Most webservers serve XHTML content as text/html what is definitly the right way to handle XHTML documents. In case the server isn't doing that correctly, you can force it on Apache servers with .htaccess:&lt;/p&gt;
&lt;code class="htaccess"&gt;RewriteEngine On
RewriteCond %{HTTP_ACCEPT} application/xhtml&amp;#92;+xml
RewriteCond %{HTTP_ACCEPT} !application/xhtml&amp;#92;+xml&amp;#92;s*;&amp;#92;s*q=0
RewriteCond %{REQUEST_URI} &amp;#92;.html$
RewriteCond %{THE_REQUEST} HTTP/1&amp;#92;.1
RewriteRule .* - "[T=application/xhtml+xml; charset=ISO-8859-1]"&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=6140</guid>
         <pubDate>Wed, 07 Apr 2010 18:17:00 +0000</pubDate>
         <content:encoded><![CDATA[<p>Most webservers serve XHTML content as <tt>text/html</tt> what is definitly the right way to handle XHTML documents. In case the server isn't doing that correctly, you can force it on Apache servers with .htaccess:</p>
<pre><code class="htaccess">RewriteEngine On
RewriteCond %{HTTP_ACCEPT} application/xhtml&#92;+xml
RewriteCond %{HTTP_ACCEPT} !application/xhtml&#92;+xml&#92;s*;&#92;s*q=0
RewriteCond %{REQUEST_URI} &#92;.html$
RewriteCond %{THE_REQUEST} HTTP/1&#92;.1
RewriteRule .* - "[T=application/xhtml+xml; charset=ISO-8859-1]"</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/0vGap980cBY" height="1" width="1"/>]]></content:encoded>
         <category>Article</category>
      <feedburner:origLink>http://css-tricks.com/snippets/htaccess/force-correct-content-type-for-xhtml-documents/</feedburner:origLink></item>
   </channel>
</rss><!-- fe4.yql.bf1.yahoo.com compressed/chunked Wed May 22 01:48:05 UTC 2013 -->
