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

<channel>
	<title>Slash25 Code &#187; css</title>
	<atom:link href="http://slash25.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://slash25.com</link>
	<description>Code that works&#8230;, Beautifully.</description>
	<lastBuildDate>Fri, 02 Jul 2010 01:48:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using jQuery to mimic CSS3&#039;s :nth-last-child</title>
		<link>http://slash25.com/2009/06/using-jquery-to-mimic-css3s-nth-last-child/</link>
		<comments>http://slash25.com/2009/06/using-jquery-to-mimic-css3s-nth-last-child/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 03:59:06 +0000</pubDate>
		<dc:creator>patrick</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://slash25.com/?p=216</guid>
		<description><![CDATA[I came across the need for using CSS3&#8242;s :nth-last-child pseudo-selector recently. What does this do? Nth-last-child lets you select the nth (2nd, 3rd, 4th, etc) child of some element starting from the last one. For example: li:nth-last-child(-n+4) would select the last four list items in a list. To style the 2nd-to-last list item only, this [...]]]></description>
			<content:encoded><![CDATA[<p>I came across the need for using CSS3&#8242;s <a href="http://reference.sitepoint.com/css/pseudoclass-nthlastchild">:nth-last-child pseudo-selector</a> recently. What does this do? Nth-last-child lets you select the nth (2nd, 3rd, 4th, etc) child of some element starting from the last one. For example:</p>
<p><code>li:nth-last-child(-n+4)</code> would select the last four list items in a list.</p>
<p>To style the 2nd-to-last list item only, this example would work:</p>
<p><code>li:nth-last-child(-n+2)</code></p>
<p>The situation I had was there is a list of authors for a site. More than <code>wp_list_authors</code>, it was a custom-generated list of certain users. The list is styled to look like a box with two columns. There are dividers between each author both horizontally and vertically, with the bottom two authors having no bottom divider.</p>
<p>This list:</p>

<div class="wp_syntax"><div class="code"><pre class="xhtml" style="font-family:monospace;">&lt;ul id=&quot;authors&quot;&gt;
	&lt;li class=&quot;even&quot;&gt;&lt;span&gt;&lt;a class=&quot;authorImg&quot; href=&quot;&quot;&gt;
	  &lt;img src=&quot;avatar.jpg&quot; height=&quot;30px&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
	    &lt;a class=&quot;authorName&quot; href=&quot;&quot;&gt;John Doe&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
	&lt;li class=&quot;odd&quot;&gt;&lt;span&gt;&lt;a class=&quot;authorImg&quot; href=&quot;&quot;&gt;
	  &lt;img src=&quot;avatar.jpg&quot; height=&quot;30px&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
	    &lt;a class=&quot;authorName&quot; href=&quot;&quot;&gt;Hap Pill&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
...(snip)...
	&lt;li class=&quot;odd&quot;&gt;&lt;span&gt;&lt;a class=&quot;authorImg&quot; href=&quot;&quot;&gt;
	  &lt;img src=&quot;avatar.jpg&quot; height=&quot;30px&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
	    &lt;a class=&quot;authorName&quot; href=&quot;&quot;&gt;John Hancock&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
	&lt;li class=&quot;even&quot;&gt;&lt;span&gt;&lt;a class=&quot;authorImg&quot; href=&quot;&quot;&gt;
	  &lt;img src=&quot;avatar.jpg&quot; height=&quot;30px&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
	    &lt;a class=&quot;authorName&quot; href=&quot;&quot;&gt;Lorem Ipsum&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
	&lt;li class=&quot;odd&quot;&gt;&lt;span&gt;&lt;a class=&quot;authorImg&quot; href=&quot;&quot;&gt;
	  &lt;img src=&quot;avatar.jpg&quot; height=&quot;30px&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
	    &lt;a class=&quot;authorName&quot; href=&quot;&quot;&gt;Jane Doe&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></div></div>

<p>&#8230; needs to look like this:</p>
<ul id="authors">
<li class="even"><span><a class="authorImg" href="#"><img src="http://slash25.com/wp/wp-content/uploads/2009/06/avatar.jpg" height="30px" alt="" /></a><a class="authorName" href="#">John Doe</a></span></li>
<li class="odd"><span><a class="authorImg" href="#"><img src="http://slash25.com/wp/wp-content/uploads/2009/06/avatar.jpg" height="30px" alt="" /></a><a class="authorName" href="#">Hap Pill</a></span></li>
<li class="even"><span><a class="authorImg" href="#"><img src="http://slash25.com/wp/wp-content/uploads/2009/06/avatar.jpg" height="30px" alt="" /></a><a class="authorName" href="#">Foo Bar</a></span></li>
<li class="odd"><span><a class="authorImg" href="#"><img src="http://slash25.com/wp/wp-content/uploads/2009/06/avatar.jpg" height="30px" alt="" /></a><a class="authorName" href="#">Ima Doody</a></span></li>
<li class="even"><span><a class="authorImg" href="#"><img src="http://slash25.com/wp/wp-content/uploads/2009/06/avatar.jpg" height="30px" alt="" /></a><a class="authorName" href="#">Chew Bacca</a></span></li>
<li class="odd"><span><a class="authorImg" href="#"><img src="http://slash25.com/wp/wp-content/uploads/2009/06/avatar.jpg" height="30px" alt="" /></a><a class="authorName" href="#">John Hancock</a></span></li>
<li class="even"><span><a class="authorImg" href="#"><img src="http://slash25.com/wp/wp-content/uploads/2009/06/avatar.jpg" height="30px" alt="" /></a><a class="authorName" href="#">Lorem Ipsum</a></span></li>
<li class="odd"><span><a class="authorImg" href="#"><img src="http://slash25.com/wp/wp-content/uploads/2009/06/avatar.jpg" height="30px" alt="" /></a><a class="authorName" href="#">Jane Doe</a></span></li>
</ul>
<p>Removing the border on the last list item&#8217;s span is easy. Use the <code>:last-child</code> pseudo-selector and the border&#8217;s gone.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#authors</span> li<span style="color: #6666ff;">.odd</span><span style="color: #3333ff;">:last-child </span>span <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Removing the border on the 2nd-to-last one should be this easy:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#authors</span> li<span style="color: #3333ff;">:nth-last-</span>child<span style="color: #00AA00;">&#40;</span>-n<span style="color: #00AA00;">+</span><span style="color: #cc66cc;">2</span><span style="color: #00AA00;">&#41;</span> span <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>But for now, that only works in Safari 4. (and maybe Opera?) so how to get that effect in Safari 3 and Firefox 3? (I have not gotten this to work in IE7 or 6. Those are coming.) Use jQuery and a three-line script.</p>
<p>Here&#8217;s what I cobbled together from digging through the jQuery documentation:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//removes bottom border from next-to-last span in the authors listings</span>
	<span style="color: #003366; font-weight: bold;">var</span> $curr <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#authors li:last'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$curr <span style="color: #339933;">=</span> $curr.<span style="color: #660066;">prev</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$curr.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'border-bottom'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'none'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The script first locates the last list item. Then it looks for the previous element of that type, then drills down to the children elements that are spans. In this case, there&#8217;s only one. Lastly, the script applies a CSS rule of no border to the span.</p>
<p>Is it perfect? Almost. I&#8217;ll need to figure out how to get IE7 and, unfortunately for this job, IE6 to render the next-to-last item correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://slash25.com/2009/06/using-jquery-to-mimic-css3s-nth-last-child/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CSS Specificity &#8211; the basics</title>
		<link>http://slash25.com/2009/04/css-specificity-the-basics/</link>
		<comments>http://slash25.com/2009/04/css-specificity-the-basics/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 06:01:18 +0000</pubDate>
		<dc:creator>patrick</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[specificity]]></category>

		<guid isPermaLink="false">http://slash25.com/?p=182</guid>
		<description><![CDATA[Specificity is one of the most difficult topics to grasp in CSS but it doesn&#8217;t have to be. It requires two things: Basic math. (How to add, really.) How to tell the difference between an HTML element (a tag), a class, an id, and a pseudo-element That&#8217;s it. Let&#8217;s look at an example: Say you&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>Specificity is one of the most difficult topics to grasp in CSS but it doesn&#8217;t have to be. It requires two things:</p>
<ol>
<li>Basic math. (How to add, really.)</li>
<li>How to tell the difference between an HTML element (a tag), a class, an id, and a pseudo-element</li>
</ol>
<p>That&#8217;s it. Let&#8217;s look at an example:</p>
<p>Say you&#8217;ve got this in your styles:</p>
<p><code>ul li { color: black; } </code><br />
<code>li { color: red; }</code></p>
<p>What will the color of list items (li) be? Is it red, because it comes last? Is it black because we&#8217;ve got two tags in the style? The correct answer is black, but not just because we have two tags in the style. It&#8217;s because that style declaration&#8217;s specificity is greater.</p>
<p><a href="http://www.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/">Here&#8217;s the specificity math</a>:<br />
<em>element selectors (HTML tags) = 1<br />
pseudo-element selectors = 1<br />
class selectors = 10 (also psuedo-classes and attributes)<br />
id selectors = 100<br />
inline style = 1000</em></p>
<p>Looking back at the list items, the style with both the ul tag and the li tag has a specifity value of 2 (1 + 1) while the li by itself has a value of 1.</p>
<p>Let&#8217;s look at some of the styles on slash25.com.</p>
<pre>p {
	line-height: 1.5em;
	margin-bottom: 1.5em;
	}</pre>
<p>Specificity = 1</p>
<pre>div.entry div p {
	font-family: "gill sans",helvetica, sans-serif;
	font-weight: 100;
	font-size: 90%;
	letter-spacing: 1px;
	}</pre>
<p>Specificity = 13<br />
10 for .entry, 1 for div, 1 for div, 1 for p</p>
<p>What about the link styles?</p>
<pre>a {
	color: #00a0ea;
	text-decoration: none;
	border-bottom: 1px dotted #00a0ea;
	}</pre>
<p>Specificity = 1</p>
<pre>a:hover, a:focus {
	color: #000;
	border-bottom: 1px solid #000;
	}</pre>
<p>Specificity = 11 (there are two styles, each with a specificity value of 11)<br />
10 for :hover (or :focus), 1 for a</p>
<pre>#subNav li li a:hover,#subNav li li a:focus {
	color: #000;
	border-bottom: none;
	}</pre>
<p>Specificity = 113 for each.<br />
100 for #subNav, 10 for :hover (or :focus), 1 for li, 1 for li, 1 for a</p>
<p>Remember these basics and you&#8217;ll be able to calculate specificity like a pro. Then, the order in which a style appears in the CSS won&#8217;t matter as much because you&#8217;ll be able to increase the specificity of a style and have your desired effect come to life.</p>
<p><em>Are there caveats? Like all things in life, yes. The linked URL in this goes to a wonderful Smashing Magazine article in which they go into great depth. I would recommend if you&#8217;re stuck and everything seems to not work, <a href="http://slash25.com/contact">drop us a comment</a> or visit that article and see if you can&#8217;t figure it out.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://slash25.com/2009/04/css-specificity-the-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
