<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CSS-TricksCSS-Tricks</title>
	<atom:link href="http://css-tricks.com/css-snippets-feed/" rel="self" type="application/rss+xml" />
	<link>http://css-tricks.com</link>
	<description>Tips, Tricks, and Techniques on using Cascading Style Sheets.</description>
	<lastBuildDate>Wed, 19 Jun 2013 14:06:26 +0000</lastBuildDate>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>

	<generator>http://wordpress.org/?v=3.5.1</generator>

	
		<item>
			<title>Momentum Scrolling on iOS Overflow Elements</title>
			<link>http://css-tricks.com/snippets/css/momentum-scrolling-on-ios-overflow-elements/</link>
			<comments>http://css-tricks.com/snippets/css/momentum-scrolling-on-ios-overflow-elements/#comments</comments>
			<pubDate>Sat, 04 May 2013 13:26:53 +0000</pubDate>
			<dc:creator>Chris Coyier</dc:creator>
				<guid isPermaLink="false">http://css-tricks.com/?page_id=21524</guid>

			<description><![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>
<code class="language-css">.module &#8230;</code>]]></description>

			<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 rel="CSS"><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" data-height="352" data-type="result" data-href="nHEDj" data-user="chriscoyier" data-safe="true"><code></code><a href="http://codepen.io/chriscoyier/pen/nHEDj">Check out this Pen!</a></pre>
]]></content:encoded>

			<wfw:commentRss>http://css-tricks.com/snippets/css/momentum-scrolling-on-ios-overflow-elements/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>

						
		</item>

	
		<item>
			<title>A Complete Guide to Flexbox</title>
			<link>http://css-tricks.com/snippets/css/a-guide-to-flexbox/</link>
			<comments>http://css-tricks.com/snippets/css/a-guide-to-flexbox/#comments</comments>
			<pubDate>Mon, 08 Apr 2013 18:46:57 +0000</pubDate>
			<dc:creator>Chris Coyier</dc:creator>
				<guid isPermaLink="false">http://css-tricks.com/?page_id=21059</guid>

			<description><![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 &#8230;</p>]]></description>

			<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 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 rel="CSS"><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 rel="CSS"><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 rel="CSS"><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 rel="CSS"><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 rel="CSS"><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>
<figure id='post-21043 media-21043' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2011/08/justify-contetnt.png' alt='' /></figure>
<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 rel="CSS"><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>
<figure id='post-21044 media-21044' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2011/08/align-items.png' alt='' /></figure>
<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 rel="CSS"><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>
<figure id='post-21045 media-21045' class='align-none'><img src='http://cdn.css-tricks.com/wp-content/uploads/2011/08/align-content.png' alt='' /></figure>
<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 rel="CSS"><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 rel="CSS"><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 rel="CSS"><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 rel="CSS"><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 rel="CSS"><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 rel="CSS"><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 rel="CSS"><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 rel="CSS"><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" data-height="400" data-type="result" data-href="3e86f7ea0ae954e541f0431fa20f04f1" data-user="HugoGiraudel" data-safe="true"><code></code><a 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 rel="CSS"><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" data-height="100" data-type="result" data-href="f6b906545dadb0a12567433c9f406343" data-user="HugoGiraudel" data-safe="true"><code></code><a 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 rel="CSS"><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" data-height="300" data-type="result" data-href="6448fc51f994a029be1facb87afe3b5c" data-user="HugoGiraudel" data-safe="true"><code></code><a href="http://codepen.io/HugoGiraudel/pen/qIAwr">Check out this Pen!</a></pre>
<h3>Related Properties</h3>
<ul>
<li><a href="http://css-tricks.com/almanac/properties/g/grid/">Grid</a></li>
</ul>
<h3>Other Resources</h3>
<ul>
<li><a href="http://www.w3.org/TR/css3-flexbox/">Flexbox in the CSS specifications</a></li>
<li><a href="https://developer.mozilla.org/en-US/docs/CSS/Tutorials/Using_CSS_flexible_boxes">Flexbox at MDN</a></li>
<li><a href="http://dev.opera.com/articles/view/flexbox-basics/">Flexbox at Opera</a></li>
<li><a href="http://weblog.bocoup.com/dive-into-flexbox/">Diving into Flexbox by Bocoup</a></li>
<li><a href="http://css-tricks.com/using-flexbox/">Mixing syntaxes for best browser support on CSS-Tricks</a></li>
<li><a href="http://www.alsacreations.com/tuto/lire/1493-css3-flexbox-layout-module.html">Flexbox by Raphael Goetter (FR)</a></li>
<li><a 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 href="http://css-tricks.com/using-flexbox/">this article (CSS-Tricks)</a> or <a 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 rel="SCSS"><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>
]]></content:encoded>

			<wfw:commentRss>http://css-tricks.com/snippets/css/a-guide-to-flexbox/feed/</wfw:commentRss>
			<slash:comments>11</slash:comments>

						
		</item>

	
		<item>
			<title>Turn Off Number Input Spinners</title>
			<link>http://css-tricks.com/snippets/css/turn-off-number-input-spinners/</link>
			<comments>http://css-tricks.com/snippets/css/turn-off-number-input-spinners/#comments</comments>
			<pubDate>Fri, 12 Oct 2012 00:11:17 +0000</pubDate>
			<dc:creator>Chris Coyier</dc:creator>
				<guid isPermaLink="false">http://css-tricks.com/?page_id=18880</guid>

			<description><![CDATA[<p>WebKit desktop browsers add little up down arrows to number inputs called spinners. You can turn them off visually like this:</p>
<code class="language-css">input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}</code>
<p>Note that some other functionality still exists, like being able to increment the number via the scroll wheel on a mouse.&#8230;</p>

Top, on, Bottom, off.]]></description>

			<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 rel="CSS"><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>
<figure id='post-18881 media-18881' class='align-none'><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' /></p>
<figcaption>Top, on, Bottom, off.</figcaption>
</figure>
]]></content:encoded>

			<wfw:commentRss>http://css-tricks.com/snippets/css/turn-off-number-input-spinners/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>

						
		</item>

	
		<item>
			<title>Retina Display Media Query</title>
			<link>http://css-tricks.com/snippets/css/retina-display-media-query/</link>
			<comments>http://css-tricks.com/snippets/css/retina-display-media-query/#comments</comments>
			<pubDate>Thu, 16 Aug 2012 03:53:27 +0000</pubDate>
			<dc:creator>Chris Coyier</dc:creator>
				<guid isPermaLink="false">http://css-tricks.com/?page_id=17757</guid>

			<description><![CDATA[<p>For including high-res graphics, but only for screens that can make use of them. "Retina" being "2x":</p>
<code class="language-css">@media 
(-webkit-min-device-pixel-ratio: 2), 
(min-resolution: 192dpi) { 
    /* Retina-specific stuff here */
}</code>
<p>Or other highish-res:</p>
<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 */
}&#8230;</code>
Old Stuff (don't]]></description>

			<content:encoded><![CDATA[<p>For including high-res graphics, but only for screens that can make use of them. "Retina" being "2x":</p>
<pre rel="CSS"><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 rel="CSS"><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 rel="CSS" 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 rel="CSS" 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 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 rel="CSS"><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>
]]></content:encoded>

			<wfw:commentRss>http://css-tricks.com/snippets/css/retina-display-media-query/feed/</wfw:commentRss>
			<slash:comments>30</slash:comments>

						
		</item>

	
		<item>
			<title>Transparent Background Images</title>
			<link>http://css-tricks.com/snippets/css/transparent-background-images/</link>
			<comments>http://css-tricks.com/snippets/css/transparent-background-images/#comments</comments>
			<pubDate>Sun, 05 Aug 2012 15:07:31 +0000</pubDate>
			<dc:creator>Chris Coyier</dc:creator>
				<guid isPermaLink="false">http://css-tricks.com/?page_id=17657</guid>

			<description><![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>
<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>
<code></code>
<p><br />
​&#8230;</p>]]></description>

			<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 rel="CSS" 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" data-type="result" data-href="DaJnG" data-user="chriscoyier" data-host="http://codepen.io"  ><code></code></pre>
<p><script async src="http://codepen.io/assets/embed/ei.js"></script><br />
​</p>
]]></content:encoded>

			<wfw:commentRss>http://css-tricks.com/snippets/css/transparent-background-images/feed/</wfw:commentRss>
			<slash:comments>20</slash:comments>

						
		</item>

	
</channel>

</rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk (User agent is rejected)
Content Delivery Network via cdn.css-tricks.com

 Served from: css-tricks.com @ 2013-06-19 18:12:53 by W3 Total Cache -->