<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title>
			Ask the CSS Guy
		</title>
		<link>
			http://www.askthecssguy.com/
		</link>
		<description>
			Providing CSS assistance and tutorials to whoever asks - askthecssguy@gmail.com
		</description>
		<language>
			en
		</language>
		<copyright>
			Copyright 2011
		</copyright>
		<lastBuildDate>
			Thu, 16 June 2011 21:11:28 -0600
		</lastBuildDate>
		<generator>
			http://www.sixapart.com/movabletype/
		</generator>
		<docs>
			http://blogs.law.harvard.edu/tech/rss
		</docs>
		<item>
			<title>
				Update your Ask the CSS Guy RSS feed
			</title>
			<description>
<![CDATA[<p>You have a been a subscriber to my site and for that I am grateful.  I've switched over to a new host and am now using a different CMS, so this feed will not be updated going forward.  To get notified of any new posts, please <a href="http://askthecssguy.com">visit my site again</a> and subscribe from there, or follow @askthecssguy on twitter.  Muchas thanks!</p>]]>
			</description>
			<link>
				http://www.askthecssguy.com/
			</link>
			<guid>
				http://www.askthecssguy.com/
			</guid>
			<pubDate>
				Thu, 16 June 2011 21:05:45 -0600
			</pubDate>
		</item>
		<item>
			<title>
				Waqas asks the CSS Guy how to specify an alternate font size if the preferred font isn&apos;t available on the user&apos;s system
			</title>
			<description>
<![CDATA[<p>Waqas writes:</p>

<blockquote><p>Is there any way to specify alternate font size?</p>
<p>e.g.</p>
<p>p { font: 11px Tahoma, Helvetica; }</p>
<p>If Tahoma font is not available in machine, Helvetica will be used (if available) with size 11px. Is there any workaround that if Tahoma is available it will use size 11px &amp; if it is not available Helvetica will use for example 13px?</p>
</blockquote>

<p>Yes - here's a way.  I had found this article from 2007: <a href="http://www.lalit.org/lab/javascript-css-font-detect">JavaScript/CSS Font Detector</a>, so let's use that as a starting point.</p>

<p>I'll start with HTML for a simple paragraph:</p>

<pre><code class="html">&lt;p&gt;Row, row, row your boat&lt;br /&gt;
Gently down the stream.&lt;br /&gt;
Merrily, merrily, merrily, merrily&lt;br /&gt;
Life is butter dreams.&lt;/p&gt;</code></pre>

<p>And style it:</p>

<pre><code class="css">&lt;style type="text/css"&gt;
p { font: normal 28px/1.2 'Brush Script Std',Arial,sans-serif; }
&lt;/style&gt;</code></pre>

<p>And so I have two fonts: Brush Script Std as my preferred font, and Arial as my fallback.  The challenge is that supposing Brush Script Std isn't on the user's system, I want Arial to display not at 28px, but at 18px.</p>

<p>I'd approach is like this.  First set a style rule for the fallback state.  If we know that 'Brush Script Std' is available, let's use JavaScript to add a class to the <code>body</code> tag that indicates the font is good to use, like <code>&lt;body class="hasBrushScriptStd"&gt;</code>.  I could then write a separate style rule that makes use of that selector, like so:</p>

<pre><code class="css">&lt;style type="text/css"&gt;
p { font: normal 18px/1.2 Arial,sans-serif; }
<strong>.hasBrushScriptStd p { font: normal 28px/1.2 'Brush Script Std'; }</strong>
&lt;/style&gt;</code></pre>

<p>Now for the script that handles the font detection and adding of the class name to the body. I verified that Waqas isn't using jQuery, so I'm writing a couple of extra functions to handle the onload event and the adding of class names. (credits at the end of the article).</p>

<pre><code class="js">&lt;script type="text/javascript" src="fontdetect.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}
addLoadEvent(function() {
  var detective = new Detector();
  var hasBrushScriptStd = detective.test('Brush Script Std');
  if (hasBrushScriptStd == true) { 
    addClass(document.getElementsByTagName('body')[0],'hasBrushScriptStd');
  }
});
&lt;/script&gt;</code></pre>

<p><a href="http://askthecssguy.com/examples/fontdetect/index.html">Here's the final result where you can view source and copy if you wish.</a>  Know of other methods, better methods, or gotchas?  Tell me about it.</p>

<p>Script credits:</p>

<ul>
	<li>addLoadEvent function courtesy of <a href="http://simonwillison.net/2004/May/26/addLoadEvent/">Simon Willison</a>.</li>
	<li>font detection script courtesy of <a href="http://www.lalit.org/lab/javascript-css-font-detect">Lalit</a></li>
	<li>addClass script courtesy of (dunno... <a href="http://adactio.com/">Jeremy Keith</a>, maybe? I got it from his <a href="http://domscripting.com/domsters/scripts/global.js">DOM Scripting sample site</a>)</li>
</ul>]]>
			</description>
			<link>
				http://www.askthecssguy.com/2010/11/waqas_asks_the_css_guy_how_to.html
			</link>
			<guid>
				http://www.askthecssguy.com/2010/11/waqas_asks_the_css_guy_how_to.html
			</guid>
			<pubDate>
				Fri, 05 Nov 2010 16:11:28 -0600
			</pubDate>
		</item>
		<item>
			<title>
				Memphis AIGA Mini-conference
			</title>
			<description>
<![CDATA[<p>This saturday morning, October 16th,  there is a local AIGA mini-conference on topics like designing for mobile, HTML5 and CSS3 (yours truly speaking), HTML frameworks, accessibility, and more.  If you're in the Memphis area, check it out.</p>

<p><a href="http://integrateeparate.eventbrite.com/">Here are the details.</a></p>

<p>I only know two of the other speakers (JD and John Lloyd). I'm looking forward to meeting the others, but even more so, getting to meet some of the other web-savvy designers in Memphis who are interested in these topics.  Maybe I'll see you there.</p>]]>
			</description>
			<link>
				http://www.askthecssguy.com/2010/10/memphis_aiga_miniconference.html
			</link>
			<guid>
				http://www.askthecssguy.com/2010/10/memphis_aiga_miniconference.html
			</guid>
			<pubDate>
				Thu, 14 Oct 2010 09:05:45 -0600
			</pubDate>
		</item>
		<item>
			<title>
				Spinboxes Optimized for Touchscreen
			</title>
			<description>
<![CDATA[<p>So what's a spinbox?  A picture is worth a thousand words:</p>

<p><img src="http://askthecssguy.com/images/20100715_spinboxexamples.gif" alt="Spinbox examples" /></p>

<p>Here's the thousand word version (<a href="http://msdn.microsoft.com/en-us/library/bb246411%28VS.85%29.aspx">via</a>):</p>

<blockquote><p>A spin box — sometimes called a spinner control — is a collective term for the combination of a text box with an up-down control. Users can click arrow buttons (the up-down control) or press the UP ARROW or DOWN ARROW key to change the value in the text box. The value ascends or descends incrementally.</p></blockquote>

<p>I've been optimizing web forms for use in iPhones and Androids.  Not too long ago I ready <a href="http://www.lukew.com/ff/entry.asp?1014">a post by Luke Wroblewski</a> on the topic (which used hotel search forms as an example - bonus for me).  In Luke's post, he calls attention to the fact that Kayak's mobile app uses spinboxes for room and guest count instead of select drop-downs:</p>

<p><img src="http://askthecssguy.com/images/20100715_kayak.png" alt="Screenshot of Kayak's iPhone app" /></p>

<p>The up/down controls are sized and positioned optimally for input from a fingertip instead of a mouse.</p>

<p>I've seen these used in iPhone apps, but not in web forms.  I wanted to make a form that used these but wasn't sure how to mark on up. According to the <a href="http://diveintohtml5.org/forms.html">forms chapter of "Dive into HTML5"</a>, Opera will render a spinbox for <code>input type="number"</code>, and Opera even respects the <code>min</code> and <code>max</code> attributes.  That's great, but Safari doesn't respect the <code>min</code> and <code>max</code> attributes (yet), so using cool new HTML5 attributes for <code>input</code> isn't going to work for me.</p>

<p>I decided to use jQuery to dynamically create a spinbox that uses a select dropdown as it's source.  The jQuery would grab the select and all its options, create a spinbox control that dyanimically updates the hidden select as the up/down buttons are pressed, while keeping the original select hidden.</p>

<p><a href="http://askthecssguy.com/examples/tapbox/test.html">Here's an example </a> I made that I wrote specifically for webkit (iPhones, Androids, or if you want to see it in the desktop, Safari or Chrome).  Or here's a screenshot:</p>

<p><img src="http://askthecssguy.com/images/20100715_tapbox.png" alt="A touch-screen optimized spinbox example" /></p>

<p><a href="http://askthecssguy.com/examples/tapbox/tapbox.zip">Download a zip</a> if you want to play around with it.  I'm no JavaScript/jQuery expert, so I'd love to hear about any improvements. Note that my script and styles use the term 'tapbox', which was my way of saying 'touchscreen optimized spinbox'.</p>

<h3>More about spinboxes</h3>

<p>For select drop downs with few options (like in my case, 4), a spinbox is a great substitute for a select box.  Select boxes that have many options, like say 31 days in a 'day of the month' drop down, should likely stay in a select, and not be converted to a spinbox, else you risk triggering your old nintendo thumb by furiously tapping to get to the higher options.</p>

<p>Other situations in which a spinbox might be appropriate, as summed up in <a href="http://msdn.microsoft.com/en-us/library/bb246411%28VS.85%29.aspx">this article</a>:</p>

<blockquote><p>Spin boxes are useful when users don’t need to see the whole range of values in order to make a selection. For example, if the range is so familiar to users that they'll be able to infer all values from seeing just one (such as Monday indicating days of the week), consider using a spin box.</p></blockquote>]]>
			</description>
			<link>
				http://www.askthecssguy.com/2010/07/spinboxes_optimized_for_touchs.html
			</link>
			<guid>
				http://www.askthecssguy.com/2010/07/spinboxes_optimized_for_touchs.html
			</guid>
			<pubDate>
				Mon, 19 Jul 2010 10:49:12 -0600
			</pubDate>
		</item>
		<item>
			<title>
				Review of CSS Mastery, Second Edition
			</title>
			<description>
<![CDATA[<p>I don't read many technical books about web site development with CSS.  I probably learned like many of you likely did: online articles, right click/view source, firebug, and a hell of a lot of trial and error.  I never take for granted that I've been able to provide bacon and diapers for my family by learning from these freely available resources.  I'm taking a moment now for that to sink in.... it's awesome.</p>

<p>You can't do that and become a surgeon, right?  Like you can't walk up to someone who you know has recently had their appendix removed, <em>right-click, view source</em>, and replay the procedure, saving the information to implement later.  If you could, I'd imagine there'd be lots of link bait blogs with headlines like "32+ Ass-Kicking Drugs That Help Prevent Heart Disease You Should be Prescribing to Your Patients, but (Probably) Aren't."</p>

<p>Anyway, let's bring this back home.  As easy as it is to find great content all over the internet that would educate you on every possible thing you could imagine regarding what you can do with CSS, there's nothing like having a book to articulate concepts from beginning to end and provide a coherent narrative of the thought and methodology behind a technique's implementation.  Andy Budd's <a href="http://www.amazon.com/gp/product/1430223979?ie=UTF8&tag=atcg-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=1430223979">CSS Mastery: Advanced Web Standards Solutions, Second Edition</a>, accomplishes this.</p>

<p><img src="http://askthecssguy.com/images/100122_cssmastery.jpg" alt="CSS Mastery book cover snippet" /></p>

<p>CSS Mastery isn't for those just starting out (although anyone would learn something from this book if they are familiar with CSS and HTML).  This isn't something that starts out with how to specify font sizes for the <code>p</code> element.  Athough it touches on some fundamentals, you'll want to have been using CSS for a while in order to get the most out of this book.</p>

<p>Chapter 1 is called "Setting the Foundations", and addresses the use of meaningful markup, using classes vs ids, different versions of HTML and CSS, DOCTYPE, among other things.  It gets your head around some of the parts you don't learn just by zapping an element on someone else's site with Firebug.  There is a part about microformats that is mentioned here, and though it's great information, it feels out of place among the other topics in this chapter.</p>

<p>Chapter 2, "Getting Your Styles to Hit the Target", talks about selectors, specificity, inheritance, style sheet planning and organizing, and style guides.  It's good to know these before you start authoring your CSS style.  I appreciated his explanation as to why he prefers one CSS file rather than splitting it up into smaller ones.  I've noticed other authors advocate splitting them up, so it's nice to see someone of <a href="http://www.andybudd.com">Budd</a>'s stature offering some yang to balance the yin.  (Note that it all depends on the site in question in anyway.)</p>

<p>Chapter 3, "Visual Formatting Model Overview", describes the box model, differences with IE, positioning (relative/absolute/etc.) and floating.  I particularly found helpful Budd's description of how inline boxes work, and why they ignore certain properties like height and vertical padding and margins.</p>

<p>Chapter 4 is "Using Backgrounds for Effect", and talks about using images for list bullets, various rounded corner techniques (including border-radius), multiple background images, opacity (including RGBa), drop shadows, image replacement techniques, and then some.  I sensed that this chapter got beefed up a bit with the CSS 3 properties from the previous version of the book.</p>

<p>Chapter 5 is "Styling Links", and mentions all sorts of interesting ways to play up links, including creating CSS-only tooltips.</p>

<p>Chapter 6 is "Styling Lists and Creating Nav Bars", which is definitely one of the most common things I get asked about.  Not only does this chapter discuss all the various proven methods of creating CSS-styled navigation, but also has a terrific section on how to create Flickr-style image maps.</p>

<p>In Chapter 7, "Styling Forms and Data Tables", Budd shows how to style a calendar, and what markup he'd use to make various layout methods for a simple form.  This is one chapter I think is a little weak.  I would've loved to have seen this chapter fleshed out much more.  The concepts from the calendar can be applied to any table, but it would be nice to see a real data table taken on here, <a href="http://24ways.org/2005/tables-with-style">something like what happened here</a>.  And though the form concepts mentioned here are common in the wild (like a blog comment form), they feel far from leaving someone with a <em>mastery</em> of tackling forms.  It only seems to tackle basic form layout, but nothing further.  We've seen in Chapter 5 some pizazz he'd throw on links, but what about form fields?  What about warning of the inherent dangers of <a href="http://www.456bereastreet.com/archive/200705/why_styling_form_controls_with_css_is_problematic/">applying styles to form fields</a>?</p>

<p>Chapter 8, "Layout".  This is a meaty chapter, which discusses how to create fixed, elastic, and liquid layouts, and the bonuses of each.  Someone could have a field day playing with layouts and techniques used here.</p>

<p>If you've forgotten why web developers cuss IE so much, then Chapter 9, "Bugs and Bug Fixing", will help you remember.  The chapter mentions how to find and isolate bugs, and reminds you to "fix the problem, not the symptoms."  It then goes into various IE-releated bugs, why they happen, and how to prevent them.  Budd also mentions the concept of graded browser support ('graded' as opposed to 'supported'/'not supported'). Great read.</p>

<p>The final two chapters are the all-new case studies for sample sites "<a href="http://roma.cssmastery.com/">Roma Italia</a>" (by <a href="http://cameronmoll.com/">Cameron Moll</a>) and "<a href="http://climb.cssmastery.com/">Climb the Mountains</a>" (by <a href="http://www.colly.com/">Simon Collison</a>).  Moll and Collison walk through their approach to building their sites, and walk you through the implementation of various techniques.  These case studies serve as professional models for readers to learn from and experiment with.  These aren't just wireframes or isolated elements - they are fully fleshed out pages, professionally designed and developed by leaders in the field on web development.  You'll hear them describe CSS3 properties in their own words.  Although there is some overlap among all three authors in subject matter, this is a pro in two respects: 1) the case studies can be independently of the rest of the book, and 2) what concept may not have congealed under one author would hopefully click with the reader by another.</p>

<p>I have some some minor issues with the book.  This book seemed to be written over a span of time while the latest crop of browsers were just coming out.  I didn't see any mention of Internet Explorer 8, which was released in March of last year.  Also, whenever a tech book has chunks of code, and we want to illustrate what's different from one chunk of code to the next, color highlighting is very helpful.  And although this book is in color, only Chapter 8 and Chapter 10 appear to use different font colors to illustrate changes in within blocks of code and markup.  As I mentioned before, there is some slight overlap in content that the three authors were responsible for.  And while this can be helpful, for someone reading the book straight through, it seems a little weird to have concepts re-explained as if the last chapter didn't just do that.  Though I point out these issues, the pros of the book outweigh the cons by a landslide.</p>

<p>I'm sure a question might be from someone who already owns the first edition, as to whether they benefit from purchasing the second.  In my opinion, no.  I should restate that I didn't read the first edition, so take this all with a grain of salt, and I also don't pick up CSS books on a regular basis.  But I would imagine anyone who has read the first edition and has also regularly kept up with web sites like the authors' blogs, 23ways.org, alistapart.com, css-tricks.com, etc., that person may not get much more from this text.  However, if you feel out of practice with CSS sites and were wondering if you should brush off your old copy to read again, then get this one instead.</p>

<p>Recommended.  $26.  <a href="http://www.amazon.com/gp/product/1430223979?ie=UTF8&tag=atcg-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=1430223979">Available from Amazon</a>.</p>]]>
			</description>
			<link>
				http://www.askthecssguy.com/2010/01/review_of_css_mastery_second_e.html
			</link>
			<guid>
				http://www.askthecssguy.com/2010/01/review_of_css_mastery_second_e.html
			</guid>
			<pubDate>
				Fri, 22 Jan 2010 10:46:22 -0600
			</pubDate>
		</item>
		<item>
			<title>
				Monetizing your code
			</title>
			<description>
<![CDATA[<p>I've toyed with offering affiliate links to Theme Forest from this site in the past.  But since the people who typically visit my site tend to design and markup their own, it didn't seem worth it (and the click-through numbers supported that).  If anything, readers of this site would be on the selling end rather than the purchasing end.</p>

<p>Now I see that the same family of sites is offering Code Canyon, a marketplace for code, which also seems to fit the readers of my site (once again, the selling end rather than the purchasing). And if you aren't the kind of person who sells their designs and themes, perhaps you are the type of person who would be interested in monetizing your javascript image gallery, or your php contact form, or whatever.  It appears you can do that at <a href="http://codecanyon.net?ref=askthecssguy">CodeCanyon.net</a>.  (Disclaimer: Yes, I'm using my affiliate link, although it doesn't really help me that much if you are a seller, so maybe you want to buy something, too?  Go ahead, look around :) ).</p>

<p>I wonder if the quality of some of the things sold here are much better than what you can find in the jQuery plug-in repositories and free php tutorials.  Are you any of you out there buying these things?  Are any of you selling?  If so, how's it going?</p>]]>
			</description>
			<link>
				http://www.askthecssguy.com/2010/01/monetizing_your_code_2.html
			</link>
			<guid>
				http://www.askthecssguy.com/2010/01/monetizing_your_code_2.html
			</guid>
			<pubDate>
				Fri, 08 Jan 2010 20:52:30 -0600
			</pubDate>
		</item>
		<item>
			<title>
				A way we could potentially get around the fact that many web forms prevent plus signs in email addresses
			</title>
			<description>
<![CDATA[<p>Many of you are likely already familiar with the immensely useful feature of including plus signs (+) in Gmail addresses, such as the following:</p>

<pre>askthecssguy+mileycyrusfanclub@gmail.com</pre>

<p>This would allow me to sign up for account at another web site, and be able to track spam or apply filters based on everything after the plus sign.</p>

<p>The problem is that many web sites that ask for email addresses will reject addresses that contain a plus sign.  To get around this, we could do one of two things:</p>

<ol>
	<li>Contact every web site owner whose site doesn't allow plus signs, and convince them to change their form validation.</li>
	<li>Get Gmail to recognize a special string of characters as the same as '+'.</li>
</ol>


<p>I'd love to see Gmail implement a feature where a specially string of characters would serve the same purpose as '+'.  That string would be made up of commonly accepted characters, like [a-z] and [0-9], but their special combination would trigger the Gmail application to treat it like a plus sign.</p>

<p>For example, let's say Gmail enabled this for the following string of characters: zzzplussignzzz.  So I would sign up for the Miley Cyrus fan club using the following address:</p>

<pre>askthecssguy<strong>zzzplussignzzz</strong>mileycyrusfanclub@gmail.com</pre>

<p>I chose 'zzzplussignzzz' because it is unlikely to be used in a legitimate email address, and it would be easy to protect any new Gmail signups from using that string, perhaps by using the 'Sorry, that's already taken' indicator in case someone attempts to do so.</p>

]]>
			</description>
			<link>
				http://www.askthecssguy.com/2009/11/a_way_we_could_potentially_get.html
			</link>
			<guid>
				http://www.askthecssguy.com/2009/11/a_way_we_could_potentially_get.html
			</guid>
			<pubDate>
				Tue, 17 Nov 2009 22:34:18 -0600
			</pubDate>
		</item>
		<item>
			<title>
				Disabled labels and the Trilemma plugin
			</title>
			<description>
<![CDATA[<p>I'm working on a form that makes use of the disabled attribute, and the default browser settings for disabled inputs don't have as much contrast as what I'd like.  To better distinguish at a glance which inputs are disabled/enabled, I've chosen to style the labels of disabled inputs with a faint gray color.</p>

<p>Consider the differences in the screenshot below.</p>

<p><img src="http://askthecssguy.com/images/090819_regularlabels_vs_disabledlabels.gif" alt="Regular labels vs labels with a disabled class" /></p>

<p>You may also <a href="http://askthecssguy.com/examples/disabledLabels/example01.html">view a live HTML example</a> of the above form to see how disabled fields appear in your browser.</p>

<h3>HTML</h3>
<p>The difference in HTML is a small one.  The first example might have a checkbox whose HTML looks like this:</p>

<pre><code class="html">&lt;input type="checkbox" id="astronomy1" <strong>disabled="true"</strong> /&gt;
&lt;label for="astronomy1"&gt;Astronomy&lt;/label&gt;
</code></pre>

<p>While the second example, I've added <code>class="disabled"</code> to the label:</p>

<pre><code class="html">&lt;input type="checkbox" id="astronomy2" <strong>disabled="true"</strong> /&gt;
&lt;label for="astronomy2" <strong>class="disabled"</strong>&gt;Astronomy&lt;/label&gt;
</code></pre>

<h3>CSS</h3>
<p>I've chosen to apply a light gray color to any label with a class of 'disabled'.</p>

<pre><code class="css">label.disabled { color: #aaa; }</code></pre>

<hr />

<p>I found this technique to be particularly useful if you have a form that requires some fields to dynamically become disabled/enabled, in which case some JavaScript would also come in handy.  Consider the <em>trilemma</em>:</p>

<h3 id="trilemma">The Trilemma jQuery plugin</h3>
<p>According to Wikipedia, a trilemma is a difficult choice from three options.  A trilemma can also be expressed as 'a choice among three favorable options, only two of which are possible at the same time.'  That second part is where the name for this plugin came from.</p>

<p>(I found out about this term from the comments of the 2005 "<a href="http://kottke.org/05/04/pick-two">Pick Two</a>" post on kotte.org, a fun read and part inspiration for this plug-in.)</p>

<p>As my illustrative example, I've chosen the trilemma that web designers offer to their clients: <strong>Out of <em>good</em>, <em>fast</em>, and <em>cheap</em>, you can only pick two</strong>.</p>

<p>How is this represented on an online request for proposal?  I would present it as a series of checkboxes:</p>

<p><img src="http://askthecssguy.com/images/090819_designers_trilemma.gif" alt="The designers trilemma: it can be good and fast, but it wont be cheap." /></p>

<p>The trilemma plugin will disable the other checkboxes after the user checks two of them.  If the option is turned on, the plugin also applies class="disabled" to the labels of disabled inputs.</p>

<p><img src="http://askthecssguy.com/images/090819_designers_trilemma_checked.gif" alt="The designers trilemma: it can be good and fast, but it wont be cheap." /></p>

<p><a href="http://askthecssguy.com/examples/trilemma/example02.html">Try it out.</a></p>

<p>This plugin isn't limited to '2 out of 3' - the trilemma is just a way to illustrate what this plugin does.  The '2' maximum is a default setting, but you can set it to be anything.  For example, maybe you have 8 options and only wanted to allow a maximum of 5 to be checked.  So the 'trilemma' plugin is simply a jQuery plugin that allows you to limit the number of checkboxes that can be checked within a set. (Yes, changing this number to anything other than '2 out of 3' breaks the meaning of <em>trilemma</em>, but I'm ok with that.)</p>

<h4>Trilemma plugin: examples, how-tos, downloads</h4>


<p>Here are some examples.</p>

<ul>
	<li><a href="http://askthecssguy.com/examples/trilemma/example01.html">Pick 2 (out of 3)</a>: The maximum of '2' is default out of the box behavior.</li>
	<li><a href="http://askthecssguy.com/examples/trilemma/example03.html">Pick 2 (out of 5)</a>: This is the same as the previous example, except there are more to choose from.  The maximum selectable is still '2'.</li>
	<li><a href="http://askthecssguy.com/examples/trilemma/example04.html">Pick 4 (out of 5)</a>: Changes the maximum limit to something other than 2.</li>
	<li><a href="http://askthecssguy.com/examples/trilemma/example02.html">Pick 2 (out of 3) with disabled labels</a>: Adds class="disabled" to the labels of the disabled fields.</li>
	<li><a href="http://askthecssguy.com/examples/trilemma/example05.html">Pick 3 (out of 10) with disabled labels</a>: Changes the maximum limit of selectable checkboxes to something other than 2, and adds class="disabled" to the labels of the disabled fields.</li>
</ul>

<p>To install, download and insert <a href="http://jquery.com">jQuery</a> and <a href="http://askthecssguy.com/examples/trilemma/jquery.trilemma.js">jQuery.trilemma.js</a> in the head of your document, then call trilemma on whatever element contains all the checkboxes.  In the example below, it assumes all the checkboxes are wrapped in a fieldset with a class="goodFastCheapFieldset".</p>

<pre><code class="js">&lt;script src="jquery.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="jquery.trilemma.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
$(function(){
  $('fieldset.goodFastCheapFieldset').trilemma();
});
&lt;/script&gt;</code></pre>

<p>By default, trilemma only allows 2 checkboxes in the set to be checked.  To allow more, just pass a new maximum by setting 'max', like so:</p>

<pre><code class="js">$(function(){
  $('fieldset.sciences').trilemma({max:4});
});</code></pre>

<p>Also by default, trilemma won't try to set class="disabled" on the labels.  If you want to turn it on, just set it to true, like so:</p>

<pre><code class="js">$(function(){
  $('fieldset.sciences').trilemma({disablelabels:true});
});</code></pre>

<p>To use disabled labels and set a maximum other than '2', use a comma to separate those options:</p>

<pre><code class="js">$(function(){
  $('fieldset.sciences').trilemma({max:4,disablelabels:true});
});</code></pre>

<p><a href="http://askthecssguy.com/examples/trilemma/trilemma.zip">Download a zip with the trilemma plugin and examples.</a></p>

<p>If you use the disabled labels option, make sure to add something to your stylesheet, otherwise you may not notice the difference!</p>

<p>If you find this article or plugin helpful, I'd like to hear about it.  Also, consider <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2F&tag=atcg-20&linkCode=ur2&camp=1789&creative=390957">kicking off your next amazon purchase</a> using the link in my sidebar.  I get referral credit, and it costs you nothing extra.</p>

<p>Update 2/23/2010: Fixed a minor bug that involved using more than one set of checkboxes on the same page.</p>]]>
			</description>
			<link>
				http://www.askthecssguy.com/2009/08/disabled_labels_and_the_trilem.html
			</link>
			<guid>
				http://www.askthecssguy.com/2009/08/disabled_labels_and_the_trilem.html
			</guid>
			<pubDate>
				Wed, 19 Aug 2009 17:25:37 -0600
			</pubDate>
		</item>
		<item>
			<title>
				59+ Amazing (and jaw-dropping) web design-related lists with titles that will rip your face off, blow your mama&apos;s mind, and make you cry under the crushing pain of their inspiration
			</title>
			<description>
<![CDATA[<p>I couldn't resist.  The round-up post trend is growing at an unbelievable rate.  If lists are that good, then surely a <em>list of lists</em> is even better, right? Let's get started.</p>


<h3>Titles with interesting adjectives and words</h3>
<p><img src="http://askthecssguy.com/images/090803_rocketturtle.jpg" alt="" /></p>
<ol>
	<li><a href="http://www.noupe.com/css/20-wicked-proof-of-concepts-for-better-use-of-jquerycss.html">20+ Wicked Proof of Concepts for Better use of jQuery/CSS</a>
	<p>I appreciate concepts that keep the wicked from seeping through.</p>
	</li>
	<li><a href="http://spyrestudios.com/40-sexy-and-creative-typographic-logo-designs/">40 Sexy And Creative Typographic Logo Designs</a>
	<p>This is the Justin Timberlake of article titles.</p></li>
	<li><a href="http://spyrestudios.com/50-kick-ass-and-creative-dark-web-designs/">50 Kick-Ass And Creative Dark Website Designs</a>
	<p>Of all terms to use, I like 'kick-ass' the most.</p>
	</li>
	<li><a href="http://spyrestudios.com/how-to-cure-redesignitis/">6 Easy Ways To Cure A Nasty Case Of Redesign-itis</a>
	<p>I'm glad there's a 6-step program to treat this.</p>
	</li>
	<li><a href="http://dzineblog.com/2008/07/best-photoshop-layout-design-tutorials.html">27 Best Photoshop Web Layout Design Tutorials to Design Decent Web Layouts</a>
	<p>With the other lists using words like 'brilliant' and 'amazing', this title doesn't seem to be aiming high enough with 'decent'.</p>
	</li>
	<li><a href="http://econsultancy.com/blog/4129-16-bitchin-commands-and-shortcuts-for-twitter">16 bitchin' commands and shortcuts for Twitter</a>
	<p>Twitter was made for bitchin', so this works doubly well.</p></li>
</ol>

<h3>(Titles that use) parentheses</h3>
<p><img src="http://askthecssguy.com/images/090803_rocketturtle2.jpg" alt="" /></p>
<ol start="7">
	<li><a href="http://www.smashingmagazine.com/2008/09/11/75-really-useful-javascript-techniques/">75 (Really) Useful JavaScript Techniques</a>
	<p>(Really)?</p>
	</li>
	<li><a href="http://www.noupe.com/css/10-intelligent-ways-of-using-form-elements.html">10 Intelligent Ways of using [FORM] Elements</a>
	<p>Not really parentheses, but I can't imagine why brackets are being used here.</p>
	</li>
	<li><a href="http://www.seomoz.org/blog/css-properties-you-probably-never-use">15 CSS Properties You Probably Never Use (but perhaps should)</a>
	<p>..(.)</p>
	</li>
	<li><a href="http://css-tricks.com/web-nerd-terminology-explained/">Web Nerd Terminology (Explained)</a>
	<p>Am I alone or does the title work better when 'explained' is not encompassed in parentheses?</p></li>
	<li><a href="http://www.noupe.com/photoshop/50-best-of-designers-free-resources.html">50 Best-Of Designer's (NEW) Download Picks and Resources</a>
	<p>Odd placement.</p></li>
</ol>

<h3>Things your must or should do (but in some cases probably don't !)</h3>            
<p><img src="http://askthecssguy.com/images/090803_ought.jpg" alt="" /></p>
<ol start="12">
	<li><a href="http://webdeveloperplus.com/css/21-amazing-css-techniques-you-should-know/">21 Amazing CSS Techniques You Should Know</a></li>
	<li><a href="http://justcreativedesign.com/2008/03/02/30-best-font-downloads-for-designers/">30 Fonts That All Designers Must Know &amp; Should Own</a></li>
	<li><a href="http://www.3point7designs.com/blog/2008/05/08/8-fonts-you-probably-dont-use-in-css-but-should/">8 fonts you probably don't use in css, but should</a></li>
	<li><a href="http://www.seomoz.org/blog/css-properties-you-probably-never-use">15 CSS Properties You Probably Never Use (but perhaps should)</a></li>
	<li><a href="http://www.tripwiremagazine.com/tools/developer-toolbox/60-must-have-jquery-toolbox.html">60+ Must Have jQuery Toolbox</a></li>
	<li><a href="http://www.blogdesignblog.com/blog-design/30-more-must-see-comment-designs-for-blog-designers/">30 More Must See Comment Designs for Blog Designers</a></li>
	<li><a href="http://webupon.com/web-talk/nine-websites-you-should-know-about-but-probably-dont/">Nine Websites You Should Know About, But Probably Don't</a></li>
	<li><a href="http://dzineblog.com/2009/07/45-creative-business-cards.html">45 Creative Business Card Designs You Should've Seen</a></li>
	<li><a href="http://www.reencoded.com/2009/03/23/29-web-design-blogs-you-must-follow/">29 Web Design Blogs You Must Follow</a></li>
	<li><a href="http://webupon.com/services/9-more-useful-websites-you-should-know-about-but-probably-dont/">9 (More) Useful Websites You Should Know About, But Probably Don't</a></li>
</ol>
<h3>Posts that lost count of how many items are in the list, so they give up counting and slap on a plus (+) sign</h3>
<p><img src="http://askthecssguy.com/images/090803_lostcount.jpg" alt="" /></p>
<ol start="22">
	<li><a href="http://www.smashingmagazine.com/2007/06/20/ajax-javascript-solutions-for-professional-coding/">80+ AJAX-Solutions For Professional Coding</a></li>
	<li><a href="http://www.smashingmagazine.com/2007/06/12/tooltips-scripts-ajax-javascript-css-dhtml/">40+ Tooltips Scripts With AJAX, JavaScript & CSS</a></li>
	<li><a href="http://www.tripwiremagazine.com/tools/tools/25-create-amazing-image-effects-with-some-of-the-best-jquery-plugins-available.html">25+ Create Amazing Image Effects with Some of the Best jQuery Plugins Available</a></li>
	<li><a href="http://www.smashingmagazine.com/2009/01/15/45-new-jquery-techniques-for-a-good-user-experience/">45+ New jQuery Techniques For Good User Experience</a></li>
	<li><a href="http://www.reencoded.com/2009/08/01/33-online-resources-to-learn-css/">33+ Online Resources to Learn CSS</a></li>
	<li><a href="http://www.noupe.com/jquery/the-power-of-wordpress-and-jquery-30-useful-plugins-tutorials.html"> The Power of WordPress and jQuery: 25+ Useful Plugins &amp; Tutorials</a></li>
	<li><a href="http://www.noupe.com/css/21-fresh-ajax-css-tables.html">21+ Fresh Ajax CSS Tables</a></li>
	<li><a href="http://www.noupe.com/css/47-excellent-ajax-css-forms.html">47+ Excellent Ajax CSS Forms</a></li>
	<li><a href="http://www.noupe.com/jquery/50-amazing-jquery-examples-part1.html">50+ Amazing Jquery Examples- Part1</a></li>
	<li><a href="http://www.noupe.com/ajax/45-fresh-out-of-the-oven-jquery-plugins.html">45+ Fresh Out of the oven jQuery Plugins</a></li>
	<li><a href="http://www.noupe.com/javascript/23-impressive-tools-for-faster-javascriptajax-development.html">23+ Impressive Tools for Faster Javascript/Ajax Development</a></li>
	<li><a href="http://www.noupe.com/tutorial/51-best-of-jquery-tutorials-and-examples.html">51+ Best of jQuery Tutorials and Examples</a></li>
	<li><a href="http://www.noupe.com/css/form-elements-40-cssjs-styling-and-functionality-techniques.html">Form Elements: 40+ CSS/JS Styling and Functionality Techniques</a></li>
	<li><a href="http://vandelaydesign.com/blog/wordpress/custom-fields/">20+ Tutorials and Resources for Working with Custom Fields in WordPress</a></li>
	<li><a href="http://www.noupe.com/tools/13-fantastic-tools-for-knowing-how-they-are-doing-it.html">13+ Fantastic Tools For Knowing How They're Doing It</a></li>
	<li><a href="http://designm.ag/resources/headline-fonts/">50+ Fonts for Big, Bold Headlines</a></li>
	<li><a href="http://www.noupe.com/design/70-visually-impressing-header-graphics.html">70+ Visually Impressing Header Graphics</a></li>
</ol>
<h3>More round-up of round-ups</h3>
<p><img src="http://askthecssguy.com/images/090803_roundup.jpg" alt="" /></p>
<ol start="39">
	<li><a href="http://www.smashingmagazine.com/2007/01/19/53-css-techniques-you-couldnt-live-without/">53 CSS-Techniques You Couldn't Live Without</a></li>
	<li><a href="http://www.smashingmagazine.com/2008/04/15/60-more-ajax-and-javascript-solutions-for-professional-coding/">60 More AJAX- and Javascript Solutions For Professional Coding</a></li>
	<li><a href="http://www.smashingmagazine.com/2007/05/18/30-best-solutions-for-image-galleries-slideshows-lightboxes/">30 Scripts For Galleries, Slideshows and Lightboxes</a></li>
	<li><a href="http://www.webdesigndev.com/inspiration/20-creative-web-forms-for-design-inspiration">20 Creative Web Forms For Design Inspiration</a></li>
	<li><a href="http://creativenerds.co.uk/inspiration/40-most-creative-business-cards-you-will-ever-see/">40 Most Creative Business Cards You Will Ever See</a></li>
	<li><a href="http://www.smashingmagazine.com/2008/12/09/50-really-useful-css-tools/">50 Extremely Useful And Powerful CSS Tools</a></li>
	<li><a href="http://www.smashingmagazine.com/2009/06/25/35-css-lifesavers-for-efficient-web-design/">35 CSS-Lifesavers For Efficient Web Design</a></li>
	<li><a href="http://www.smashingmagazine.com/2009/07/20/50-new-css-techniques-for-your-next-web-design/">50 New CSS Techniques For Your Next Web Design</a></li>
	<li><a href="http://www.queness.com/post/456/16-impressive-flash-like-javascript-animation-inspirations-tutorials-and-plugins">16 Impressive Flash-Like Javascript Animation Inspirations, Tutorials and Plugins</a></li>
	<li><a href="http://www.webdesigneronline.co.uk/10-advance-jquery-scripts-to-take-your-website-to-the-next-level">10 Advance jQuery Scripts to take Your Website to the Next Level </a></li>
	<li><a href="http://www.smashingmagazine.com/2009/06/21/50-fresh-javascript-tools-that-will-improve-your-workflow/">50 Fresh JavaScript Tools That Will Improve Your Workflow</a></li>
	<li><a href="http://www.noupe.com/css/15-effective-tips-and-tricks-from-the-masters-of-css.html">15 Effective Tips and Tricks from the Masters of CSS</a></li>
	<li><a href="http://www.noupe.com/design/101-css-techniques-of-all-time-part-1.html">101 CSS Techniques Of All Time- Part 1</a></li>
	<li><a href="http://www.noupe.com/css/101-css-techniques-of-all-time-part2.html">101 CSS Techniques Of All Time- Part2</a></li>
	<li><a href="http://www.noupe.com/ajax/37-more-shocking-jquery-plugins.html">37 More Shocking jQuery Plugins</a></li>
	<li><a href="http://sixrevisions.com/usabilityaccessibility/14-brilliant-tools-for-evaluating-your-designs-colors/">14 Brilliant Tools for Evaluating Your Design's Colors</a></li>
	<li><a href="http://sixrevisions.com/javascript/10-impressive-javascript-animation-frameworks/">10 Impressive JavaScript Animation Frameworks</a></li>
	<li><a href="http://vandelaydesign.com/blog/design/photoshop-illustrator-tutorials/">25 Tutorials for Using Illustrator and Photoshop Together for Outstanding Results</a></li>
	<li><a href="http://www.smashingmagazine.com/2008/02/21/powerful-css-techniques-for-effective-coding/">Powerful CSS-Techniques For Effective Coding</a></li>
	<li><a href="http://www.chromaticsites.com/blog/11-reasons-why-a-web-cms-will-make-your-life-easier-and-your-wallet-fatter/">11 Reasons Why a Web CMS Will Make Your Life Easier and Your Wallet Fatter</a></li>
	<li><a href="http://spyrestudios.com/jquery-tutorials-plugins-impress-your-friends/">20 jQuery Tutorials And Plugins To Impress Your Friends</a></li>
	<li><a href="http://spyrestudios.com/podcasts-screencasts-for-designers-and-developers/">28 Sites Producing Podcasts And Screencasts To Help You Grow As A Designer And Developer</a></li>
	<li><a href="http://thefuturebuzz.com/2009/05/10/reasons-you-should-blog-and-not-just-tweet/">19 Reasons You Should Blog And Not Just Tweet</a></li>
</ol>


]]>
			</description>
			<link>
				http://www.askthecssguy.com/2009/08/59_amazing_and_jawdropping_web_1.html
			</link>
			<guid>
				http://www.askthecssguy.com/2009/08/59_amazing_and_jawdropping_web_1.html
			</guid>
			<pubDate>
				Mon, 03 Aug 2009 15:05:08 -0600
			</pubDate>
		</item>
		<item>
			<title>
				CSS image replacement for... images? It makes sense for print.
			</title>
			<description>
<![CDATA[<p>Sites with dark backgrounds lend themselves well to white or light-colored logos. The result can be nice on screen, but if the site is printed, there can be undesirable results: either the logo doesn't show up, or if it was saved as a transparent gif, it shows with jagged pixelated edges where the edges are meant to blend in with a dark background color.</p>

<p><img alt="tees crossed printed logo" src="/images/090625_teesCrossedPrinted.gif"/></p>


<p>One way people get around this is by including two logos on their site, hiding the one for print in the screens css, and vice versa. It works, but it includes twice as many <code>img</code> tags as what is really necessary.</p>

<p>A method I've had success with is calling a print-optimized image in the html, and using CSS to swap out the image with a screen-friendly one.</p>

<p>Compare what happens <a href="/examples/teescrossed/index01.html">when you don't do this</a> to <a href="/examples/teescrossed/index02.html">when you do</a>.</p>


<h3>HTML</h3>

<pre><code class="html">&lt;img id="logo" src="logo_print.gif" alt="my bloggy-blog" /&gt;</code></pre>

<h3>CSS</h3>
<pre><code class="css">#logo {
   background:transparent url(logo_screen.gif) no-repeat top left;
   height:0;
   overflow:hidden;
   padding-top: 100px; /* height of logo for screen */
   width: 100px; /* width of logo for screen */
}</code></pre>

<p>The height:0; and overflow: hidden; combo makes sure that I don't see the logo intended for print on the screen.  By adding a width and padding-top to that image, I can set my screen-optimized logo as the background-image.  The width and padding-top should match the width and height of the image you want to show up.</p>

<p>This came about by reading David Shea's <a href="http://www.mezzoblue.com/tests/revised-image-replacement/">image replacement tests</a>.  I like the <a href="http://www.moronicbajebus.com/playground/cssplay/image-replacement/">Leahy</a>/<a href="http://www.kryogenix.org/code/browser/lir/">Langridge</a> method of image replacement because it requires no extra markup, but this image replacement technique has some cons (as they all do) when it is used to replace text.</p>

<h3>If it has cons, why do you think it's an ok idea?</h3>

<p>One usually reads about image replacement to replace text, and issues that typically come up are what to do when images are disabled, when CSS is disabled, or what extra markup has to be included to make the effect work.  Since I'm using image replacement technique to replace an <em>image</em>, these become non-issues.  If images are off, it's the same effect as not using the technique at all - alt attribute values are shown instead.  If CSS is off, the print-friendly logo is likely the favored image to show anyway.  Also, no extra markup is needed - we manipulate the existing <code>img</code> tag and nothing else.</p>

<p>Presenting a src for the print-optimized logo in the HTML, even though it doesn't get shown, feels a little weird, though, doesn't it?  You might feel better if you set the src for the screen-optimized logo, and then use a rule in the print style sheet to swap out for the print-optimized one.  But <a href="/examples/teescrossed/index03.html">that doesn't work</a> - remember that printing of background images is not enabled in browsers (by default, anyway).</p>

<p>So I'm sure you've seen plenty of sites that have a dark background with a white logo on them.  You may even have one yourself.  Go give them print preview and see how it's handled.  Sometimes (as in the case of this site), text is an acceptable fallback, but if the logo is set as an image, hopefully it is represented well in print.</p>
]]>
			</description>
			<link>
				http://www.askthecssguy.com/2009/06/css_image_replacement_for_imag.html
			</link>
			<guid>
				http://www.askthecssguy.com/2009/06/css_image_replacement_for_imag.html
			</guid>
			<pubDate>
				Thu, 25 Jun 2009 17:08:25 -0600
			</pubDate>
		</item>
		<item>
			<title>
<![CDATA[Troubleshooting with &lt;base&gt;]]>
			</title>
			<description>
<![CDATA[<p>As powerful as Firebug is for inserting HTML and CSS on the fly, sometimes you just want to save a local version of the page so that HTML manipulation can be saved and tested across browsers.</p>

<p>I just wanted to share a tip on how easy this is to do.  Right click, view source, and save it as an html file.  If you're lucky, the page will load right up, bringing in the CSS/JavaScript files that's being used on its original domain.</p>

<p>For some sites, you have to give a little guidance.  Like today, I went to <a href="http://www.wired.com">wired.com</a>, viewed and saved the html source.  You can view the result <a href="/examples/usingBase/as_is.html">here</a>.</p>

<p>Yuck, it's missing styles.  That's not what we wanted.</p>

<p>But by inserting a little code in <code>head</code>, we can grab everything the page uses from the site.  After the opening <code>head</code> tag, insert the following:</p>

<pre><code class="html">&lt;base href="http://www.wired.com/" /&gt;</code></pre>

<p>and then resave the file.  <a href="/examples/usingBase/adding_base.html">View the result</a>, and you should see the page just as it is meant to be seen at its original address.</p>

<p>I can modify my local copy to my heart's content, putting new or modified CSS in <code>style</code> tags until I have it just right, then commit the changes to something more permanent. I use this all the time when troubleshooting defects, especially when needing to see how inserting some new element in the HTML will affect IE.  Hopefully, it will help some of you, too.</p>

<p>And note that the wired.com example might work for today, but if they ever redesign, this article's example won't mean jack.  I apologize in advance.</p>]]>
			</description>
			<link>
				http://www.askthecssguy.com/2009/03/troubleshooting_with.html
			</link>
			<guid>
				http://www.askthecssguy.com/2009/03/troubleshooting_with.html
			</guid>
			<pubDate>
				Fri, 20 Mar 2009 15:06:01 -0600
			</pubDate>
		</item>
		<item>
			<title>
				Checkbox filters with jQuery
			</title>
			<description>
<![CDATA[<p>Perhaps I'm using delicious.com wrong, but sometimes I wish I had the ability to narrow down my results from a variety of different tags rather than excluding results that don't share the first tag I marked.  That's where this exercise came into play.</p>

<p>The technique can be used anywhere. In my line of work (online hotel reservations), I've experimented with this technique for a room selection for online hotel reservations.  For instance, hide all but the non-smoking rooms with a king bed, and only show me rooms that I can pay for in advance to get the cheaper price.  That sort of thing.</p>

<p>For this article, I'm going to base my examples on delicious.com's bookmarks.</p>

<p class="entrySupportLinks"><a class="viewDemo" href="/examples/checkboxFilters/exampleFinal.html">View demo</a></p>

<h3>Disclaimer stuff</h3>
<p>This isn't so much of a 'teaching' post as it is an 'asking to be taught' post. Despite the danger I can cause, <strong>I'm no JavaScript/jQuery guy</strong>, and there are plenty of places here that I'm going about this all wrong.  In those instances, I need your help.  I'll call out some specific questions where I know I need improvement.  And if you see additional places, please let me know.  In the meantime, don't look to this post as tried-and-true, ready-to-copy-and-paste way to do things, because it's far from it.</p>


<h3>The HTML</h3>

<p>Let's recreate a delicious bookmark listing and leave out the filters for now.  Here's the html for a single listing:</p>

<pre><code class="html">&lt;ul&gt;
  ...
  &lt;li&gt;
    &lt;h4&gt;The Power of WordPress and jQuery: 25+ Useful Plugins &amp; Tutorials&lt;/h4&gt;
    &lt;p class="url"&gt;http://www.noupe.com/jquery/the-power-of-wordpress-and-jquery-30-useful-plugins-tutorials.html&lt;/p&gt;
    &lt;p class="tags"&gt;&lt;strong&gt;Tags:&lt;/strong&gt; plugin, wordpress, webdesign, jquery&lt;/p&gt;
  &lt;/li&gt;
  ...
&lt;/ul&gt;</code></pre>

<p>In order for this to work, we need a way to get the list items using class names.  So the tags are repeated as class names.  Also, I'm going to give this particular list a class name so the javascript has something to target later.</p>

<pre><code class="html">&lt;ul <strong>class="filterThis"</strong>&gt;
  ...
  &lt;li <strong>class="plugin wordpress webdesign jquery"</strong>&gt;
    &lt;h4&gt;The Power of WordPress and jQuery: 25+ Useful Plugins &amp; Tutorials&lt;/h4&gt;
    &lt;p class="url"&gt;http://www.noupe.com/jquery/the-power-of-wordpress-and-jquery-30-useful-plugins-tutorials.html&lt;/p&gt;
    &lt;p class="tags"&gt;&lt;strong&gt;Tags:&lt;/strong&gt; plugin, wordpress, webdesign, jquery&lt;/p&gt;
  &lt;/li&gt;
  ...
&lt;/ul&gt;</code></pre>

<p>We create several of these records and we have ourselves a nice delicious-like page of results.</p>

<p class="entrySupportLinks"><a class="viewDemo" href="http://www.askthecssguy.com/examples/checkboxFilters/example1.html">View example 1</a> - the starting point: basic page, no javascript</p>

<h3>Let's say it in English</h3>
<p>The JavaScript for this is kind of long and boring, not to mention that I'm not doing it right in several places.  So instead of reprinting it, I'd rather just say in English what I wanted the JavaScript to do.  Writing out the logic in English is always a good practice anyway. So here goes:</p>

<p>When the page loads, look through all the class names of the list items to be filtered, and build a new list with all the unique values of those class names, along with a corresponding checkbox.  Being friendly, we'll also include a 'show all' checkbox at the end of the list.  Since all items are shown by default, all checkboxes will be shown by default, too.  When someone unchecks a box, hide any item that has the class name of that checkbox's value.  When rechecked, show any item that has the class name of that checkbox's value.</p>

<p>Mouthful, right?  There's much more to come, as I quickly realized that there is more I needed to do with this list.</p>

<p class="entrySupportLinks"><a class="viewDemo" href="http://www.askthecssguy.com/examples/checkboxFilters/example2.html">View example 2</a> - the starting point: basic page, no javascript</p>

<h3>Working through one issue at a time</h3>

<p>Issues I immediately noticed with example 2:</p>
<ol>
	<li>'jquery' is a common tag to every item.  How should that be handled?</li>
	<li>When i uncheck 'webdev', an item that has the class of 'resources' also disappears.  It's the only item with the class of 'resources', yet it's checkbox stays checked, misleading me into thinking that because it's checked, there must be a listing showing that has it.</li>
	<li>It would be nice to alphabetize the filters.</li>
</ol>

<p>The latter one was the easiest to knock out.  I can sort the array of unique class names by adding this line to the JavaScript:</p>

<pre><code class="js">arrayUniqueClasses = arrayUniqueClasses.sort();
</code></pre>

<p>Also, I chose to exclude any class that is common to all elements from being in the filter column.  (My code is probably cruddy for doing this - would love feedback on this.) For sake of demonstration, I created a paragraph above the filters that states which classes those are common to all list items.</p>

<p class="entrySupportLinks"><a class="viewDemo" href="http://www.askthecssguy.com/examples/checkboxFilters/example3.html">View example 3</a> - alphabetized filters, and excluding tags common to all list items.</p>

<p>I noticed an additional challenges:</p>
<ol>
	<li>When a filter is unchecked, before hiding the list item, I need to check other classes on the list item to be hidden.</li>
	<li>When a filter is checked again, in addition to showing the list item, I need to check all the other filters for every other class associated with a newly shown list item.</li>
	<li>For my personal preference, I wanted to add this in: If all other filters are checked, go ahead and recheck the 'show all' checkbox.</li>
</ol>

<p>To see how I tackled these challenges, I recommend viewing source on the examples.  The script is commented with what I'm doing and questions to myself throughout the process.</p>

<p class="entrySupportLinks"><a class="viewDemo" href="/examples/checkboxFilters/exampleFinal.html">View final example</a></p>

<h3>Questions for people with more jQuery/JavaScript experience than me:</h3>

<ul>
	<li>In order to have only unique values in my array, I'm using a function called <code>unique(a)</code> (credit: Johan Känngård, http://johankanngard.net/). I tried to use jQuery.unique, but it wasn't working right.  If anyone can do the unique part in jQuery for me and point out how it's done, I'd be much appreciative.</li>
	<li>I'm using what is probably an unreliable method for determining if a tag is common to every result.  I count the number of list items, and I count the number of times any class appears.  If a class's total occurrences equals the total of all list items, I assume that class is common to all list items.  Is there a better way to do this?</li>
	<li>I'm removing items from my arrays using a <code>removeItems(array, item)</code> function that I got from who-knows-where.  Is there a way I can do this in jQuery?</li>
<li>Any other things that could be done better?</li>
</ul>
]]>
			</description>
			<link>
				http://www.askthecssguy.com/2009/03/checkbox_filters_with_jquery_1.html
			</link>
			<guid>
				http://www.askthecssguy.com/2009/03/checkbox_filters_with_jquery_1.html
			</guid>
			<pubDate>
				Fri, 06 Mar 2009 14:16:16 -0600
			</pubDate>
		</item>
		<item>
			<title>
				How to make a &apos;wall of awesome&apos; with CSS and an animated gif
			</title>
			<description>
<![CDATA[<p><img src="/images/20090130_wallOfAwesome.jpg" alt="moustacheme.com wall of awesome" /></p>

<p>My coworker <a href="http://www.tugbucket.net/">Alan</a> sent me a link to <a href="http://moustacheme.com">moustacheme.com</a> last week.  Moustacheme.com has a <a href="http://moustacheme.com/wall-of-awesome/">wall of awesome</a>, which is a gallery of moustachioed photos (perhaps it could be called a "stash of staches", or a "stache-cache"), and it uses a clever CSS technique for an attention-getting effect on hover.</p>

<p>Let's recreate it.</p>

<h3>The HTML</h3>

<p>We want a thumbnail container, with our link inside of it.  The thumbnail image is inside the link.  The thumbnail containers are at a fixed dimension (thanks to the thumb) and will simply float left and repeat .</p>

<p>So this:</p>

<pre><code class="html">&lt;div class="thumbnail"&gt;
  &lt;a href="#"&gt;
    &lt;img src="thumb.gif" alt="" /&gt;
  &lt;/a&gt;
&lt;/div&gt;</code></pre>

<p>repeated a few times and put in a container, like so:</p>

<pre><code class="html">&lt;div class="container"&gt;
  &lt;div class="thumbnail"&gt;...&lt;/div&gt;
  &lt;div class="thumbnail"&gt;...&lt;/div&gt;
  &lt;div class="thumbnail"&gt;...&lt;/div&gt;
  ...
&lt;/div&gt;</code></pre>

<p class="entrySupportLinks"><a class="viewDemo" href="http://www.askthecssguy.com/examples/wallOfAwesome/example01.html">View example 1</a></p>

<h3>Some basic layout CSS</h3>

<p>Right off the bat, I want to layout my thumbs a little better, like a 9x9 grid. So I'll start with that first.</p>

<pre><code class="css">.container { width: 470px; }
.thumbnail { float:left; }
.thumbnail a img { display:block; border:none; }</code></pre>

<p class="entrySupportLinks"><a class="viewDemo" href="http://www.askthecssguy.com/examples/wallOfAwesome/example02.html">View example 2</a></p>

<p>Now let's get awesome.</p>

<h3>Awesome CSS</h3>

<p>To get awesome, we need to find a nice high-contrast animated gif to assist our hover state.  I could use the <a href="http://moustacheme.com/wall-of-awesome/images/star.gif">star blast used on moustacheme.com</a>, but those are cut to the size used on that site, so I think I'll create my own little <a href="http://www.askthecssguy.com/examples/wallOfAwesome/images/spiral.gif">animated spiral</a> based on a rough gif I found on the internets.</p>

<p>We set that image as the background of our thumbnail div.  The awesomeness is baked into place once the opacity of the thumbnail image is changed on hover.</p>

<pre><code class="css">.container { width: 470px; }
.thumbnail { float:left; background:transparent url(images/spiral.gif) no-repeat 50% 50%; }
.thumbnail a img { display:block; border:none; }
.thumbnail a:hover img {
  opacity: 0.8;
  filter: alpha(opacity = 80); /* for IE */
}
</code></pre>

<p class="entrySupportLinks"><a class="viewDemo" href="http://www.askthecssguy.com/examples/wallOfAwesome/example03.html">View example 3</a></p>

<p>I'm certain this could be done with less markup.  For instance, we don't need a div.thumbnail.  Our &lt;a&gt; tag can be the thumbnail - set it to display block and attach the background image to it.</p>

<p class="entrySupportLinks"><a class="viewDemo" href="http://www.askthecssguy.com/examples/wallOfAwesome/example04.html">View example 4</a></p>

<h3>In summary</h3>
<p>Ok, so my wall of awesome featuring images from the Men Who Look Like Kenny Rogers web site is not as awesome as moustacheme.com's wall, but you get the idea.</p>
]]>
			</description>
			<link>
				http://www.askthecssguy.com/2009/01/how_to_make_a_wall_of_awesome_1.html
			</link>
			<guid>
				http://www.askthecssguy.com/2009/01/how_to_make_a_wall_of_awesome_1.html
			</guid>
			<pubDate>
				Thu, 29 Jan 2009 22:46:11 -0600
			</pubDate>
		</item>
		<item>
			<title>
				Mike asks the CSS Guy about a scrolling trick with background images
			</title>
			<description>
<![CDATA[ <p>Mike writes:</p>

<blockquote><p>Check this out: <a href="http://econsultancy.com/reports">http://econsultancy.com/reports</a>.</p><p>Scroll up/down... whaaaaat? :) How was this done?</p></blockquote>

<p>Answer: fixed background images.  Let's look at some examples.</p>

<h3>Images</h3>
<p>For the basic effect, start with two same sized images, with a slight difference.  For my example, I chose this color image and made second version of it in black and white.</p>

<p><img alt="" src="/examples/fixedBackgroundImages/images/cuckoo_color.jpg"/><img alt="" src="/examples/fixedBackgroundImages/images/cuckoo_bw.jpg"/></p>

<p>The images don't have to be the same size, but that definitely makes it easier.</p>

<h3>The markup</h3>

<p>Each image will need it's only container.  I've used a header div and a content div.</p>

<pre><code class="html">&lt;html&gt;
  &lt;head&gt;
    ... 
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div class="header"&gt;
      ...
    &lt;/div&gt;
    &lt;div class="content"&gt;
      ...
    &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;</code></pre>

<h3>The CSS</h3>

<p>Now you assign each image as the background image of each div.  The positioning should always be the same, and <code>background-attachment</code> should be set to <code>fixed</code>.

<pre><code class="css">...
.header {
  padding:40px 40px 40px 300px;
  background: #dbded1 url(images/cuckoo_color.jpg) no-repeat 20px 20px fixed;
}
...
.content {
  padding:10px 40px 10px 300px;
  background: transparent url(images/cuckoo_bw.jpg) no-repeat 20px 20px fixed;
}
...</code></pre>

<p class="entrySupportLinks"><a href="/examples/fixedBackgroundImages/example01.html" class="viewDemo">View example 1</a></p>

<p>I've kept this example basic.  If your browser is wide enough by default, the two images are already seen at the same time.  That's ok just for purposes of illustration.</p>

<p>And knowing this can be done, there's no reason it has be limited to just two images.</p>

<p class="entrySupportLinks"><a href="/examples/fixedBackgroundImages/example02.html" class="viewDemo">View example 2</a></p>

<h3>So what can be done with it?</h3>

<p>This 'effect' isn't inherently bad or annoying, but it is noticeable enough that I'd rather it exist for a reason - where the effect adds some value to the content.  Otherwise, like in the case of econsultancy, it just seems like an excuse to show both the home and away jersey, as if someone couldn't decide which logo to go with, so they came up with a way to use both.</p>

<p>I took a stab at it.  Maybe a paper shredder web page?</p>

<p class="entrySupportLinks"><a href="/examples/fixedBackgroundImages/example03.html">View example 3</a></p>

<p>Or maybe not...</p>
<p>If you've seen technique this used effectively, let me know in the comments.</p>

<div class="updates">
<p><strong>Jan 14, 2009:</strong> Some readers of reddit mention that the following sites that have used fixed background images to achieve a nice effect:</p>
<ul>
	<li>Eric Meyer's <a href="http://meyerweb.com/eric/css/edge/complexspiral/demo.html">complexspiral demo</a> uses fixed background images to fake transparency</li>
	<li>Bryan Katzel's <a href="http://www.webleeddesign.com/">We Bleed Design</a> portfolio. (Click the 'play' link at the top, sit back, and enjoy).</li>
</ul>
</div>
]]>
			</description>
			<link>
				http://www.askthecssguy.com/2009/01/mike_asks_the_css_guy_about_a.html
			</link>
			<guid>
				http://www.askthecssguy.com/2009/01/mike_asks_the_css_guy_about_a.html
			</guid>
			<category domain="http://www.sixapart.com/ns/types#category">
				ringmaster
			</category>
			<pubDate>
				Tue, 13 Jan 2009 16:27:30 -0600
			</pubDate>
		</item>
		<item>
			<title>
				Josh asks the CSS Guy about row locking with jQuery
			</title>
			<description>
<![CDATA[  <p>With regards to <a href="http://www.askthecssguy.com/2006/12/row_locking_with_css_and_javas.html">this article</a>, Josh writes:</p>

<blockquote><p>"Would it be possible for you to recreate this with jQuery and see how many lines of JS you can save in the process?"</p></blockquote>

<p>Yes!</p>

<p class="entrySupportLinks"><a href="/examples/rowlock/example10.html" class="viewDemo">View demo</a></p>

<p>This is a direct jQuery replacement of <a href="/examples/rowlock/example9.html">this particular example</a>.</p>

<h3>The jQuery</h3>

<p>I ditched all the home-grown functions, linked  out to the <a href="http://code.jquery.com/jquery-latest.js">jQuery-latest.js</a>, then wrote the following bits:</p>

<pre><code class="js">$(document).ready(function() {
  $('.pickme tbody tr:odd').addClass('odd');
  $('.pickme tbody tr').hover(
    function() { $(this).addClass('highlight'); },
    function() { $(this).removeClass('highlight'); }
  ).click( function() {
    $('.selected').removeClass('selected');
    $(this).addClass('selected').find('input').attr('checked','checked');
  });
});</code></pre>

<p>In English, this says:</p>
<ol>
	<li>When the page has finished loading the DOM...</li>
	<li>add a class of 'odd' to every other row in the table...</li>
	<li>then assign a hover behavior that consists of:</li>
	<li>adding a class of 'highlight' to the row when hovered into...</li>
	<li>and removing the class of 'highlight' when hovered away.</li>
	<li>When any row is clicked...</li>
	<li>remove the class of 'selected' from any other row that happens to have it...</li>
	<li>then add class of 'selected' to the current row, while also checking it's radio button.</li>
</ol>

<p>This is much shorter and easier to write for than the previous example.  Compare the javascript written in the source code on the <a href="/examples/rowlock/example9.html">previous version</a> to the <a href="/examples/rowlock/example10.html">jQuery version</a>.</p>

<p>The usual warnings for using libraries still apply.  If it's a single effect on your site, it is likely best and more concise to write out your functions from scratch, but if you are already using jQuery (or any other library) on your site, take advantage of it.  Also, just because it's easy doesn't make it right - give consideration to whether a behavior should be applied at all.</p>]]>
			</description>
			<link>
				http://www.askthecssguy.com/2008/10/josh_asks_the_css_guy_about_ro.html
			</link>
			<guid>
				http://www.askthecssguy.com/2008/10/josh_asks_the_css_guy_about_ro.html
			</guid>
			<category domain="http://www.sixapart.com/ns/types#category">
				tiger
			</category>
			<pubDate>
				Wed, 22 Oct 2008 08:49:22 -0600
			</pubDate>
		</item>
		<item>
			<title>
				Pardon the mess
			</title>
			<description>
<![CDATA[<p>I'm gutting some movable type html, and along with that, I'll need to rebuild the CSS file as well.  If you keep seeing fresh articles in your feed reader, this is why.  This will take a few days.</p>

<div class="updates">
<p><strong>Sep 12, 2008:</strong> I suppose it could be considered subjective, but the 'mess' has been straightened up.  I still have some entries to edit to bring up to column standards (why didn't I do this sooner?), but things are falling into place, and I'm learning plenty in the process.  I've got a vacation coming up, but hope to get some articles currently in the works on the site soon after my return.</p>
</div>]]>
			</description>
			<link>
				http://www.askthecssguy.com/2008/09/pardon_the_mess.html
			</link>
			<guid>
				http://www.askthecssguy.com/2008/09/pardon_the_mess.html
			</guid>
			<pubDate>
				Thu, 04 Sep 2008 13:39:51 -0600
			</pubDate>
		</item>
	</channel>
</rss>

