<?xml version="1.0"?>
<rss version="2.0" 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">
   <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>Thu, 01 Oct 2015 23:11:15 +0000</pubDate>
      <generator>http://pipes.yahoo.com/pipes/</generator>
      <item>
         <title>Handling Long Words and URLs (Forcing Breaks, Hyphenation, Ellipsis, etc)</title>
         <link>https://css-tricks.com/snippets/css/handling-long-words-and-urls/</link>
         <description>We've moved this snippet to our canonical snippet on this subject. See: &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/&quot;&gt;Handling Long Words and URLs&lt;/a&gt;&amp;#8230;</description>
         <guid isPermaLink="false">https://css-tricks.com/?page_id=208233</guid>
         <pubDate>Fri, 25 Sep 2015 14:03:43 +0000</pubDate>
         <content:encoded><![CDATA[<div class="explanation">We've moved this snippet to our canonical snippet on this subject. See: <a rel="nofollow" target="_blank" href="https://css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/">Handling Long Words and URLs</a></div>]]></content:encoded>
      </item>
      <item>
         <title>Toggle Visibility When Hiding Elements</title>
         <link>https://css-tricks.com/snippets/css/toggle-visibility-when-hiding-elements/</link>
         <description>&lt;p&gt;The development team at Medium have discussed some &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://medium.com/medium-eng/five-goofy-things-medium-did-that-break-accessibility-3bc804ae818d&quot;&gt;bad practices that break accessibility&lt;/a&gt;. In one example, they argue that &lt;code&gt;opacity&lt;/code&gt; is not well supported by screen readers and so if we want to hide an element in a transition then we should always use the &lt;code&gt;&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://css-tricks.com/almanac/properties/v/visibility/&quot;&gt;visibility&lt;/a&gt;&lt;/code&gt; attribute, too:&lt;/p&gt;
&lt;code class=&quot;language-css&quot;&gt;.m-fadeOut {
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s linear 300ms, opacity 300ms;
}
.m-fadeIn {
  visibility: visible;
  opacity: 1;
  transition: visibility 0s linear 0s, opacity 300ms;
}&lt;/code&gt;
&lt;p class='codepen'&gt;See the Pen &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">https://css-tricks.com/?page_id=208296</guid>
         <pubDate>Thu, 17 Sep 2015 23:58:44 +0000</pubDate>
         <content:encoded><![CDATA[<p>The development team at Medium have discussed some <a rel="nofollow" target="_blank" href="https://medium.com/medium-eng/five-goofy-things-medium-did-that-break-accessibility-3bc804ae818d">bad practices that break accessibility</a>. In one example, they argue that <code>opacity</code> is not well supported by screen readers and so if we want to hide an element in a transition then we should always use the <code><a rel="nofollow" target="_blank" href="https://css-tricks.com/almanac/properties/v/visibility/">visibility</a></code> attribute, too:</p>
<pre><code class="language-css">.m-fadeOut {
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s linear 300ms, opacity 300ms;
}
.m-fadeIn {
  visibility: visible;
  opacity: 1;
  transition: visibility 0s linear 0s, opacity 300ms;
}</code></pre>
<p class='codepen'>See the Pen <a rel="nofollow" target="_blank" href='http://codepen.io/team/css-tricks/pen/avNqoe/'>avNqoe</a> by CSS-Tricks (<a rel="nofollow" target="_blank" href='http://codepen.io/css-tricks'>@css-tricks</a>) on <a rel="nofollow" target="_blank" href='http://codepen.io'>CodePen</a>.</p>
<p>Remember opacity and visibility still leave an element in the document flow. If you need to remove it from flow, there is more work to do. In fact here's a way to think about them...</p>
<table>
<tr>
<th></th>
<th>can make thing invisible</th>
<th>can make thing unclickable</th>
<th>removes from doc flow</th>
<th>can be transitioned</th>
<th>can be reversed on child</th>
</tr>
<tr>
<th><a rel="nofollow" target="_blank" href="https://css-tricks.com/almanac/properties/o/opacity/">opacity</a></th>
<td>ya</td>
<td>no</td>
<td>no</td>
<td>yes</td>
<td>no</td>
</tr>
<tr>
<th><a rel="nofollow" target="_blank" href="https://css-tricks.com/almanac/properties/v/visibility/">visibility</a></th>
<td>ya</td>
<td>ya</td>
<td>no</td>
<td>yes</td>
<td>yes</td>
</tr>
<tr>
<th><a rel="nofollow" target="_blank" href="https://css-tricks.com/almanac/properties/d/display/">display</a></th>
<td>ya</td>
<td>ya</td>
<td>ya</td>
<td>no</td>
<td>no</td>
</tr>
<tr>
<th><a rel="nofollow" target="_blank" href="https://css-tricks.com/almanac/properties/p/pointer-events/">pointer-events</a></th>
<td>no</td>
<td>ya</td>
<td>no</td>
<td>no</td>
<td>no</td>
</tr>
</table>
<p>If you need to change the display value of an element after a fading, that's tougher. Not really possible in CSS since display isn't transitionable. <a rel="nofollow" target="_blank" href="http://snook.ca/archives/javascript/preparetransition-jquery-plugin">Snook has written about this</a>, including some JavaScript to help.</p>]]></content:encoded>
      </item>
      <item>
         <title>Hide Scrollbar in Edge, IE 10/11</title>
         <link>https://css-tricks.com/snippets/css/hide-scrollbar-in-edge-ie-1011/</link>
         <description>&lt;p&gt;You can make it auto-hiding instead of always-showing:&lt;/p&gt;
&lt;code class=&quot;language-css&quot;&gt;html {
  -ms-overflow-style: -ms-autohiding-scrollbar;
}&lt;/code&gt;
&lt;p&gt;Turns out like this:&lt;/p&gt;

&lt;p&gt;Credit to &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://twitter.com/thierrykoblentz/status/640043998376103936&quot;&gt;Thierry Koblentz&lt;/a&gt; for digging this gem out of Jon Neal's &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://github.com/10up/sanitize.css&quot;&gt;Sanitize.css&lt;/a&gt;.&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">https://css-tricks.com/?page_id=207678</guid>
         <pubDate>Sun, 06 Sep 2015 00:02:12 +0000</pubDate>
         <content:encoded><![CDATA[<p>You can make it auto-hiding instead of always-showing:</p>
<pre><code class="language-css">html {
  -ms-overflow-style: -ms-autohiding-scrollbar;
}</code></pre>
<p>Turns out like this:</p>
<img src='https://cdn.css-tricks.com/wp-content/uploads/2015/09/scrollbar.gif' alt=''/> 
<p>Credit to <a rel="nofollow" target="_blank" href="https://twitter.com/thierrykoblentz/status/640043998376103936">Thierry Koblentz</a> for digging this gem out of Jon Neal's <a rel="nofollow" target="_blank" href="https://github.com/10up/sanitize.css">Sanitize.css</a>.</p>]]></content:encoded>
      </item>
      <item>
         <title>Start a Web Server With One Terminal Command on OS X</title>
         <link>https://css-tricks.com/snippets/html/start-a-web-server-with-one-terminal-command-on-os-x/</link>
         <description>&lt;p&gt;I've searched for this three times this week, so I figured I'd better make sure I have a copy of it:&lt;/p&gt;
&lt;code&gt;python -m SimpleHTTPServer 8000&lt;/code&gt;
&lt;p&gt;Navigate to the project directory in the terminal and do that command. Then http://localhost:8000 will server up that directory (as in, it's `index.html` file).&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">https://css-tricks.com/?page_id=207270</guid>
         <pubDate>Thu, 27 Aug 2015 20:22:41 +0000</pubDate>
         <content:encoded><![CDATA[<p>I've searched for this three times this week, so I figured I'd better make sure I have a copy of it:</p>
<pre><code>python -m SimpleHTTPServer 8000</code></pre>
<p>Navigate to the project directory in the terminal and do that command. Then http://localhost:8000 will server up that directory (as in, it's `index.html` file).</p>]]></content:encoded>
      </item>
      <item>
         <title>“Shake” CSS Keyframe Animation</title>
         <link>https://css-tricks.com/snippets/css/shake-css-keyframe-animation/</link>
         <description>&lt;p&gt;This assumes the use of an autoprefixer.&lt;/p&gt;
&lt;code class=&quot;language-css&quot;&gt;.face:hover {
  animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  perspective: 1000px;
}

@keyframes shake {
  10%, 90% {
    transform: translate3d(-1px, 0, 0);
  }
  
  20%, 80% {
    transform: translate3d(2px, 0, 0);
  }

  30%, 50%, 70% {
    transform: translate3d(-4px, 0, 0);
  }

  40%, 60% {
    transform: translate3d(4px, 0, 0);
  }
}&lt;/code&gt;
&lt;p class='codepen'&gt;See the Pen &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href='http://codepen.io/sdras/pen/aOgMON/'&gt;&quot;Shake&quot; CSS snippet for CSS-Tricks&lt;/a&gt; by Sarah Drasner (&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href='http://codepen.io/sdras'&gt;@sdras&lt;/a&gt;) on &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href='http://codepen.io'&gt;CodePen&lt;/a&gt;.&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">https://css-tricks.com/?page_id=206892</guid>
         <pubDate>Sat, 22 Aug 2015 15:09:42 +0000</pubDate>
         <content:encoded><![CDATA[<p>This assumes the use of an autoprefixer.</p>
<pre><code class="language-css">.face:hover {
  animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  perspective: 1000px;
}

@keyframes shake {
  10%, 90% {
    transform: translate3d(-1px, 0, 0);
  }
  
  20%, 80% {
    transform: translate3d(2px, 0, 0);
  }

  30%, 50%, 70% {
    transform: translate3d(-4px, 0, 0);
  }

  40%, 60% {
    transform: translate3d(4px, 0, 0);
  }
}</code></pre>
<p class='codepen'>See the Pen <a rel="nofollow" target="_blank" href='http://codepen.io/sdras/pen/aOgMON/'>"Shake" CSS snippet for CSS-Tricks</a> by Sarah Drasner (<a rel="nofollow" target="_blank" href='http://codepen.io/sdras'>@sdras</a>) on <a rel="nofollow" target="_blank" href='http://codepen.io'>CodePen</a>.</p>]]></content:encoded>
      </item>
      <item>
         <title>Compare jQuery Objects</title>
         <link>https://css-tricks.com/snippets/jquery/compare-jquery-objects/</link>
         <description>&lt;p&gt;You can't really compare if two jQuery objects are the same...&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;if ($(selectionOne) === $(selectionTwo)) {

}&lt;/code&gt;
&lt;p&gt;You can compare DOM objects though...&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;if ($(selectionOne)[0] === $(selectionTwo)[0]) {

} &lt;/code&gt;
&lt;p&gt;But that's only really useful if you're comparing a single element, not a collection. &lt;/p&gt;
&lt;p&gt;If you need to compare a collection of elements, &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://stackoverflow.com/questions/2436966/how-would-you-compare-jquery-objects&quot;&gt;this StackOverflow thread&lt;/a&gt; has the answer:&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;var divs = $(&quot;div&quot;);
var divs2 = $(&quot;div&quot;);

if (divs.length == divs2.length &amp;#38;&amp;#38; divs.length == divs.filter(divs2).length) {         
  // They are equal
}&lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">https://css-tricks.com/?page_id=206763</guid>
         <pubDate>Wed, 19 Aug 2015 16:25:42 +0000</pubDate>
         <content:encoded><![CDATA[<p>You can't really compare if two jQuery objects are the same...</p>
<pre><code class="language-javascript">if ($(selectionOne) === $(selectionTwo)) {

}</code></pre>
<p>You can compare DOM objects though...</p>
<pre><code class="language-javascript">if ($(selectionOne)[0] === $(selectionTwo)[0]) {

} </code></pre>
<p>But that's only really useful if you're comparing a single element, not a collection. </p>
<p>If you need to compare a collection of elements, <a rel="nofollow" target="_blank" href="http://stackoverflow.com/questions/2436966/how-would-you-compare-jquery-objects">this StackOverflow thread</a> has the answer:</p>
<pre><code class="language-javascript">var divs = $("div");
var divs2 = $("div");

if (divs.length == divs2.length &amp;&amp; divs.length == divs.filter(divs2).length) {         
  // They are equal
}</code></pre>]]></content:encoded>
      </item>
      <item>
         <title>A jQuery hasAttr() Equivalent</title>
         <link>https://css-tricks.com/snippets/jquery/make-an-jquery-hasattr/</link>
         <description>&lt;p&gt;jQuery doesn't really have an &lt;code&gt;.hasAttr()&lt;/code&gt; function. You might assume that it does, but alas, it does not. &lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://stackoverflow.com/questions/1318076/jquery-hasattr-checking-to-see-if-there-is-an-attribute-on-an-element&quot;&gt;A StackOverflow thread&lt;/a&gt; has some pretty good solutions.&lt;/p&gt;
Get the attribute, check the value
&lt;code class=&quot;language-javascript&quot;&gt;var attr = $(this).attr('name');

// For some browsers, `attr` is undefined; for others, `attr` is false. Check for both.
if (typeof attr !== typeof undefined &amp;#38;&amp;#38; attr !== false) {
  // Element has this attribute
}&lt;/code&gt;
Native JavaScript has a way
&lt;p&gt;If you only have a jQuery reference...&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">https://css-tricks.com/?page_id=206756</guid>
         <pubDate>Wed, 19 Aug 2015 16:15:31 +0000</pubDate>
         <content:encoded><![CDATA[<p>jQuery doesn't really have an <code>.hasAttr()</code> function. You might assume that it does, but alas, it does not. </p>
<p><a rel="nofollow" target="_blank" href="http://stackoverflow.com/questions/1318076/jquery-hasattr-checking-to-see-if-there-is-an-attribute-on-an-element">A StackOverflow thread</a> has some pretty good solutions.</p>
<h3>Get the attribute, check the value</h3>
<pre><code class="language-javascript">var attr = $(this).attr('name');

// For some browsers, `attr` is undefined; for others, `attr` is false. Check for both.
if (typeof attr !== typeof undefined &amp;&amp; attr !== false) {
  // Element has this attribute
}</code></pre>
<h3>Native JavaScript has a way</h3>
<p>If you only have a jQuery reference...</p>
<pre><code class="language-javascript">$(this)[0].hasAttribute("name");

jQObject[0].hasAttribute("name");</code></pre>
<h3>Filter the selection</h3>
<pre><code class="language-javascript">$(this).is('[name]');

$(this).filter("[name='choice']");</code></pre>]]></content:encoded>
      </item>
      <item>
         <title>Mixin to Qualify a Selector</title>
         <link>https://css-tricks.com/snippets/sass/mixin-to-qualify-a-selector/</link>
         <description>&lt;p&gt;There is no easy way of qualifying a selector from within its associated ruleset. By qualifying I mean prepending an element name (e.g. &lt;code&gt;a&lt;/code&gt;) to a class (e.g. &lt;code&gt;.btn&lt;/code&gt;) so that a ruleset gets specific to a combination of an element selector and a class selector (e.g. &lt;code&gt;a.btn&lt;/code&gt;) for instance. &lt;/p&gt;
&lt;p&gt;As of today, the best (and so far only valid way) to do so is as follow:&lt;/p&gt;
&lt;code class=&quot;language-scss&quot;&gt;.button {
  @at-root a#{&amp;#38;} {
    // Specific styles for `a.button`
  &lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">https://css-tricks.com/?page_id=196824</guid>
         <pubDate>Thu, 26 Feb 2015 08:29:12 +0000</pubDate>
         <content:encoded><![CDATA[<p>There is no easy way of qualifying a selector from within its associated ruleset. By qualifying I mean prepending an element name (e.g. <code>a</code>) to a class (e.g. <code>.btn</code>) so that a ruleset gets specific to a combination of an element selector and a class selector (e.g. <code>a.btn</code>) for instance. </p>
<p>As of today, the best (and so far only valid way) to do so is as follow:</p>
<pre><code class="language-scss">.button {
  @at-root a#{&amp;} {
    // Specific styles for `a.button`
  }
}</code></pre>
<p>Wow, definitely not really elegant, is it? Ideally, you might want to hide this kind of horrific syntax behind a mixin so that you keep a clean and friendly API, especially if you have rookie developers in your team. </p>
<p>Doing so is extremely simple of course:</p>
<pre><code class="language-scss">/// Since the current way to qualify a class from within its ruleset is quite
/// ugly, here is a mixin providing a friendly API to do so.
/// @author Hugo Giraudel
/// @param {String} $element-selector - Element selector
@mixin qualify($element-selector) {
  @at-root #{$element-selector + &amp;} {
    @content;
  }
}</code></pre>
<p>Now, rewriting our previous snippet:</p>
<pre><code class="language-scss">.button {
  @include qualify(a) {
    // Specific styles for `a.button`
  }
}</code></pre>
<p>Much better, right? Still, <code>qualify</code> can sound a bit tricky for inexperienced Sass tinkerers. You could provide an alias when a more descriptive name, such as <code>when-is</code>.</p>
<pre><code class="language-scss">/// @alias qualify
@mixin when-is($args...) {
  @include qualify($args...) {
    @content;
  }
}</code></pre>
<p>One final example:</p>
<pre><code class="language-scss">.button {
  border: none;
  
  // Qualify `.button` with `button`
  @include qualify(button) {
    -webkit-appearance: none;
  }
  
  // Qualify `.button` with `a`
  @include when-is(a) {
    text-decoration: none;
  }
}</code></pre>]]></content:encoded>
      </item>
      <item>
         <title>Cross-Browser Dependency-Free DOM Ready</title>
         <link>https://css-tricks.com/snippets/javascript/cross-browser-dependency-free-dom-ready/</link>
         <description>&lt;p&gt;Denis Ciccale's &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://gist.github.com/dciccale/4087856&quot;&gt;version&lt;/a&gt;:&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;var DOMReady = function(a, b, c) {
  b = document
  c = 'addEventListener'
  b[c] ? b[c]('DocumentContentLoaded', a) : window.attachEvent('onload', a)
}
    
DOMReady(function () {
  alert('The DOM is Ready!');
});&lt;/code&gt;
&lt;p&gt;Minimized:&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;var DOMReady = function(a,b,c){b=document,c='addEventListener';b[c]?b[c]('DOMContentLoaded',a):window.attachEvent('onload',a)}&lt;/code&gt;
&lt;hr /&gt;
&lt;p&gt;Dustin Diaz's &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://www.dustindiaz.com/smallest-domready-ever&quot;&gt;version&lt;/a&gt;:&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}&lt;/code&gt;
&lt;p&gt;He also had a repo for it where the code is &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://github.com/ded/domready/blob/master/ready.js&quot;&gt;a bit different&lt;/a&gt; (and looks newer) so you might wanna try that, although I've found the above pretty effective as-is. His &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://github.com/ded/domready/tree/v0.3.0&quot;&gt;0.3.0 branch&lt;/a&gt; is required &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=196692</guid>
         <pubDate>Tue, 24 Feb 2015 13:35:39 +0000</pubDate>
         <content:encoded><![CDATA[<p>Denis Ciccale's <a rel="nofollow" target="_blank" href="https://gist.github.com/dciccale/4087856">version</a>:</p>
<pre><code class="language-javascript">var DOMReady = function(a, b, c) {
  b = document
  c = 'addEventListener'
  b[c] ? b[c]('DocumentContentLoaded', a) : window.attachEvent('onload', a)
}
    
DOMReady(function () {
  alert('The DOM is Ready!');
});</code></pre>
<p>Minimized:</p>
<pre><code class="language-javascript">var DOMReady = function(a,b,c){b=document,c='addEventListener';b[c]?b[c]('DOMContentLoaded',a):window.attachEvent('onload',a)}</code></pre>
<hr>
<p>Dustin Diaz's <a rel="nofollow" target="_blank" href="http://www.dustindiaz.com/smallest-domready-ever">version</a>:</p>
<pre><code class="language-javascript">function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}</code></pre>
<p>He also had a repo for it where the code is <a rel="nofollow" target="_blank" href="https://github.com/ded/domready/blob/master/ready.js">a bit different</a> (and looks newer) so you might wanna try that, although I've found the above pretty effective as-is. His <a rel="nofollow" target="_blank" href="https://github.com/ded/domready/tree/v0.3.0">0.3.0 branch</a> is required for IE 6-7-8.</p>
<hr>
<p>The native DOM function is:</p>
<pre><code class="language-javascript">document.addEventListener('DOMContentLoaded', function() {

});</code></pre>
<p>In case you're cool with only needing to support browsers <a rel="nofollow" target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded">that support that</a>.</p>]]></content:encoded>
      </item>
      <item>
         <title>Px to Em Functions</title>
         <link>https://css-tricks.com/snippets/sass/px-to-em-functions/</link>
         <description>&lt;p&gt;We've talked about &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://css-tricks.com/why-ems/&quot;&gt;&quot;Why Ems?&quot;&lt;/a&gt; here before.&lt;/p&gt;
&lt;p&gt;For those new to em values, &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/font-size#Ems&quot;&gt;The Mozilla Developer Network&lt;/a&gt; does an excellent job of explaining ems:&lt;/p&gt;
&lt;p&gt;...an em is equal to the size of the font that applies to the parent of the element in question. If you haven't set the font size anywhere on the page, then it is the browser default, which is probably 16px. So, by default 1em = 16px, and 2em = 32px.&lt;/p&gt;
&lt;p&gt;If you still prefer to &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=196684</guid>
         <pubDate>Tue, 24 Feb 2015 13:02:41 +0000</pubDate>
         <content:encoded><![CDATA[<p>We've talked about <a rel="nofollow" target="_blank" href="http://css-tricks.com/why-ems/">"Why Ems?"</a> here before.</p>
<p>For those new to em values, <a rel="nofollow" target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size#Ems">The Mozilla Developer Network</a> does an excellent job of explaining ems:</p>
<blockquote><p>...an em is equal to the size of the font that applies to the parent of the element in question. If you haven't set the font size anywhere on the page, then it is the browser default, which is probably 16px. So, by default 1em = 16px, and 2em = 32px.</p></blockquote>
<p>If you still prefer to think in px, but like the benefits of em, no need have your calculator handy, you can let Sass do the work for you. There are a variety of ways to calculate ems with Sass. </p>
<p>Inline math:</p>
<pre><code class="language-scss">h1 {
  font-size: (32 / 16) * 1em;
}

p {
  font-size: (14 / 16) + 0em;
}</code></pre>
<p>Note: We need the "* 1em" there for Sass to correctly append the unit value.  You can also use "+ 0em" for the same purpose.</p>
<p>Result:</p>
<pre><code class="language-css">h1 {
  font-size: 2em;
}

p {
  font-size: 0.875em;
}</code></pre>
<p>This works, but we can make it easier. </p>
<h3>The em() Sass function</h3>
<p>There are quite a few different ways to write this function, this one from a <a rel="nofollow" target="_blank" href="http://web-design-weekly.com/snippets/converts-pixels-to-ems-with-sass/">Web Design Weekly</a> article:</p>
<pre><code class="language-scss">$browser-context: 16; // Default

@function em($pixels, $context: $browser-context) {
  @return #{$pixels/$context}em;
}</code></pre>
<p>Super clever! This function uses Sass' string interpolation to append em to the value. Note that the $context parameter has a default value of $browser-context (so, whatever you set this variable to).  This means that when calling the function in your Sass, you only need to define the <code>$pixels</code> value and the math will be calculated relative to <code>$browser-context</code> - in this case - 16px.  </p>
<p>Example Usage: </p>
<pre><code class="language-scss">h1 {
  font-size: em(32);
}

p {
  font-size: em(14);
}</code></pre>
<p>Result:</p>
<pre><code class="language-css">h1 {
  font-size: 2em;
}

p {
  font-size: 0.875em;
}</code></pre>
<p>A similar function using math instead of string interpolation from <a rel="nofollow" target="_blank" href="http://thesassway.com/intermediate/responsive-web-design-part-1">The Sass Way</a> can easily be modified to accept variables like our string interpolation function:</p>
<pre><code class="language-scss">//un-modified

@function calc-em($target-px, $context) {
  @return ($target-px / $context) * 1em;
}

// and modified to accept a base context variable

$browser-context: 16;

@function em($pixels, $context: $browser-context) {
  @return ($pixels / $context) * 1em;
}</code></pre>
<p>Another using Sass' <a rel="nofollow" target="_blank" href="http://sass-lang.com/documentation/Sass/Script/Functions.html#unitless-instance_method">unitless()</a> method:</p>
<pre><code class="language-scss">$browser-context: 16;

@function em($pixels, $context: $browser-context) {
  @if (unitless($pixels)) {
    $pixels: $pixels * 1px;
  }

  @if (unitless($context)) {
    $context: $context * 1px;
  }

  @return $pixels / $context * 1em;
}</code></pre>
<p>This allows us to either include the px unit or not in the function call.</p>
<pre><code class="language-scss">h1 {
  font-size: em(32);
}

// is the same as:

h1 {
  font-size: em(32px);
}</code></pre>]]></content:encoded>
      </item>
      <item>
         <title>Easing Map Get Function</title>
         <link>https://css-tricks.com/snippets/sass/easing-map-get-function/</link>
         <description>&lt;p&gt;Bézier curves can be used to add beautiful effects to CSS transitions and animations. Typing out the full functional notation (e.g. &lt;code&gt;cubic-bezier(0.550, 0.085, 0.680, 0.530)&lt;/code&gt;) - for developers writing Sass, is unnecessary.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://bourbon.io&quot;&gt;Bourbon&lt;/a&gt; - a popular Sass mixin library, comes pre-packaged with all of the &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://bourbon.io/docs/#timing-functions&quot;&gt;timing functions&lt;/a&gt; declared as variables. If you're not using Bourbon, feel free to grab these:&lt;/p&gt;
&lt;code class=&quot;language-scss&quot;&gt;$ease: (
  in-quad:      cubic-bezier(0.550,  0.085, 0.680, 0.530),
  in-cubic:     cubic-bezier(0.550,  0.055, 0.675, 0.190),
  in-quart:     cubic-bezier(0.895,  0.030, 0.685, 0.220),
  in-quint:     cubic-bezier(0.755,  &lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=196304</guid>
         <pubDate>Thu, 19 Feb 2015 19:12:17 +0000</pubDate>
         <content:encoded><![CDATA[<p>Bézier curves can be used to add beautiful effects to CSS transitions and animations. Typing out the full functional notation (e.g. <code>cubic-bezier(0.550, 0.085, 0.680, 0.530)</code>) - for developers writing Sass, is unnecessary.</p>
<p><a rel="nofollow" target="_blank" href="http://bourbon.io">Bourbon</a> - a popular Sass mixin library, comes pre-packaged with all of the <a rel="nofollow" target="_blank" href="http://bourbon.io/docs/#timing-functions">timing functions</a> declared as variables. If you're not using Bourbon, feel free to grab these:</p>
<pre><code class="language-scss">$ease: (
  in-quad:      cubic-bezier(0.550,  0.085, 0.680, 0.530),
  in-cubic:     cubic-bezier(0.550,  0.055, 0.675, 0.190),
  in-quart:     cubic-bezier(0.895,  0.030, 0.685, 0.220),
  in-quint:     cubic-bezier(0.755,  0.050, 0.855, 0.060),
  in-sine:      cubic-bezier(0.470,  0.000, 0.745, 0.715),
  in-expo:      cubic-bezier(0.950,  0.050, 0.795, 0.035),
  in-circ:      cubic-bezier(0.600,  0.040, 0.980, 0.335),
  in-back:      cubic-bezier(0.600, -0.280, 0.735, 0.045),
  out-quad:     cubic-bezier(0.250,  0.460, 0.450, 0.940),
  out-cubic:    cubic-bezier(0.215,  0.610, 0.355, 1.000),
  out-quart:    cubic-bezier(0.165,  0.840, 0.440, 1.000),
  out-quint:    cubic-bezier(0.230,  1.000, 0.320, 1.000),
  out-sine:     cubic-bezier(0.390,  0.575, 0.565, 1.000),
  out-expo:     cubic-bezier(0.190,  1.000, 0.220, 1.000),
  out-circ:     cubic-bezier(0.075,  0.820, 0.165, 1.000),
  out-back:     cubic-bezier(0.175,  0.885, 0.320, 1.275),
  in-out-quad:  cubic-bezier(0.455,  0.030, 0.515, 0.955),
  in-out-cubic: cubic-bezier(0.645,  0.045, 0.355, 1.000),
  in-out-quart: cubic-bezier(0.770,  0.000, 0.175, 1.000),
  in-out-quint: cubic-bezier(0.860,  0.000, 0.070, 1.000),
  in-out-sine:  cubic-bezier(0.445,  0.050, 0.550, 0.950),
  in-out-expo:  cubic-bezier(1.000,  0.000, 0.000, 1.000),
  in-out-circ:  cubic-bezier(0.785,  0.135, 0.150, 0.860),
  in-out-back:  cubic-bezier(0.680, -0.550, 0.265, 1.550)
);

@function ease($key) {
  @if map-has-key($ease, $key) {
    @return map-get($ease, $key);
  }

  @warn "Unkown '#{$key}' in $ease.";
  @return null;
}</code></pre>
<h4>Example usage</h4>
<pre><code class="language-scss">.example {
  animation: there-and-back 2.5s ease(in-quad) infinite alternate;
}</code></pre>
<h4>Demo of all</h4>
<p>Thanks to <a rel="nofollow">Sean Dempsey</a> (<a rel="nofollow" target="_blank" href="https://twitter.com/thatseandempsey">@thatseandempsey</a>).</p>
<p class='codepen'>See the Pen <a rel="nofollow" target="_blank" href='http://codepen.io/seanseansean/pen/GgxrXw/'>Easing Map Get Function</a> by Sean Dempsey (<a rel="nofollow" target="_blank" href='http://codepen.io/seanseansean'>@seanseansean</a>) on <a rel="nofollow" target="_blank" href='http://codepen.io'>CodePen</a>.</p>]]></content:encoded>
      </item>
      <item>
         <title>Denying and Allowing Access</title>
         <link>https://css-tricks.com/snippets/htaccess/denying-allowing-access/</link>
         <description>&lt;h4&gt;Deny except from specific IPs&lt;/h4&gt;
&lt;code&gt;Order deny,allow
Deny from All
Allow from xxx.xxx.xxx.xxx
Allow from xxx.xxx.xxx.xxy&lt;/code&gt;
&lt;h4&gt;Allow except from specific IPs&lt;/h4&gt;
&lt;code&gt;Order deny,allow
Allow from All
Deny from xxx.xxx.xxx.xxx
Deny from xxx.xxx.xxx.xxy&lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=195626</guid>
         <pubDate>Wed, 11 Feb 2015 18:50:06 +0000</pubDate>
         <content:encoded><![CDATA[<h4>Deny except from specific IPs</h4>
<pre><code>Order deny,allow
Deny from All
Allow from xxx.xxx.xxx.xxx
Allow from xxx.xxx.xxx.xxy</code></pre>
<h4>Allow except from specific IPs</h4>
<pre><code>Order deny,allow
Allow from All
Deny from xxx.xxx.xxx.xxx
Deny from xxx.xxx.xxx.xxy</code></pre>]]></content:encoded>
      </item>
      <item>
         <title>Force HTTPS</title>
         <link>https://css-tricks.com/snippets/htaccess/force-https/</link>
         <description>&lt;code&gt;RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}&lt;/code&gt;
&lt;p&gt;If you have a proxy in front of your server performing TLS termination:&lt;/p&gt;
&lt;code&gt;RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}&lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=195624</guid>
         <pubDate>Wed, 11 Feb 2015 16:48:49 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code>RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}</code></pre>
<p>If you have a proxy in front of your server performing TLS termination:</p>
<pre><code>RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}</code></pre>]]></content:encoded>
      </item>
      <item>
         <title>Maintain Aspect Ratio Mixin</title>
         <link>https://css-tricks.com/snippets/sass/maintain-aspect-ratio-mixin/</link>
         <description>&lt;p&gt;&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://www.mademyday.de/css-height-equals-width-with-pure-css.html&quot;&gt;This article&lt;/a&gt; from July 2013 describes a method of using psuedo elements to maintain an elements aspect ratio, even as it scales.&lt;/p&gt;
&lt;p&gt;Here's a Sass mixin that simplifies the math a bit.&lt;/p&gt;
&lt;code class=&quot;language-scss&quot;&gt;@mixin aspect-ratio($width, $height) {
  position: relative;
  &amp;#38;:before {
    display: block;
    content: &quot;&quot;;
    width: 100%;
    padding-top: ($height / $width) * 100%;
  }
  &amp;#62; .content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
  }
}&lt;/code&gt;
&lt;p&gt;The mixin assumes you'll be nesting an element with the class of &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=195512</guid>
         <pubDate>Tue, 10 Feb 2015 21:58:35 +0000</pubDate>
         <content:encoded><![CDATA[<p><a rel="nofollow" target="_blank" href="http://www.mademyday.de/css-height-equals-width-with-pure-css.html">This article</a> from July 2013 describes a method of using psuedo elements to maintain an elements aspect ratio, even as it scales.</p>
<p>Here's a Sass mixin that simplifies the math a bit.</p>
<pre><code class="language-scss">@mixin aspect-ratio($width, $height) {
  position: relative;
  &amp;:before {
    display: block;
    content: "";
    width: 100%;
    padding-top: ($height / $width) * 100%;
  }
  &gt; .content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
  }
}</code></pre>
<p>The mixin assumes you'll be nesting an element with the class of content inside your initial block. Like this:</p>
<pre><code class="language-markup">&lt;div class="sixteen-nine"&gt;
  &lt;div class="content"&gt;
    insert content here
    this will maintain a 16:9 aspect ratio
  &lt;/div&gt;
&lt;/div&gt;</code></pre>
<p>Using the mixin is as easy as:</p>
<pre><code class="language-scss">.sixteen-nine {
  @include aspect-ratio(16, 9);
}</code></pre>
<p>Result:</p>
<pre><code class="language-css">.sixteen-nine {
  position: relative;
}
.sixteen-nine:before {
  display: block;
  content: "";
  width: 100%;
  padding-top: 56.25%;
}
.sixteen-nine &gt; .content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}</code></pre>
<h3>Demo</h3>
<p>Here's a demo showing the above code in action. The animation is added to show the element maintaining the assigned aspect ratio as it resizes.</p>
<p class='codepen'>See the Pen <a rel="nofollow" target="_blank" href='http://codepen.io/seanseansean/pen/NPwLxg/'>Maintain Aspect Ratio Demo</a> by Sean Dempsey (<a rel="nofollow" target="_blank" href='http://codepen.io/seanseansean'>@seanseansean</a>) on <a rel="nofollow" target="_blank" href='http://codepen.io'>CodePen</a>.</p>
<p>Thanks to <a rel="nofollow" target="_blank" href="http://codepen.io/seanseansean">Sean Dempsey</a> (<a rel="nofollow" target="_blank" href="http://twitter.com/thatseandempsey">@thatseandempsey</a>) for this one!</p>]]></content:encoded>
      </item>
      <item>
         <title>Placing Items on a Circle</title>
         <link>https://css-tricks.com/snippets/sass/placing-items-circle/</link>
         <description>&lt;p&gt;It can be quite challenging to place items on a circle with CSS. Usually, we end up relying on JavaScript because some plugins do it all right away. However more often than not there is no good reason to do it in JavaScript rather than CSS. This is presentational purpose, let's go the CSS way.&lt;/p&gt;
The Mixin
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://twitter.com/thebabydino&quot;&gt;Ana Tudor&lt;/a&gt; explained how she managed to do it in a &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://stackoverflow.com/questions/12813573/position-icons-into-circle&quot;&gt;Stack Overflow answer&lt;/a&gt;, using chained CSS transforms. Thereafter I turned her &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=194425</guid>
         <pubDate>Wed, 28 Jan 2015 12:22:51 +0000</pubDate>
         <content:encoded><![CDATA[<p>It can be quite challenging to place items on a circle with CSS. Usually, we end up relying on JavaScript because some plugins do it all right away. However more often than not there is no good reason to do it in JavaScript rather than CSS. This is presentational purpose, let's go the CSS way.</p>
<h3>The Mixin</h3>
<p><a rel="nofollow" target="_blank" href="https://twitter.com/thebabydino">Ana Tudor</a> explained how she managed to do it in a <a rel="nofollow" target="_blank" href="http://stackoverflow.com/questions/12813573/position-icons-into-circle">Stack Overflow answer</a>, using chained CSS transforms. Thereafter I turned her solution into a Sass mixin to make everything a breeze.</p>
<pre class="language-scss"><code>/// Mixin to place items on a circle
/// @author Hugo Giraudel
/// @author Ana Tudor
/// @param {Integer} $item-count - Number of items on the circle
/// @param {Length} $circle-size - Large circle size
/// @param {Length} $item-size - Single item size
@mixin on-circle($item-count, $circle-size, $item-size) {
  position: relative;
  width:  $circle-size;
  height: $circle-size;
  padding: 0;
  border-radius: 50%; 
  list-style: none;       
  
  &gt; * {
    display: block;
    position: absolute;
    top:  50%; 
    left: 50%;
    width:  $item-size;
    height: $item-size;
    margin: -($item-size / 2);
  
    $angle: (360 / $item-count);
    $rot: 0;

    @for $i from 1 through $item-count {
      &amp;:nth-of-type(#{$i}) {
        transform: 
          rotate($rot * 1deg) 
          translate($circle-size / 2) 
          rotate($rot * -1deg);
      }

      $rot: $rot + $angle;
    }
  }
}</code></pre>
<p><strong>Caution!</strong> Vendor prefixes have been omitted from this code snippet. Be sure to prefix <code>transform</code> if you do not use <a rel="nofollow" target="_blank" href="https://github.com/postcss/autoprefixer">Autoprefix</a>.</p>
<h3>Demo</h3>
<p>For demo purposes, we'll consider a list of 8 images but basically anything could work.</p>
<pre class="language-markup"><code>&lt;ul class='circle-container'&gt;
  &lt;li&gt;&lt;img src='http://lorempixel.com/100/100/city' alt="..." /&gt;&lt;/li&gt;
  &lt;li&gt;&lt;img src='http://lorempixel.com/100/100/nature' alt="..." /&gt;&lt;/li&gt;
  &lt;li&gt;&lt;img src='http://lorempixel.com/100/100/abstract' alt="..." /&gt;&lt;/li&gt;
  &lt;li&gt;&lt;img src='http://lorempixel.com/100/100/cats' alt="..." /&gt;&lt;/li&gt;
  &lt;li&gt;&lt;img src='http://lorempixel.com/100/100/food' alt="..." /&gt;&lt;/li&gt;
  &lt;li&gt;&lt;img src='http://lorempixel.com/100/100/animals' alt="..." /&gt;&lt;/li&gt;
  &lt;li&gt;&lt;img src='http://lorempixel.com/100/100/business' alt="..." /&gt;&lt;/li&gt;
  &lt;li&gt;&lt;img src='http://lorempixel.com/100/100/people' alt="..." /&gt;&lt;/li&gt;
&lt;/ul&gt;</code></pre>
<pre class="language-scss"><code>.circle-container {
  @include on-circle($item-count: 8, $circle-size: 20em, $item-size: 6em); 
  margin: 5em auto 0;
  border: solid 5px tomato;
  
  img { 
    display: block; 
    max-width: 100%; 
    border-radius: 50%;
    filter: grayscale(100%);
    border: solid 5px tomato;
    transition: .15s;
    
    &amp;:hover,
    &amp;:active {
      filter: grayscale(0);
    }
  }
}</code></pre>
<p class='codepen'>See the Pen <a rel="nofollow" target="_blank" href='http://codepen.io/HugoGiraudel/pen/vEJXGm/'>Items on circle</a> by Hugo Giraudel (<a rel="nofollow" target="_blank" href='http://codepen.io/HugoGiraudel'>@HugoGiraudel</a>) on <a rel="nofollow" target="_blank" href='http://codepen.io'>CodePen</a>.</p>]]></content:encoded>
      </item>
      <item>
         <title>Removing Jetpack CSS</title>
         <link>https://css-tricks.com/snippets/wordpress/removing-jetpack-css/</link>
         <description>&lt;p&gt;&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://jetpack.me/&quot;&gt;Jetpack&lt;/a&gt; is a WordPress plugin that brings a ton of features to WordPress. You turn on the features as needed. At the time of this writing, rather than include a separate CSS file for each feature as needed, they load a large concatenated stylesheet with all the CSS together. &lt;/p&gt;
&lt;p&gt;I was in a position where I was using a few Jetpack features but actually needed none of the CSS. This is what was able to completely stop any Jetpack CSS &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=190541</guid>
         <pubDate>Wed, 10 Dec 2014 21:45:43 +0000</pubDate>
         <content:encoded><![CDATA[<p><a rel="nofollow" target="_blank" href="http://jetpack.me/">Jetpack</a> is a WordPress plugin that brings a ton of features to WordPress. You turn on the features as needed. At the time of this writing, rather than include a separate CSS file for each feature as needed, they load a large concatenated stylesheet with all the CSS together. </p>
<p>I was in a position where I was using a few Jetpack features but actually needed none of the CSS. This is what was able to completely stop any Jetpack CSS for me (for functions.php, or functionality plugin):</p>
<pre><code class="language-markup">// First, make sure Jetpack doesn't concatenate all its CSS
add_filter( 'jetpack_implode_frontend_css', '__return_false' );

// Then, remove each CSS file, one at a time
function jeherve_remove_all_jp_css() {
  wp_deregister_style( 'AtD_style' ); // After the Deadline
  wp_deregister_style( 'jetpack_likes' ); // Likes
  wp_deregister_style( 'jetpack_related-posts' ); //Related Posts
  wp_deregister_style( 'jetpack-carousel' ); // Carousel
  wp_deregister_style( 'grunion.css' ); // Grunion contact form
  wp_deregister_style( 'the-neverending-homepage' ); // Infinite Scroll
  wp_deregister_style( 'infinity-twentyten' ); // Infinite Scroll - Twentyten Theme
  wp_deregister_style( 'infinity-twentyeleven' ); // Infinite Scroll - Twentyeleven Theme
  wp_deregister_style( 'infinity-twentytwelve' ); // Infinite Scroll - Twentytwelve Theme
  wp_deregister_style( 'noticons' ); // Notes
  wp_deregister_style( 'post-by-email' ); // Post by Email
  wp_deregister_style( 'publicize' ); // Publicize
  wp_deregister_style( 'sharedaddy' ); // Sharedaddy
  wp_deregister_style( 'sharing' ); // Sharedaddy Sharing
  wp_deregister_style( 'stats_reports_css' ); // Stats
  wp_deregister_style( 'jetpack-widgets' ); // Widgets
  wp_deregister_style( 'jetpack-slideshow' ); // Slideshows
  wp_deregister_style( 'presentations' ); // Presentation shortcode
  wp_deregister_style( 'jetpack-subscriptions' ); // Subscriptions
  wp_deregister_style( 'tiled-gallery' ); // Tiled Galleries
  wp_deregister_style( 'widget-conditions' ); // Widget Visibility
  wp_deregister_style( 'jetpack_display_posts_widget' ); // Display Posts Widget
  wp_deregister_style( 'gravatar-profile-widget' ); // Gravatar Widget
  wp_deregister_style( 'widget-grid-and-list' ); // Top Posts widget
  wp_deregister_style( 'jetpack-widgets' ); // Widgets
}
add_action('wp_print_styles', 'jeherve_remove_all_jp_css' );</code></pre>
<p>Thanks to <a rel="nofollow" target="_blank" href="https://twitter.com/jonbellah/status/542012394952613889">Jon Bellah</a>, <a rel="nofollow" target="_blank" href="http://www.tjkelly.com/blog/remove-wordpress-jetpack-css/">TJ Kelly</a>, <a rel="nofollow" target="_blank" href="https://twitter.com/daljo628/status/542011696030941184">George Stephanis</a>, and everyone else who chimed in to help me.</p>
<p>I suspect this will change over time. It seems to me the best possible way to do this would be to serve a concatenated stylesheet for just the featured you have turned on, and have a single named thing you can deregister.</p>]]></content:encoded>
      </item>
      <item>
         <title>Done Resizing Event</title>
         <link>https://css-tricks.com/snippets/jquery/done-resizing-event/</link>
         <description>&lt;p&gt;If you're used to something like &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://jqueryui.com/resizable/&quot;&gt;jQuery UI resizeable&lt;/a&gt;, you get events you can bind to during the resizing, but also at the &lt;em&gt;end&lt;/em&gt; of resizing.&lt;/p&gt;
&lt;p&gt;No such event exists in native JavaScript.&lt;/p&gt;
&lt;p&gt;You can fake it by setting a timeout to run the code you want to run when resizing stops. Then clear that timeout every time a resize event fires. That way the timeout will only finish if that timeout actually finishes.&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;var resizeTimer;

$(window).on('resize', function(e) {

  &lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=185617</guid>
         <pubDate>Tue, 07 Oct 2014 01:53:07 +0000</pubDate>
         <content:encoded><![CDATA[<p>If you're used to something like <a rel="nofollow" target="_blank" href="http://jqueryui.com/resizable/">jQuery UI resizeable</a>, you get events you can bind to during the resizing, but also at the <em>end</em> of resizing.</p>
<p>No such event exists in native JavaScript.</p>
<p>You can fake it by setting a timeout to run the code you want to run when resizing stops. Then clear that timeout every time a resize event fires. That way the timeout will only finish if that timeout actually finishes.</p>
<pre><code class="language-javascript">var resizeTimer;

$(window).on('resize', function(e) {

  clearTimeout(resizeTimer);
  resizeTimer = setTimeout(function() {

    // Run code here, resizing has "stopped"
            
  }, 250);

});</code></pre>
<p>Similar to <a rel="nofollow" target="_blank" href="http://davidwalsh.name/javascript-debounce-function">debouncing</a>.</p>]]></content:encoded>
      </item>
      <item>
         <title>A Complete Guide to Grid</title>
         <link>https://css-tricks.com/snippets/css/complete-guide-grid/</link>
         <description>This article is &lt;strong&gt;in-progress&lt;/strong&gt;. We're trying to stay on-top of grid layout and make sure we have some information about it. But know that grid is extremely new, not well supported, and in-flux in browserland still.

&lt;p&gt;The &lt;code&gt;grid&lt;/code&gt; property in CSS is the foundation of Grid Layout. It aims at fixing issues with older layout techniques like &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://css-tricks.com/almanac/properties/f/float/&quot;&gt;float&lt;/a&gt; and &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://css-tricks.com/almanac/properties/d/display/#inline-block&quot;&gt;inline-block&lt;/a&gt;, which both have issues and weren't really designed for page layout.&lt;/p&gt;
&lt;p&gt;You start by establishing a grid context &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=177225</guid>
         <pubDate>Thu, 14 Aug 2014 14:33:12 +0000</pubDate>
         <content:encoded><![CDATA[<div class="explanation">
This article is <strong>in-progress</strong>. We're trying to stay on-top of grid layout and make sure we have some information about it. But know that grid is extremely new, not well supported, and in-flux in browserland still.
</div>
<p>The <code>grid</code> property in CSS is the foundation of Grid Layout. It aims at fixing issues with older layout techniques like <a rel="nofollow" target="_blank" href="http://css-tricks.com/almanac/properties/f/float/">float</a> and <a rel="nofollow" target="_blank" href="http://css-tricks.com/almanac/properties/d/display/#inline-block">inline-block</a>, which both have issues and weren't really designed for page layout.</p>
<p>You start by establishing a grid context on an element:</p>
<pre><code class="language-css">.area {
  display: -ms-grid; /* prefix for IE 10 */
  display: grid; /* or inline-grid */
}</code></pre>
<p>Then you define what that grid layout will be like. Think columns and rows like a spreadsheet (or table). Then, you can define for each child a column and a row (resulting in a cell). <strong>No markup changing is involved; everything is done through CSS.</strong></p>
<p>Along with the fact this method fixes the issues we encounter with older layout techniques, its main benefit is <strong>you can display a page in a way which can differ from the flow order</strong>.</p>
<h3>Properties</h3>
<p>Since CSS Grid Layout is a whole module and not a single property, it gathers a bunch of properties meant to be used together. Some are meant to be set on the parent (grid) element, others on the children.</p>
<ul>
<li class="page_item page-item-177032"><a rel="nofollow" target="_blank" href="http://css-tricks.com/almanac/properties/g/grid-row-column/">grid-row / grid-column</a></li>
<li class="page_item page-item-177014"><a rel="nofollow" target="_blank" href="http://css-tricks.com/almanac/properties/g/grid-row-column-align/">grid-row-align / grid-column-align</a></li>
<li class="page_item page-item-177027"><a rel="nofollow" target="_blank" href="http://css-tricks.com/almanac/properties/g/grid-row-column-span/">grid-row-span / grid-column-span</a></li>
<li class="page_item page-item-177030"><a rel="nofollow" target="_blank" href="http://css-tricks.com/almanac/properties/g/grid-rows-columns/">grid-rows / grid-columns</a></li>
</ul>
<h3>The `fr` Unit</h3>
<p>The <code>fr</code> unit can be used for <code>grid-rows</code> and <code>grid-columns</code> values. It stands for <em>"fraction of available space"</em>. Think of it as <em>percentages for available space</em> when you've taken off fixed-sized and content-based columns/rows. As the spec says:</p>
<blockquote><p>The distribution of fractional space occurs after all 'length' or content-based row and column sizes have reached their maximum.</p></blockquote>
<h3>Coming Soon</h3>
<p>The properties listed so far are the very basics to use the grid layout; they are also the first (and currently only) properties to be supported in this module.</p>
<p>According to the official specifications, there are a lot more involved including:</p>
<ul>
<li><code>grid-template</code>: allows grid definition through a template of identifiers</li>
<li><code>grid-column-position</code>: current <code>grid-column</code> since <code>grid-column </code>is supposed to be a shorthand for <code>grid-column-position</code> and <code>grid-column-span</code></li>
<li><code>grid-row-position</code>: same as above</li>
<li><code>grid-position</code>: shorthand for <code>grid-column-position</code> and <code>grid-row-position</code></li>
<li><code>grid-span</code>: shorthand for <code>grid-column-span</code> and <code>grid-row-span</code></li>
<li><code>grid-area</code>: shorthand for <code>grid-column-position</code>, <code>grid-row-position</code>, <code>grid-column-span</code> and <code>grid-row-span</code></li>
<li><code>grid-auto-columns</code>: change default size for columns</li>
<li><code>grid-auto-rows</code>: change default size for rows</li>
<li><code>grid-auto-flow</code>: allows grid-items to automatically flow in available cells</li>
</ul>
<p>Unfortunately, these properties are currently unsupported. We'll update this article over time to document and include examples.</p>
<h3>Example</h3>
<p>Consider a structure like the following:</p>
<pre><code class="language-markup">&lt;div class="main"&gt;My awesome content here&lt;/div&gt;
&lt;footer class="footer"&gt;Some informations here&lt;/footer&gt;
&lt;header class="header"&gt;My site title goes here&lt;/header&gt;
&lt;aside class="sidebar"&gt;Here is my side content&lt;/aside&gt;</code></pre>
<p>Note how the markup order has absolutely no impact on the final rendering.</p>
<pre><code class="language-css">body {
 /* First, we define body as a grid element */
 display: grid;
   
 /* Then, we define the number of columns we want by setting their dimensions */
 /* Beware, gaps between columns will be actual columns too */
 /* 1. This means there are 3 columns: 
  * the first one is 200px wide
  * the second one will be a margin (1%) 
  * the third one will occupy the remaining space 
  */
 grid-columns: 200px 1% 1fr; /* 1 */
   
 /* Now we define the number of rows and their dimensions */
 /* 2. this means there are 5 rows: 
  * the first one will be sized according to its content
  * the second one will be a margin
  * the third one will be sized according to its content
  * the fourth one will be a margin as well
  * the last one will be sized according to its content 
  */
 grid-rows: auto 15px auto 15px auto; /* 2 */
   
 /* The body element is now a 3*5 grid. */
}
 
/* Both the header and the footer will be full width, so we have to make them occupy the 3 columns */
.header, 
.footer {
  grid-column-span: 3;
}

/* Let's define in which row the header will be: the first one */
.header {
  grid-row: 1;
}
 
/* Same for the footer: the last one so the fifth (remember margins count as cols/rows */
.footer {
  grid-row: 5;
}
 
.sidebar {
  /* The sidebar will occupy the first column which is 200px wide */
  grid-column: 1;
  /* And the 3rd row (there are the header and a margin before) */
  grid-row: 3;
}
 
.main {
  /* The main content will be on the 3rd column and the 3rd row */
 grid-column: 3;
 grid-row: 3;
}</code></pre>
<p>With a few other lines of CSS to handle styling issues, we have a decent layout with absolutely no floats, no inline-blocks, no defined widths, no defined heights and no margins and completely independant of the flow order. Pretty neat, right?</p>
<pre class="codepen"><code></code><a rel="nofollow" target="_blank" href="http://codepen.io/HugoGiraudel/pen/snrcj">Check out this Pen!</a></pre>
<div class="explanation">If you see the 4 parts one under the other, your browser doesn't support CSS Grids. Please switch to a supported browser to enjoy the demo.</div>
<p>Now let's add a 2nd sidebar to, for instance, display ads. It will be on the right side of the main content. There are a few tweaks to do in order to make everything works.</p>
<pre><code class="language-css">/* We first change the grid-columns definition on the grid element to add 2 new columns: one margin and one sidebar */
body {
  display: grid;
  grid-columns: 200px 1% 1fr 1% 100px;
  grid-rows: auto 15px auto 15px auto;
  /* We could have writen grid-rows: auto (15px auto)[2] */
}

/* Both the header and the footer will expand to 5 columns instead of 3 */
.header, .footer {
  grid-column-span: 5;
}

.ads {
  grid-column: 5;
  grid-row: 3;
}</code></pre>
<p>Done! We now have a layout with full-width header and footer, 3-columns on the main part including 2 fixed-width columns with about 13 lines of CSS.</p>
<pre class="codepen"><code></code><a rel="nofollow" target="_blank" href="http://codepen.io/HugoGiraudel/pen/plhDk">Check out this Pen!</a></pre>
<div class="explanation">If you see the 5 parts one under the other, your browser doesn't support CSS Grids. Please switch to a supported browser to enjoy the demo.</div>
<p>What about responsive design? Easy as a pie. Let's slightly tweak our design when under 600px device width.</p>
<pre><code class="language-css">@media all and (max-width: 600px) {
  body {
    /* First, we make the body 1-column and 5 rows spaced by 4 margin rows */
    grid-columns: 1fr;
    grid-rows: auto (1% auto)[4];
    /* This is the same as:
     * grid-rows: auto 1% auto 1% auto 1% auto 1% auto;
     */
  }
  
  /* Then we say to all elements they belong in the only existing column */
  .header, .ads, .sidebar, .main, .footer {
    grid-column: 1;
  }
  
  /* Now we define their row; don't forget spacing rows! */
  .header  { grid-row: 1; }
  .ads     { grid-row: 3; }
  .main    { grid-row: 5; }
  .sidebar { grid-row: 7; }
  .footer  { grid-row: 9; }
  
  /* We even can create grids inside grids */
  .ads {
    display: grid;
    grid-columns: 1% (32% 1%)[3]; /* 1% 32% 1% 32% 1% 32% 1% */
    grid-rows: 2; /* One for the title, one for the images */
  }
  
  .ads h2  { grid-row: 1; grid-column-span: 3; }
  .ads img { grid-row: 2; }
  .ads img:nth-of-type(1) { grid-column: 2; }
  .ads img:nth-of-type(2) { grid-column: 4; }
  .ads img:nth-of-type(3) { grid-column: 6; }
}</code></pre>
<p>Have a look at <a rel="nofollow" target="_blank" href="http://codepen.io/HugoGiraudel/pen/2befd6d225b69912af8561f7cb020124">this Pen</a> and resize your browser to see the magic!</p>
<p>Here is a grid system made with CSS Grid Layout and Sass:</p>
<pre class="codepen"><code></code><a rel="nofollow" target="_blank" href="http://codepen.io/HugoGiraudel/pen/pHLlr">Check out this Pen!</a></pre>
<div class="explanation">If you see all items one under the other, your browser doesn't support CSS Grids. Please switch to a supported browser to enjoy the demo.</div>
<p>If you feel uncomfortable with the idea of having columns and rows as margins, I guess you can still use actual margins on element but that defeats the purpose a bit. Or you could use a CSS preprocessor to ease you the calculations; here is a <a rel="nofollow" target="_blank" href="http://codepen.io/HugoGiraudel/pen/bf9765f98147be052535f4d767a040eb">demo</a>.</p>
<h3>Related</h3>
<ul>
<li><a rel="nofollow" target="_blank" href="http://css-tricks.com/using-flexbox/">Flexbox</a></li>
</ul>
<h3>Other Resources</h3>
<ul>
<li><a rel="nofollow" target="_blank" href="http://www.w3.org/TR/css3-grid-layout/">CSS Grid Layout in the CSS specifications</a></li>
<li><a rel="nofollow" target="_blank" href="http://msdn.microsoft.com/en-us/library/ie/hh673533(v=vs.85).aspx">CSS Grid Layout by Microsoft</a></li>
<li><a rel="nofollow" target="_blank" href="http://ie.microsoft.com/testdrive/Graphics/hands-on-css3/hands-on_grid.htm">Microsoft's CSS Grid layout playground</a></li>
<li><a rel="nofollow" target="_blank" href="http://24ways.org/2012/css3-grid-layout/">CSS Grid Layout by 24Ways</a></li>
<li><a rel="nofollow" target="_blank" href="http://hugogiraudel.com/2013/04/04/css-grid-layout/">Future of CSS Layout: Grids</a></li>
</ul>
<h3 id="browser-support">Browser Support</h3>
<table class="browser-support-table">
<thead>
<tr>
<th class="chrome">Chrome</th>
<th class="safari">Safari</th>
<th class="firefox">Firefox</th>
<th class="opera">Opera</th>
<th class="ie">IE</th>
<th class="android">Android</th>
<th class="iOS">iOS</th>
</tr>
</thead>
<tbody>
<tr>
<td class="nope">none</td>
<td class="nope">none</td>
<td class="nope">none</td>
<td class="nope">none</td>
<td class="yep">10+</td>
<td class="nope">none</td>
<td class="nope">none</td>
</tr>
</tbody>
</table>
<p>Support coming in WebKit/Blink and Gecko (currently in some nightly builds).</p>]]></content:encoded>
      </item>
      <item>
         <title>Increase Custom Fields Dropdown Limit</title>
         <link>https://css-tricks.com/snippets/wordpress/increase-custom-fields-dropdown-limit/</link>
         <description>&lt;p&gt;For your functions.php file or custom plugin:&lt;/p&gt;
&lt;code class=&quot;language-markup&quot;&gt;// Increase number of meta fields shown in dropdown
add_filter('postmeta_form_limit', 'customfield_limit_increase');
function customfield_limit_increase($limit) {
  $limit = 100;
  return $limit;
}&lt;/code&gt;
&lt;p&gt;Otherwise, the dropdown for Custom Fields is capped at 30 (alphabetically). &lt;/p&gt;
&lt;p&gt;Before:&lt;/p&gt;

&lt;p&gt;After:&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=178550</guid>
         <pubDate>Mon, 11 Aug 2014 15:59:07 +0000</pubDate>
         <content:encoded><![CDATA[<p>For your functions.php file or custom plugin:</p>
<pre><code class="language-markup">// Increase number of meta fields shown in dropdown
add_filter('postmeta_form_limit', 'customfield_limit_increase');
function customfield_limit_increase($limit) {
  $limit = 100;
  return $limit;
}</code></pre>
<p>Otherwise, the dropdown for Custom Fields is capped at 30 (alphabetically). </p>
<p>Before:</p>
<img src='https://cdn.css-tricks.com/wp-content/uploads/2014/08/before.png' alt=''/> 
<p>After:</p>
<img src='https://cdn.css-tricks.com/wp-content/uploads/2014/08/full-list.png' alt=''/>]]></content:encoded>
      </item>
      <item>
         <title>Remove an Element</title>
         <link>https://css-tricks.com/snippets/javascript/remove-element/</link>
         <description>&lt;p&gt;For whatever reason, an element can't destroy itself in JavaScript. jQuery &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://api.jquery.com/remove/&quot;&gt;has a method&lt;/a&gt; for this, which is nice because this is how we think:&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;$(&quot;.remove-me&quot;).remove();&lt;/code&gt;
&lt;p&gt;But there is no direct equivalent in JavaScript. Instead you'll need to select the parent element and use &lt;code&gt;removeChild&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;So if you have:&lt;/p&gt;
&lt;code class=&quot;language-markup&quot;&gt;&amp;#60;div class=&quot;module&quot;&amp;#62;
  &amp;#60;p&amp;#62;Stuff.&amp;#60;/p&amp;#62;
  &amp;#60;div class=&quot;remove-me&quot;&amp;#62;...&amp;#60;/div&amp;#62;
&amp;#60;/div&amp;#62;&lt;/code&gt;
&lt;p&gt;You'll need to do:&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;var thingToRemove = document.querySelectorAll(&quot;.remove-me&quot;)[0];

thingToRemove.parentNode.removeChild(thingToRemove);&lt;/code&gt;
&lt;p&gt;Or if you had a reference to an element and wanted to &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://stackoverflow.com/questions/13763/how-do-i-remove-a-child-node-in-html-using-javascript&quot;&gt;empty out all &lt;/a&gt;&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=175420</guid>
         <pubDate>Mon, 14 Jul 2014 23:31:04 +0000</pubDate>
         <content:encoded><![CDATA[<p>For whatever reason, an element can't destroy itself in JavaScript. jQuery <a rel="nofollow" target="_blank" href="http://api.jquery.com/remove/">has a method</a> for this, which is nice because this is how we think:</p>
<pre><code class="language-javascript">$(".remove-me").remove();</code></pre>
<p>But there is no direct equivalent in JavaScript. Instead you'll need to select the parent element and use <code>removeChild</code>. </p>
<p>So if you have:</p>
<pre><code class="language-markup">&lt;div class="module"&gt;
  &lt;p&gt;Stuff.&lt;/p&gt;
  &lt;div class="remove-me"&gt;...&lt;/div&gt;
&lt;/div&gt;</code></pre>
<p>You'll need to do:</p>
<pre><code class="language-javascript">var thingToRemove = document.querySelectorAll(".remove-me")[0];

thingToRemove.parentNode.removeChild(thingToRemove);</code></pre>
<p>Or if you had a reference to an element and wanted to <a rel="nofollow" target="_blank" href="http://stackoverflow.com/questions/13763/how-do-i-remove-a-child-node-in-html-using-javascript">empty out all the elements inside it</a>, but keep it:</p>
<pre><code class="language-javascript">mydiv = document.getElementById('empty-me');
while (mydiv.firstChild) {
  mydiv.removeChild(mydiv.firstChild);
}</code></pre>]]></content:encoded>
      </item>
      <item>
         <title>Loop Over querySelectorAll Matches</title>
         <link>https://css-tricks.com/snippets/javascript/loop-queryselectorall-matches/</link>
         <description>&lt;p&gt;You can loop over Arrays really easily in JavaScript with forEach, but unfortunately it's not that simple with the results of a &lt;code&gt;querySelectorAll&lt;/code&gt;. &lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;/* Will Not Work */
document.querySelectorAll('.module').forEach(function() {
  
});&lt;/code&gt;
&lt;p&gt;That's because what you get back from &lt;code&gt;querySelectorAll&lt;/code&gt; isn't an array, it's a (non-live) NodeList.&lt;/p&gt;
&lt;p&gt;Here's &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://coderwall.com/p/jcmzxw&quot;&gt;a quick way&lt;/a&gt; to iterate over all the found elements:&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;var divs = document.querySelectorAll('div');

[].forEach.call(divs, function(div) {
  // do whatever
  div.style.color = &quot;red&quot;;
});&lt;/code&gt;
&lt;p&gt;Fair warning, Todd Motto &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://toddmotto.com/ditch-the-array-foreach-call-nodelist-hack/&quot;&gt;explains why this method &lt;/a&gt;&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=175418</guid>
         <pubDate>Mon, 14 Jul 2014 23:12:08 +0000</pubDate>
         <content:encoded><![CDATA[<p>You can loop over Arrays really easily in JavaScript with forEach, but unfortunately it's not that simple with the results of a <code>querySelectorAll</code>. </p>
<pre><code class="language-javascript">/* Will Not Work */
document.querySelectorAll('.module').forEach(function() {
  
});</code></pre>
<p>That's because what you get back from <code>querySelectorAll</code> isn't an array, it's a (non-live) NodeList.</p>
<p>Here's <a rel="nofollow" target="_blank" href="https://coderwall.com/p/jcmzxw">a quick way</a> to iterate over all the found elements:</p>
<pre><code class="language-javascript">var divs = document.querySelectorAll('div');

[].forEach.call(divs, function(div) {
  // do whatever
  div.style.color = "red";
});</code></pre>
<p>Fair warning, Todd Motto <a rel="nofollow" target="_blank" href="http://toddmotto.com/ditch-the-array-foreach-call-nodelist-hack/">explains why this method is a rather hacky</a>, detailing over 10 problems with it. </p>
<hr>
<p>You could also use a classic for loop:</p>
<pre><code class="language-javascript">var divs = document.querySelectorAll('div'), i;

for (i = 0; i &lt; divs.length; ++i) {
  divs[i].style.color = "green";
}</code></pre>
<p>Todd's suggestion is to make your own method:</p>
<pre><code class="language-javascript">// forEach method, could be shipped as part of an Object Literal/Module
var forEach = function (array, callback, scope) {
  for (var i = 0; i &lt; array.length; i++) {
    callback.call(scope, i, array[i]); // passes back stuff we need
  }
};

// Usage:
// optionally change the scope as final parameter too, like ECMA5
var myNodeList = document.querySelectorAll('li');
forEach(myNodeList, function (index, value) {
  console.log(index, value); // passes index + value back!
});</code></pre>
<hr>
<p>There are also for..of loops, but...</p>
<pre><code class="language-javascript">/* Be warned, this only works in Firefox */

var divs = document.querySelectorAll('div );

for (var div of divs) {
  div.style.color = "blue";
}</code></pre>
<hr>
<p>This is pretty intense (probably dangerous and generally not recommended) but you could <a rel="nofollow" target="_blank" href="https://gist.github.com/DavidBruant/1016007">make</a> NodeList have the same forEach function as Array does, then use it.</p>
<pre><code class="language-javascript">NodeList.prototype.forEach = Array.prototype.forEach;

var divs = document.querySelectorAll('div').forEach(function(el) {
  el.style.color = "orange";
})</code></pre>
<hr>
<p>There is a bit more information in <a rel="nofollow" target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/NodeList">the MDN article</a>.</p>]]></content:encoded>
      </item>
      <item>
         <title>the_category with Excludes</title>
         <link>https://css-tricks.com/snippets/wordpress/the_category-excludes/</link>
         <description>&lt;p&gt;The WordPress function &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://codex.wordpress.org/Function_Reference/the_category&quot;&gt;the_category&lt;/a&gt; doesn't offer an exclude parameter. This does:&lt;/p&gt;
&lt;code class=&quot;language-markup&quot;&gt;function exclude_post_categories($excl='', $spacer=' ') {
  $categories = get_the_category($post-&amp;#62;ID);
  if (!empty($categories)) {
    $exclude = $excl;
    $exclude = explode(&quot;,&quot;, $exclude);
    $thecount = count(get_the_category()) - count($exclude);
    foreach ($categories as $cat) {
      $html = '';
      if (!in_array($cat-&amp;#62;cat_ID, $exclude)) {
        $html .= '&amp;#60;a href=&quot;' . get_category_link($cat-&amp;#62;cat_ID) . '&quot; ';
        $html .= 'title=&quot;' . $cat-&amp;#62;cat_name . '&quot;&amp;#62;' . $cat-&amp;#62;cat_name . '&amp;#60;/a&amp;#62;';
        if ($thecount &amp;#62; 1) {
          $html .= $spacer;
        }
        $thecount--;
        echo $html;
      }
    }
  &lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=175410</guid>
         <pubDate>Mon, 14 Jul 2014 22:03:32 +0000</pubDate>
         <content:encoded><![CDATA[<p>The WordPress function <a rel="nofollow" target="_blank" href="http://codex.wordpress.org/Function_Reference/the_category">the_category</a> doesn't offer an exclude parameter. This does:</p>
<pre><code class="language-markup">function exclude_post_categories($excl='', $spacer=' ') {
  $categories = get_the_category($post-&gt;ID);
  if (!empty($categories)) {
    $exclude = $excl;
    $exclude = explode(",", $exclude);
    $thecount = count(get_the_category()) - count($exclude);
    foreach ($categories as $cat) {
      $html = '';
      if (!in_array($cat-&gt;cat_ID, $exclude)) {
        $html .= '&lt;a href="' . get_category_link($cat-&gt;cat_ID) . '" ';
        $html .= 'title="' . $cat-&gt;cat_name . '"&gt;' . $cat-&gt;cat_name . '&lt;/a&gt;';
        if ($thecount &gt; 1) {
          $html .= $spacer;
        }
        $thecount--;
        echo $html;
      }
    }
  }
}</code></pre>
<p>Plus as long as you have that, you can alter the output however you want which is nice. </p>
<p>Usage is like:</p>
<pre><code class="language-markup">&lt;?php exclude_post_categories("4"); ?&gt;</code></pre>
<p>Which would list all categories excluding the one with the ID of 4.</p>]]></content:encoded>
      </item>
      <item>
         <title>Responsive Meta Tag</title>
         <link>https://css-tricks.com/snippets/html/responsive-meta-tag/</link>
         <description>&lt;p&gt;I tend to use this:&lt;/p&gt;
&lt;code class=&quot;language-markup&quot;&gt;&amp;#60;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;&amp;#62;&lt;/code&gt;
&lt;p&gt;Although I see this is recommended a lot: &lt;/p&gt;
&lt;code class=&quot;language-markup&quot;&gt;&amp;#60;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&amp;#62;&lt;/code&gt;
&lt;p&gt;This means that the browser will (probably) render the width of the page at the width of its own screen. So if that screen is 320px wide, the browser window will be 320px wide, rather than way zoomed out and showing 960px (or whatever that device does by default, in lieu of a responsive meta tag).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://blog.javierusobiaga.com/stop-using-the-viewport-tag-until-you-know-ho&quot;&gt;don't&lt;/a&gt; use a &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=165586</guid>
         <pubDate>Thu, 13 Mar 2014 19:37:13 +0000</pubDate>
         <content:encoded><![CDATA[<p>I tend to use this:</p>
<pre><code class="language-markup">&lt;meta name="viewport" content="width=device-width"&gt;</code></pre>
<p>Although I see this is recommended a lot: </p>
<pre><code class="language-markup">&lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;</code></pre>
<p>This means that the browser will (probably) render the width of the page at the width of its own screen. So if that screen is 320px wide, the browser window will be 320px wide, rather than way zoomed out and showing 960px (or whatever that device does by default, in lieu of a responsive meta tag).</p>
<p><strong>Note:</strong> <a rel="nofollow" target="_blank" href="http://blog.javierusobiaga.com/stop-using-the-viewport-tag-until-you-know-ho">don't</a> use a responsive meta tag if your website isn't specifically designed to be responsive and work well at that size, as it will make the experience worse.</p>
<p>There are <a rel="nofollow" target="_blank" href="http://www.inmotionhosting.com/support/edu/website-design/create-responsive-template/viewpoint-meta-tag-website-responsive-template">more attributes</a> this tag supports:</p>
<table class="meta-tag-chart">
<tbody>
<tr>
<th>Property</th>
<th>Description</th>
</tr>
<tr>
<td>width</td>
<td>The width of the virtual viewport of the device. </td>
</tr>
<tr>
<td>device-width</td>
<td>The physical width of the device's screen.</td>
</tr>
<tr>
<td>height</td>
<td>The  height of the "<em>virtual viewport</em>" of the device.</td>
</tr>
<tr>
<td>device-height</td>
<td>The  physical height of the device's screen.</td>
</tr>
<tr>
<td>initial-scale</td>
<td>The initial zoom when visiting the page. 1.0 does not zoom.</td>
</tr>
<tr>
<td>minimum-scale</td>
<td>The minimum amount the visitor can zoom on the page. 1.0 does not zoom.</td>
</tr>
<tr>
<td>maximum-scale</td>
<td>The maximum amount the visitor can zoom on the page. 1.0 does not zoom.</td>
</tr>
<tr>
<td>user-scalable</td>
<td>Allows the device to zoom in and out. Values are yes or no.</td>
</tr>
</tbody>
</table>
<p>It's generally recommended that you don't prevent scaling, as that's annoying and potentially an accessibility problem.</p>
<p>You'll probably <a rel="nofollow" target="_blank" href="http://timkadlec.com/2012/10/ie10-snap-mode-and-responsive-design/">want this</a> in your CSS as well:</p>
<pre><code class="language-css">@-ms-viewport{
  width: device-width;
}</code></pre>
<p>Good to know: changing the value of this meta tag with JavaScript does work, the page will react to the new value. Either out the entire tag and replace, or change the <code>content</code> property.  Not a super common need, but it can come up.</p>]]></content:encoded>
      </item>
      <item>
         <title>Print Object To Screen</title>
         <link>https://css-tricks.com/snippets/javascript/print-object-screen/</link>
         <description>&lt;p&gt;PHP has a nice &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://us2.php.net/print_r&quot;&gt;print_r&lt;/a&gt; function for printing out information about a variable to the screen. console.log() is great for that in JavaScript also, but sometimes you just need/want to look at it on the screen.&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;function print_r(o) {
  return JSON.stringify(o,null,'&amp;#92;t').replace(/&amp;#92;n/g,'&amp;#60;br&amp;#62;').replace(/&amp;#92;t/g,'&amp;#38;nbsp;&amp;#38;nbsp;&amp;#38;nbsp;'); 
}&lt;/code&gt;
&lt;p&gt;So if you have an object like: &lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;var myObject = {
   &quot;lunch&quot;: &quot;sandwich&quot;,
   &quot;dinner&quot;: &quot;stirfry&quot;
};&lt;/code&gt;
&lt;p&gt;You could do:&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;var putHere = document.getElementById(&quot;#put-here&quot;);

putHere.innerHTML = print_r(myObject);&lt;/code&gt;
&lt;p&gt;to see the result on screen. &lt;/p&gt;
&lt;p&gt;Also, &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://blog.mariusschulz.com/2013/11/13/advanced-javascript-debugging-with-consoletable&quot;&gt;console.table()&lt;/a&gt; is sometimes much better &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=163748</guid>
         <pubDate>Sat, 22 Feb 2014 17:03:11 +0000</pubDate>
         <content:encoded><![CDATA[<p>PHP has a nice <a rel="nofollow" target="_blank" href="http://us2.php.net/print_r">print_r</a> function for printing out information about a variable to the screen. console.log() is great for that in JavaScript also, but sometimes you just need/want to look at it on the screen.</p>
<pre><code class="language-javascript">function print_r(o) {
  return JSON.stringify(o,null,'&#92;t').replace(/&#92;n/g,'&lt;br&gt;').replace(/&#92;t/g,'&amp;nbsp;&amp;nbsp;&amp;nbsp;'); 
}</code></pre>
<p>So if you have an object like: </p>
<pre><code class="language-javascript">var myObject = {
   "lunch": "sandwich",
   "dinner": "stirfry"
};</code></pre>
<p>You could do:</p>
<pre><code class="language-javascript">var putHere = document.getElementById("#put-here");

putHere.innerHTML = print_r(myObject);</code></pre>
<p>to see the result on screen. </p>
<p>Also, <a rel="nofollow" target="_blank" href="http://blog.mariusschulz.com/2013/11/13/advanced-javascript-debugging-with-consoletable">console.table()</a> is sometimes much better than console.log() for this kind of thing.</p>]]></content:encoded>
      </item>
      <item>
         <title>Get Query Params as Object</title>
         <link>https://css-tricks.com/snippets/jquery/get-query-params-object/</link>
         <description>&lt;p&gt;Nicholas Ortenzio &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://github.com/youbastard/jquery.getQueryParameters&quot;&gt;wrote this&lt;/a&gt; little plugin:&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;jQuery.extend({

  getQueryParameters : function(str) {
	  return (str &amp;#124;&amp;#124; document.location.search).replace(/(^&amp;#92;?)/,'').split(&quot;&amp;#38;&quot;).map(function(n){return n = n.split(&quot;=&quot;),this[n[0]] = n[1],this}.bind({}))[0];
  }

});&lt;/code&gt;
&lt;p&gt;So if the URL is:&lt;/p&gt;
&lt;p&gt;http://codepen.io/chriscoyier/pen/uszCr?lunch=sandwich&amp;#038;dinner=stirfry&lt;/p&gt;
&lt;p&gt;You can do:&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;var queryParams = $.getQueryParameters();&lt;/code&gt;
&lt;p&gt;And &lt;code&gt;queryParams&lt;/code&gt; will be an object like:&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;{
   &quot;lunch&quot;: &quot;sandwich&quot;,
   &quot;dinner&quot;: &quot;stirfry&quot;
}&lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=163745</guid>
         <pubDate>Sat, 22 Feb 2014 16:57:54 +0000</pubDate>
         <content:encoded><![CDATA[<p>Nicholas Ortenzio <a rel="nofollow" target="_blank" href="https://github.com/youbastard/jquery.getQueryParameters">wrote this</a> little plugin:</p>
<pre><code class="language-javascript">jQuery.extend({

  getQueryParameters : function(str) {
	  return (str || document.location.search).replace(/(^&#92;?)/,'').split("&amp;").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
  }

});</code></pre>
<p>So if the URL is:</p>
<p>http://codepen.io/chriscoyier/pen/uszCr?lunch=sandwich&#038;dinner=stirfry</p>
<p>You can do:</p>
<pre><code class="language-javascript">var queryParams = $.getQueryParameters();</code></pre>
<p>And <code>queryParams</code> will be an object like:</p>
<pre><code class="language-javascript">{
   "lunch": "sandwich",
   "dinner": "stirfry"
}</code></pre>]]></content:encoded>
      </item>
      <item>
         <title>Get Featured Image URL</title>
         <link>https://css-tricks.com/snippets/wordpress/get-featured-image-url/</link>
         <description>&lt;p&gt;Post thumbnails are pretty useful and pretty easy to use in WordPress. Simply add:&lt;/p&gt;
&lt;code class=&quot;language-markup&quot;&gt;add_theme_support('post-thumbnails'); &lt;/code&gt;
&lt;p&gt;To a theme's functions.php file and you'll get a &lt;strong&gt;Featured Image&lt;/strong&gt; module on the admin screen for posts which allows you to select one. &lt;/p&gt;
&lt;p&gt;It is also very easy to output that image as an HTML &lt;code&gt;&amp;#60;img&amp;#62;&lt;/code&gt;:&lt;/p&gt;
&lt;code class=&quot;language-markup&quot;&gt;the_post_thumbnail();&lt;/code&gt;
&lt;p&gt;But what if you just need the URL? Say, you're going to use it as a &lt;code&gt;background-image&lt;/code&gt; on an element rather than a content image. Unfortunately &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=163741</guid>
         <pubDate>Sat, 22 Feb 2014 16:48:39 +0000</pubDate>
         <content:encoded><![CDATA[<p>Post thumbnails are pretty useful and pretty easy to use in WordPress. Simply add:</p>
<pre><code class="language-markup">add_theme_support('post-thumbnails'); </code></pre>
<p>To a theme's functions.php file and you'll get a <strong>Featured Image</strong> module on the admin screen for posts which allows you to select one. </p>
<p>It is also very easy to output that image as an HTML <code>&lt;img&gt;</code>:</p>
<pre><code class="language-markup">the_post_thumbnail();</code></pre>
<p>But what if you just need the URL? Say, you're going to use it as a <code>background-image</code> on an element rather than a content image. Unfortunately there is no super easy/obvious function for that. </p>
<p>Within the loop, you'll have to do:</p>
<pre><code class="language-markup">$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0];</code></pre>
<p>Then $thumb_url will be that URL.</p>]]></content:encoded>
      </item>
      <item>
         <title>Add Category Name to body_class</title>
         <link>https://css-tricks.com/snippets/wordpress/add-category-name-body_class/</link>
         <description>&lt;p&gt;The &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;https://codex.wordpress.org/Function_Reference/body_class&quot;&gt;body_class&lt;/a&gt; function is nice for adding a bunch of classes to the body tag that have information about what kind of page is currently being displayed. Probably for styling purposes. But for whatever reason, it doesn't include a class for the current category (or categories) for a single post.&lt;/p&gt;
&lt;p&gt;This adds that category &quot;nice&quot; name:&lt;/p&gt;
&lt;code class=&quot;language-markup&quot;&gt;add_filter('body_class','add_category_to_single');
function add_category_to_single($classes, $class) {
  if (is_single() ) {
    global $post;
    foreach((get_the_category($post-&amp;#62;ID)) as $category) {
      // add category slug to the $classes array
      $classes[] &lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=163742</guid>
         <pubDate>Sat, 22 Feb 2014 16:44:23 +0000</pubDate>
         <content:encoded><![CDATA[<p>The <a rel="nofollow" target="_blank" href="https://codex.wordpress.org/Function_Reference/body_class">body_class</a> function is nice for adding a bunch of classes to the body tag that have information about what kind of page is currently being displayed. Probably for styling purposes. But for whatever reason, it doesn't include a class for the current category (or categories) for a single post.</p>
<p>This adds that category "nice" name:</p>
<pre><code class="language-markup">add_filter('body_class','add_category_to_single');
function add_category_to_single($classes, $class) {
  if (is_single() ) {
    global $post;
    foreach((get_the_category($post-&gt;ID)) as $category) {
      // add category slug to the $classes array
      $classes[] = $category-&gt;category_nicename;
    }
  }
  // return the $classes array
  return $classes;
}</code></pre>]]></content:encoded>
      </item>
      <item>
         <title>Serve SVG with the Correct Content Type</title>
         <link>https://css-tricks.com/snippets/htaccess/serve-svg-correct-content-type/</link>
         <description>&lt;p&gt;If you are trying to use SVG like &lt;code&gt;&amp;#60;img src=&quot;image.svg&quot;&amp;#62;&lt;/code&gt; or as a CSS &lt;code&gt;background-image&lt;/code&gt;, and the file is linked to correctly and everything seems right, but the browser isn't displaying it, it might be because your server is serving it with an incorrect content-type.&lt;/p&gt;
&lt;p&gt;Add this to your .htaccess file at the root to fix it:&lt;/p&gt;
&lt;code class=&quot;language-markup&quot;&gt;AddType image/svg+xml .svg .svgz&lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=163734</guid>
         <pubDate>Sat, 22 Feb 2014 16:40:30 +0000</pubDate>
         <content:encoded><![CDATA[<p>If you are trying to use SVG like <code>&lt;img src="image.svg"&gt;</code> or as a CSS <code>background-image</code>, and the file is linked to correctly and everything seems right, but the browser isn't displaying it, it might be because your server is serving it with an incorrect content-type.</p>
<p>Add this to your .htaccess file at the root to fix it:</p>
<pre><code class="language-markup">AddType image/svg+xml .svg .svgz</code></pre>
<img src='https://cdn.css-tricks.com/wp-content/uploads/2014/02/wrong.png' alt=''/> 
<img src='https://cdn.css-tricks.com/wp-content/uploads/2014/02/right.png' alt=''/>]]></content:encoded>
      </item>
      <item>
         <title>Check if font-family is Honored</title>
         <link>https://css-tricks.com/snippets/javascript/check-font-family-honored/</link>
         <description>&lt;code class=&quot;language-javascript&quot;&gt;function checkFont(strFamily) {
  var objDiv = document.createElement('div');

  objDiv.style.fontFamily = strFamily;
  objDiv.appendChild(document.createTextNode('FONT TEST'));

  if (window.getComputedStyle) {
      return window.getComputedStyle(objDiv, null).getPropertyValue('font-family') === strFamily;
  }

  return objDiv.currentStyle.fontFamily === strFamily;
}&lt;/code&gt;
&lt;p&gt;Usage&lt;/p&gt;
&lt;code class=&quot;language-javascript&quot;&gt;var iconFontHonored = checkFont('icomoon');&lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=154814</guid>
         <pubDate>Thu, 31 Oct 2013 23:19:54 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code class="language-javascript">function checkFont(strFamily) {
  var objDiv = document.createElement('div');

  objDiv.style.fontFamily = strFamily;
  objDiv.appendChild(document.createTextNode('FONT TEST'));

  if (window.getComputedStyle) {
      return window.getComputedStyle(objDiv, null).getPropertyValue('font-family') === strFamily;
  }

  return objDiv.currentStyle.fontFamily === strFamily;
}</code></pre>
<p>Usage</p>
<pre><code class="language-javascript">var iconFontHonored = checkFont('icomoon');</code></pre>]]></content:encoded>
      </item>
      <item>
         <title>Move Cursor To End of Textarea or Input</title>
         <link>https://css-tricks.com/snippets/jquery/move-cursor-to-end-of-textarea-or-input/</link>
         <description>&lt;code class=&quot;language-javascript&quot;&gt;jQuery.fn.putCursorAtEnd = function() {

  return this.each(function() {

    $(this).focus()

    // If this function exists...
    if (this.setSelectionRange) {
      // ... then use it (Doesn't work in IE)

      // Double the length because Opera is inconsistent about whether a carriage return is one character or two. Sigh.
      var len = $(this).val().length * 2;

      this.setSelectionRange(len, len);
    
    } else {
    // ... otherwise replace the contents with itself
    // (Doesn't work in Google Chrome)

      $(this).val($(this).val());
      
    }

    // Scroll to the bottom, in case we're in &lt;/code&gt;&amp;#8230;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=22430</guid>
         <pubDate>Tue, 16 Jul 2013 19:27:44 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code class="language-javascript">jQuery.fn.putCursorAtEnd = function() {

  return this.each(function() {

    $(this).focus()

    // If this function exists...
    if (this.setSelectionRange) {
      // ... then use it (Doesn't work in IE)

      // Double the length because Opera is inconsistent about whether a carriage return is one character or two. Sigh.
      var len = $(this).val().length * 2;

      this.setSelectionRange(len, len);
    
    } else {
    // ... otherwise replace the contents with itself
    // (Doesn't work in Google Chrome)

      $(this).val($(this).val());
      
    }

    // Scroll to the bottom, in case we're in a tall textarea
    // (Necessary for Firefox and Google Chrome)
    this.scrollTop = 999999;

  });

};</code></pre>
<pre class="codepen"><code></code><a rel="nofollow" target="_blank" href="http://codepen.io/chriscoyier/pen/CagnJ">Check out this Pen!</a></pre>]]></content:encoded>
      </item>
      <item>
         <title>HTTP or HTTPS</title>
         <link>https://css-tricks.com/snippets/php/http-or-https/</link>
         <description>&lt;code class=&quot;language-markup&quot;&gt;if (!empty($_SERVER['HTTPS']) &amp;#38;&amp;#38; $_SERVER['HTTPS'] !== 'off'
    &amp;#124;&amp;#124; $_SERVER['SERVER_PORT'] == 443) {

  // HTTPS

} else {

  // HTTP

}&lt;/code&gt;&amp;#8230;</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>]]></content:encoded>
      </item>
      <item>
         <title>Get Width/Height of Image</title>
         <link>https://css-tricks.com/snippets/php/get-widthheight-of-image/</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(&quot;url/to/image.jpg&quot;);

  echo &quot;Image width &quot; . $width;
  echo &quot;Image height &quot; . $height;
  echo &quot;Image type &quot; . $type;
  echo &quot;Attribute &quot; . $attr;

?&amp;#62;&lt;/code&gt;&amp;#8230;</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>]]></content:encoded>
      </item>
      <item>
         <title>Import CSV into MySQL</title>
         <link>https://css-tricks.com/snippets/php/import-csv-into-mysql/</link>
         <description>&lt;code&gt;&amp;#60;?php

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

/********************************/
/* 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 &lt;/code&gt;&amp;#8230;</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>]]></content:encoded>
      </item>
      <item>
         <title>Meta Tag to Prevent Search Engine Bots</title>
         <link>https://css-tricks.com/snippets/html/meta-tag-to-prevent-search-engine-bots/</link>
         <description>&lt;p&gt;To prevent all search bots from indexing a page:&lt;/p&gt;
&lt;code&gt;&amp;#60;meta name=&quot;robots&quot; content=&quot;noindex&quot;&amp;#62;&lt;/code&gt;
&lt;p&gt;To prevent just Google:&lt;/p&gt;
&lt;code&gt;&amp;#60;meta name=&quot;googlebot&quot; content=&quot;noindex&quot;&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=&quot;privatepage.html&quot; rel=&quot;nofollow&quot;&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>]]></content:encoded>
      </item>
      <item>
         <title>Video For Everybody (HTML5 Video with Flash Fallback)</title>
         <link>https://css-tricks.com/snippets/html/video-for-everybody-html5-video-with-flash-fallback/</link>
         <description>&lt;code&gt;&amp;#60;!-- first try HTML5 playback: if serving as XML, expand `controls` to `controls=&quot;controls&quot;` 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=&quot;640&quot; height=&quot;360&quot; controls&amp;#62;
	&amp;#60;!-- MP4 must be first for iPad! --&amp;#62;
	&amp;#60;source src=&quot;__VIDEO__.MP4&quot; type=&quot;video/mp4&quot; /&amp;#62;&amp;#60;!-- Safari / iOS video    --&amp;#62;
	&amp;#60;source src=&quot;__VIDEO__.OGV&quot; type=&quot;video/ogg&quot; /&amp;#62;&amp;#60;!-- Firefox / Opera / Chrome10 --&amp;#62;
	&amp;#60;!-- fallback to Flash: --&amp;#62;
	&amp;#60;object width=&quot;640&quot; height=&quot;360&quot; type=&quot;application/x-shockwave-flash&quot; data=&quot;__FLASH__.SWF&quot;&amp;#62;
		&amp;#60;!-- Firefox uses the &lt;/code&gt;&amp;#8230;</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>]]></content:encoded>
      </item>
      <item>
         <title>Generate Expiring Amazon S3 Link</title>
         <link>https://css-tricks.com/snippets/php/generate-expiring-amazon-s3-link/</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
    &lt;/code&gt;&amp;#8230;</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>]]></content:encoded>
      </item>
      <item>
         <title>Get Current Page URL</title>
         <link>https://css-tricks.com/snippets/php/get-current-page-url/</link>
         <description>&lt;code&gt;function getUrl() {
  $url  = @( $_SERVER[&quot;HTTPS&quot;] != 'on' ) ? 'http://'.$_SERVER[&quot;SERVER_NAME&quot;] :  'https://'.$_SERVER[&quot;SERVER_NAME&quot;];
  $url .= ( $_SERVER[&quot;SERVER_PORT&quot;] !== 80 ) ? &quot;:&quot;.$_SERVER[&quot;SERVER_PORT&quot;] : &quot;&quot;;
  $url .= $_SERVER[&quot;REQUEST_URI&quot;];
  return $url;
}&lt;/code&gt;&amp;#8230;</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>]]></content:encoded>
      </item>
      <item>
         <title>Base64 Encode of 1x1px Transparent GIF</title>
         <link>https://css-tricks.com/snippets/html/base64-encode-of-1x1px-transparent-gif/</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=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot;&amp;#62;&lt;/code&gt;
&lt;p&gt;Or a black one:&lt;/p&gt;
&lt;code&gt;&amp;#60;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=&quot;&amp;#62;&lt;/code&gt;&amp;#8230;</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>]]></content:encoded>
      </item>
      <item>
         <title>Append / Prepend Files</title>
         <link>https://css-tricks.com/snippets/htaccess/append-prepend-files/</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 &quot;/real/path/to/file/functions.php&quot;
php_value auto_append_file &quot;/real/path/to/file/footer.php&quot;&lt;/code&gt;&amp;#8230;</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>]]></content:encoded>
      </item>
      <item>
         <title>Subdirectories URL Internally Redirect to Query String</title>
         <link>https://css-tricks.com/snippets/htaccess/subdirectories-redirect-query-string/</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=&quot;htaccess&quot;&gt;RewriteEngine on
RewriteRule ^index/([^/]+)/([^/]+).php /page.php?search=$1&amp;#38;sort=$2 [NC]&lt;/code&gt;&amp;#8230;</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>]]></content:encoded>
      </item>
   </channel>
</rss>
<!-- fe1.yql.bf1.yahoo.com compressed/chunked Thu Oct  1 23:11:13 UTC 2015 -->
