<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>CSSnewbie</title>
	
	<link>http://www.cssnewbie.com</link>
	<description>CSS Tutorials, Tips &amp; Techniques for the uninitiated.</description>
	<pubDate>Fri, 10 Oct 2008 15:00:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/cssnewbie" type="application/rss+xml" /><feedburner:emailServiceId>1376060</feedburner:emailServiceId><feedburner:feedburnerHostname>http://www.feedburner.com</feedburner:feedburnerHostname><item>
		<title>jQuery-Based Popout Ad: Part 3</title>
		<link>http://feeds.feedburner.com/~r/cssnewbie/~3/408777445/</link>
		<comments>http://www.cssnewbie.com/jquery-popout-ad-part-3/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 01:17:40 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Advanced Techniques]]></category>

		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=228</guid>
		<description><![CDATA[The previous article in this series explained how to take CSS- and XHTML-based advertisement we had developed and animate it using the jQuery JavaScript library. Today, we're going to expand our jQuery a bit to make our ad a little bit more user-friendly.]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.cssnewbie.com/example/popout-ad/part3.html'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/10/popout-functions.gif" alt="" title="popout-functions" width="400" height="149" class="alignnone size-full wp-image-229" /></a></p>
<p><strong>Note:</strong> <a href="http://www.cssnewbie.com/jquery-popout-ad-part-1/">Part 1 of this series is available here,</a> and <a href="http://www.cssnewbie.com/jquery-popout-ad-part-2/">you can read part 2 here.</a> I&#8217;d recommend reading both of those articles before continuing on to this one.</p>
<p><a href="http://www.cssnewbie.com/jquery-popout-ad-part-2/">The previous article in this series</a> explained how to take CSS- and XHTML-based advertisement we&#8217;d developed and animate it using the <a href="http://jquery.com/">jQuery JavaScript library.</a> Today, we&#8217;re going to expand our jQuery a bit to make our ad a little bit more user-friendly (if an ad can ever be said to be user-friendly, that is).</p>
<p>We&#8217;re going to expand our functionality in two important ways. First, we&#8217;ll give the popout a memory: when the user closes the ad, it will remain closed for a predetermined number of days, unless they choose to open it again. And second, we&#8217;ll allow the user to open <strong>and</strong> close the ad by clicking the permanent sidebar cap. And before I get started, I&#8217;d like to point out that these two examples are really expandable to countless practical uses &mdash; don&#8217;t feel limited just because I&#8217;m talking about a popout here!</p>
<h5>Remembering the User</h5>
<p>The only practical way to remember whether the user has opened or closed our ad across multiple visits is by using a browser cookie. <a href="http://www.cssnewbie.com/message-box-javascript-css/" title="Perma-Closing Message Boxes with JavaScript and CSS">I&#8217;ve written about setting browser cookies here before,</a> and I&#8217;ll be honest – it&#8217;s a tedious process writing the code to make the magic happen. However, because we&#8217;re already using the jQuery framework, our job is about to get a heck of a lot easier.</p>
<p>jQuery does not come with built-in cookie-setting functionality, which is a rather large shortcoming in my opinion. Luckily, jQuery has a rather active community behind it, and a nice man by the name of <a href="http://www.stilbuero.de/2006/09/17/cookie-plugin-for-jquery/">Klaus Hartl has released a jQuery cookie plugin.</a> All we need to do is include the link to the plugin in the head of our document, underneath our call to the jQuery library, like so:</p>
<pre class="html">&lt;script language=&quot;javascript&quot; src=&quot;/js/jquery/jquery.js&quot;&gt;&lt;/script&gt;
&lt;script language=&quot;javascript&quot; src=&quot;/js/jquery/jquery.cookie.js&quot;&gt;&lt;/script&gt;</pre>
<p>And voila! Cookies have suddenly gotten a whole lot easier. You&#8217;ll see just how easy in a moment.</p>
<p>So how are we going to use these cookies? Well, what makes the most sense to me (and you&#8217;re welcome to suggest alternatives) is this: whenever the user closes the ad box, we&#8217;ll set a cookie indicating this. If the user opens the ad box again, we&#8217;ll delete the cookie. When we load the page, we&#8217;ll simply check to see if our cookie is set: if not, we&#8217;ll open the ad; if so, we&#8217;ll leave the ad closed.</p>
<p>First up, let&#8217;s give our cookie a name. For consistency&#8217;s sake, I&#8217;m going to define the name at the top of my $(document).ready function, along with the other variables:</p>
<pre class="js">var popOut = "#popout";
var adBox = "#adbox";
var adWidth = $(adBox).width() + $("#cap").width();
var adCookie = "ad-example";</pre>
<p>In this example, I&#8217;m calling my cookie &#8220;ad-example,&#8221; but you could really name it whatever you wanted.</p>
<p>Next, we&#8217;ll have to edit our openAd and closeAd functions that we developed in the last article to accommodate the setting and un-setting of cookies. Our openAd function now looks like this:</p>
<pre class="js">function openAd() {
	$(popOut).width(adWidth+"px");
	$(adBox).animate({marginLeft: "0"},1200)
	$.cookie(adCookie, null);
}</pre>
<p>You&#8217;ll note the new line at the bottom. What we&#8217;re doing here is calling the cookie function that is included in the plugin we&#8217;re using. After the user opens the ad, we look for any cookies named whatever we selected at the top of the document. If one exists, we set it to &#8220;null,&#8221; effectively destroying it.</p>
<p>Next up, we have the closeAd function:</p>
<pre class="js">function closeAd() {
	$(adBox).animate({marginLeft: "-"+adWidth+"px"},1200,"linear",
		function(){ $(popOut).width($("#cap").width() + "px"); }
	);
	$.cookie(adCookie,'closed',{expires: 28});
}</pre>
<p>Again, we&#8217;re only adding a single line to our code. You can see how easy this is compared to <a href="http://www.cssnewbie.com/message-box-javascript-css/" title="Perma-Closing Message Boxes with JavaScript and CSS">writing your own JavaScript cookie function!</a> This time, after the ad has successfully closed, we&#8217;re setting a cookie. We&#8217;re giving it a name of whatever we determined at the top of the function (&#8221;ad-example,&#8221; in our case), giving it a value of &#8220;closed,&#8221; and setting the cookie to expire in 28 days (four weeks). You could choose whatever duration you felt appropriate here.</p>
<p>And finally, we&#8217;ll want to alter the last line in our $(document).ready function, the one that opens the ad when the page loads. The line that opens the ad will now read like this:</p>
<pre class="js">if(!$.cookie(adCookie)) {
	$(popOut).animate({opacity: 1.0}, 1500, "linear", openAd);
}</pre>
<p>All we&#8217;ve done is wrap our animation function in an if statement. If the cookie does not exist (the exclamation point at the beginning of our if statement means &#8220;if the following is <em>not</em> true&#8230;&#8221;), we will execute the animation we built last time. But if there is a cookie set (meaning the user has chosen to close the ad), we don&#8217;t animate our ad &mdash; meaning it remains hidden off the edge of our page by our CSS.</p>
<h5>Developing Click Logic</h5>
<p>Next up, we want to alter the click logic on the ad cap &mdash; if the ad is closed, a click should open it. But if it&#8217;s already open, the ad should close when the user clicks. This increases the odds the user will be able to get rid of the ad when they wish, which is an important usability feature in my mind.</p>
<p>To do this, we&#8217;ll need to edit the click function set on our cap. But how do we know if the ad should be opened or closed? Easy: we just set a cookie that will give us the answer we need. If the user clicks on the cap and a cookie is already set, that means the ad is currently closed, so we should open it back up. Otherwise, if no cookie is set, that means our ad is already open. A click at that point should close our ad instead.</p>
<p>Because we went to the trouble of developing functions to open and close our ad, our code change is pretty simple. We just edit the cap&#8217;s click functionality like so:</p>
<pre class="js">$("#open").click(function() {
	if(!$.cookie(adCookie)) {
		closeAd();
	} else {
		openAd();
	}
	return false;
});</pre>
<p>All it takes is a simple if-else statement. If the cookie isn&#8217;t set, close the ad. Otherwise, open the ad like we would have originally.</p>
<p>And with those changes, we have now developed a popout box that is simultaneously eye-catching and user-friendly. Here&#8217;s the JavaScript in its entirety:</p>
<pre class="js">$(document).ready(function() {
	var popOut = "#popout";
	var adBox = "#adbox";
	var adWidth = $(adBox).width() + $("#cap").width();
	var adCookie = "ad-example";

	function openAd() {
		$(popOut).width(adWidth+"px");
		$(adBox).animate({marginLeft: "0"},1200)
		$.cookie(adCookie, null);
	}

	function closeAd() {
		$(adBox).animate({marginLeft: "-"+adWidth+"px"},1200,"linear",
			function(){ $(popOut).width($("#cap").width() + "px"); }
		);
		$.cookie(adCookie,'closed',{expires: 28});
	}

	$("#open").click(function() {
		if(!$.cookie(adCookie)) {
			closeAd();
		} else {
			openAd();
		}
		return false;
	});
	$("#close").click(function() {
		closeAd();
		return false;
	});	

	if(!$.cookie(adCookie)) {
		$(popOut).animate({opacity: 1.0}, 1500, "linear", openAd);
	}
});</pre>
<p><a href="http://www.cssnewbie.com/example/popout-ad/part3.html">And you can see a working example of our ad here.</a> If you have any questions, comments, or concerns, please leave a comment and I will do my best to address them.</p>

<p><a href="http://feeds.feedburner.com/~a/cssnewbie?a=TkB6iN"><img src="http://feeds.feedburner.com/~a/cssnewbie?i=TkB6iN" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/cssnewbie?a=6hp3M"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=6hp3M" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=8b4pm"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=8b4pm" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=ePPBm"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=ePPBm" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=b6opm"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=b6opm" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=qR7CM"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=qR7CM" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=MK4jm"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=MK4jm" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/408777445" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/jquery-popout-ad-part-3/feed/</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=cssnewbie&amp;itemurl=http%3A%2F%2Fwww.cssnewbie.com%2Fjquery-popout-ad-part-3%2F</feedburner:awareness><feedburner:origLink>http://www.cssnewbie.com/jquery-popout-ad-part-3/</feedburner:origLink></item>
		<item>
		<title>jQuery-Based Popout Ad: Part 2</title>
		<link>http://feeds.feedburner.com/~r/cssnewbie/~3/394787523/</link>
		<comments>http://www.cssnewbie.com/jquery-popout-ad-part-2/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 02:54:21 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Advanced Techniques]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[ads]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[popout]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=225</guid>
		<description><![CDATA[Part 2 of our series is going to build on what we accomplished last week. Namely, we’re going to take the ad we built last week and animate it, as well as provide the user with a means to open and close the ad.]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.cssnewbie.com/example/popout-ad/part2.html'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/09/popout-animated.jpg" alt="" title="animated jquery based popout ad" width="400" height="363" class="alignnone size-full wp-image-226" /></a></p>
<p><strong>Note: </strong><a href="http://www.cssnewbie.com/jquery-popout-ad-part-1/">Part 1 of this series is available here.</a> Be sure to read it first, or what comes here won’t make a lot of sense. :)</p>
<p>Part 2 of our series is going to build on what we accomplished last week. Namely, we’re going to take the ad we built last week and animate it, as well as provide the user with a means to open and close the ad. We’ll be using jQuery for most of what we do, so you’ll need to include <a href="http://jquery.com/">the jQuery library script</a> at the top of your document for this to work (see the source of <a href="http://www.cssnewbie.com/example/popout-ad/part2.html">the example page</a> to see how this is done).</p>
<p>Before we get started on our JavaScript, however, we’ll need to make one tiny addendum to our CSS from last week:</p>
<pre class="css">#popout #adbox {
	margin-left: -300px;
}</pre>
<p>This bit of CSS moves our ad box (the bit we hope to animate) 300 pixels to the left of where it sits normally. And because our ad is 300 pixels wide (convenient, no?) this effectively hides the ad off the side of the screen. This way, our ad is hidden by default, and we can use jQuery to slide it back onto the screen.</p>
<p>Now let’s get started with the jQuery. We’ll wrap everything we write today in a “document ready” function, which looks like this: </p>
<pre class="js">$(document).ready(function() {
});</pre>
<p>This prevents everything we put inside from firing until the document has finished loading, which is a good thing for us: we don’t want our ad to start moving until it’s all loaded!</p>
<h5>Set Some Variables</h5>
<p>We’ll start by defining a few variables that we’ll use throughout the script:</p>
<pre class="js">var popOut = "#popout";
var adBox = "#adbox";
var adWidth = $(adBox).width() + $("#cap").width();</pre>
<p>The first variable, popOut, contains the CSS ID of the overall popout container that we built last week. popOut contains the ad and the ad’s cap both. The second variable (adBox) is the ID of just the animated bit of the ad. And finally, adWidth is a custom-built variable which gives us the total width of the area our ad takes up (the width of the ad plus the width of the cap). This variable will come in handy when we start animating our ad, to let us know how much space we have to work with.</p>
<h5>The Animation Functions</h5>
<p>Now that we’ve defined our primary variables, let’s delve into the actual animation of the ad. I’ve broken both parts of our animations (sliding in to the page and sliding back out again) into two functions. The opening function looks like this:</p>
<pre class="js">function openAd() {
	$(popOut).width(adWidth+"px");
	$(adBox).animate({marginLeft: "0"},1200);
}</pre>
<p>This tiny little function is doing a surprising amount of work (which is really the power of jQuery). The first line simply sets the width of the popout container to be the width of the ad plus the cap – making sure we have enough room to do our animation. This may seem redundant, but it’ll make more sense later.</p>
<p>The second line of our function is the real workhorse. Here, we’re using jQuery to build a custom animation, which we’re attaching to our adBox variable. We’re telling jQuery to set a left margin of zero on the adBox (to move it back to its “real” position, in other words). But instead of doing it all at once, we’re telling jQuery to slowly make the change over the course of 1200 milliseconds (or 1.2 seconds, if you prefer). Pretty powerful stuff for a single line of code, no?</p>
<p>And now that we’ve built the function to open our ad, we can build the function to close it back up again:</p>
<pre class="js">function closeAd() {
	$(adBox).animate({marginLeft: "-"+adWidth+"px"},1200,"linear",
		function(){ $(popOut).width($(".cap").width() + "px"); }
	);
}</pre>
<p>This function is obviously a little more complicated, although it wouldn’t have to be if it weren’t for a but in Internet Explorer 6.</p>
<p>The first bit looks somewhat familiar, I hope. We’re setting another animation here, this time setting the left margin of the ad  to be the <em>negative</em> of the width of the ad space, effectively hiding it off the side of the screen. And we’re doing it over the same 1.2 seconds as our last animation (though you can tweak these numbers to your heart’s content).</p>
<p>After that, things get a little more complicated. The next bit, “linear,” simply tells the animation function to maintain the same speed throughout the animation – not to slow down at the beginning or end. </p>
<p>And when the animation is finished, we’re firing off yet another function. This function sets the width of the popout area to be only as wide as the cap, since that’s the only part of the ad that is visible (hence why we have to set a width at the beginning of our openAd function). </p>
<p>This is because of a bug in Internet Explorer 6 that prevents the user from “clicking through” an empty div. What that means is, if the user tried to close your ad and then click on anything that had been previously hidden by the ad – a link in your sidebar, for example – they wouldn’t be able to click. Even though the ad is gone, IE6 would assume you were reserving the space for some greater purpose. So to get around this, we grow and shrink the popout space as necessary.</p>
<h5>Create Click Events</h5>
<p>Now that we’ve created our animation functions, we can attach them quickly and easily to the anchors we built last week for such a purpose. As you’ll recall, we included a “close” button in the corner of the ad – clicking this should obviously close the ad. And if someone ever wanted to see the ad again (we should be so lucky!), clicking the cap will bring it right back out.</p>
<pre class="css">$("#open").click(function() {
	openAd();
	return false;
});
$("#close").click(function() {
	closeAd();
	return false;
});</pre>
<p>These functions are fairly simple: We’re simply using jQuery to assign an onClick event to our cap (with a CSS ID of “open”) and our close button (which we called “#close” last week). When the user clicks on either of those elements, the function inside (openAd and closeAd, respectively) will trigger. After that, we’ve included a “return false,” which simply tells the browser not to bother following the href in our anchors (it was blank anyway, but we don’t want the page refresh that would go along with an attempt).</p>
<p>And now, one last line of jQuery magic. When we open our page, we want our ad to pop out of the side of the page, catching the user’s eye and drawing their attention to our box’s content. To do that, we use this line:</p>
<pre class="js">$(popOut).animate({opacity: 1.0}, 1500, "linear", openAd);</pre>
<p>jQuery is very powerful, but one thing it lacks is a simple “delay” function. And here’s the problem: I don’t want my ad to start animating the very instant that my document becomes “ready.” For one, I’d like the reader to be able to orient themselves on the page. For another, just because the document is ready (i.e., our code has downloaded) doesn’t mean that all of my images have finished downloading. And an animated ad without any images is far less impressive than the image-rich variety.</p>
<p>Luckily, I found <a href="http://p.karageorgakis.com/blog/jquery_simulating_a_delay_function_between_fade_in_out_effects/">a solution on a blog titled “Panagiotis Karageorgakis,”</a> and modified it to fit my needs. The basic concept is this: we animate the ad in some way that makes <em>absolutely no change whatsoever</em> on the screen, and then we chain on a second animation when we’re done.</p>
<p>So here, our animation, which will fire on load, tells jQuery to slowly set the opacity of our ad to “1.0” (opaque) over the course of 1.5 seconds. Of course, our ad was already fully opaque, so this has no effect at all. And then after the first “animation” is completed, we fire off another function: namely, our openAd function, which will do all the heavy lifting involved in actually opening our ad.</p>
<p>And that’s all there is to it! We now have a fully functioning popout ad. <a href="http://www.cssnewbie.com/example/popout-ad/part2.html">You can see it in action here.</a> And here’s the completed JavaScript, so you don’t have to hunt it down:</p>
<pre class="js">$(document).ready(function() {
	var popOut = "#popout";
	var adBox = "#adbox";
	var adWidth = $(adBox).width() + $(".cap").width();

	function openAd() {
		$(popOut).width(adWidth+"px");
		$(adBox).animate({marginLeft: "0"},1200);
	}

	function closeAd() {
		$(adBox).animate({marginLeft: "-"+adWidth+"px"},1200,"linear",
			function(){ $(popOut).width($(".cap").width() + "px"); }
		);
	}

	$("#open").click(function() {
		openAd();
		return false;
	});
	$("#close").click(function() {
		closeAd();
		return false;
	});	

	$(popOut).animate({opacity: 1.0}, 1500, "linear", openAd);
});</pre>
<p>Of course, that isn’t to say we couldn’t make our ad a little fancier than it is. Next week, we’ll go over some ways to make the ad even more advanced – like remembering whether the ad should be open or closed, or letting the user open <em>and</em> close the ad by clicking on the cap. Stay tuned!</p>
<p><strong>Note:</strong> <a href="http://www.cssnewbie.com/jquery-popout-ad-part-3/">Part 3 of this series is available here.</a> And if you missed it, <a href="http://www.cssnewbie.com/jquery-popout-ad-part-1/">here&#8217;s part 1.</a></p>

<p><a href="http://feeds.feedburner.com/~a/cssnewbie?a=tvjFjX"><img src="http://feeds.feedburner.com/~a/cssnewbie?i=tvjFjX" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/cssnewbie?a=alK5L"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=alK5L" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=fVbPl"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=fVbPl" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=RTcsl"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=RTcsl" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=DuPpl"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=DuPpl" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=v8f3L"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=v8f3L" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=Z7gBl"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=Z7gBl" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/394787523" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/jquery-popout-ad-part-2/feed/</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=cssnewbie&amp;itemurl=http%3A%2F%2Fwww.cssnewbie.com%2Fjquery-popout-ad-part-2%2F</feedburner:awareness><feedburner:origLink>http://www.cssnewbie.com/jquery-popout-ad-part-2/</feedburner:origLink></item>
		<item>
		<title>jQuery-Based Popout Ad: Part 1</title>
		<link>http://feeds.feedburner.com/~r/cssnewbie/~3/388248371/</link>
		<comments>http://www.cssnewbie.com/jquery-popout-ad-part-1/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 02:59:52 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Advanced Techniques]]></category>

		<category><![CDATA[Floats and Positioning]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[overflow]]></category>

		<category><![CDATA[positioning]]></category>

		<category><![CDATA[z-index]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=222</guid>
		<description><![CDATA[Advertisements on the web: love them or hate them, it's safe to say they're here to stay for a good long while. But advertising is a tough line to walk for a lot of websites (such as this one). Make your ads too annoying, and you'll lose readership. But make them too unobtrusive, and you might as well not even have them at all. Today I'd like to start an article series of three parts, the result of which will be a popout-style, jQuery-based box like the one pictured above, which I think strikes a nice balance on the obtrusion-scale. ]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.cssnewbie.com/example/popout-ad/'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/09/popout.jpg" alt="" title="jquery-based popout ad" width="400" height="275" class="alignnone size-full wp-image-223" /></a></p>
<p>Advertisements on the web: love them or hate them, it&#8217;s safe to say they&#8217;re here to stay for a good long while. But advertising is a tough line to walk for a lot of websites (such as this one). Make your ads too annoying, and you&#8217;ll lose readership. But make them too unobtrusive, and you might as well not even have them at all. So where&#8217;s the balance?</p>
<p>Today I&#8217;d like to start an article series of three parts, the result of which will be a popout-style, jQuery-based box like the one pictured above, which I think strikes a nice balance on the obtrusion-scale. <a href="http://www.crawlspacemedia.com/">A friend of mine</a> and I first developed this box to contain advertisements, but it&#8217;s a pretty versatile little technique: we&#8217;ve also used it to hold signup forms, and it could be expanded to other uses fairly easily.<br />
<a href="http://www.cssnewbie.com/example/popout-ad/"><br />
If you&#8217;d like to see this popout ad in action, click here.</a></p>
<p>So what&#8217;s the benefit of this little popout box? First of all, it&#8217;s pretty simple to set up. In today&#8217;s article, I&#8217;ll cover the XHTML and CSS necessary to build this popout box, and you&#8217;ll see that it doesn&#8217;t take as much code as you might expect. </p>
<p>Second, it&#8217;s an eye-catching, yet not entirely annoying, technique. The ad opens after the page loads, which tends to draw the reader&#8217;s eye that direction. But if the ad isn&#8217;t for them, they can just click the close button and move it out of the way. Part 2 of this series will cover the jQuery used to make the ad function as prescribed.</p>
<p>Third, the technique easy to customize for your specific needs. In part 3 of this series, I&#8217;ll cover adding cookie support (to remember whether the ad should be open or closed) using a great jQuery plugin, generalizing your CSS to support both left- and right-aligned boxes with just one stylesheet, and even supporting multiple ads on the same page, should you decide to push the envelope.</p>
<p>Intrigued? Great! Let&#8217;s dive in to part 1.</p>
<h5>The Images Required</h5>
<p><img src="http://www.cssnewbie.com/wp-content/uploads/2008/09/our-images.jpg" alt="" title="our jquery popout ad images" width="400" height="350" class="alignnone size-full wp-image-224" /></p>
<p>Depending on how you&#8217;re using the box, you&#8217;ll need some images. For mine, I&#8217;m using two images. The first image functions as the ad &#8220;cap,&#8221; which is permanently affixed to the side of the page. Clicking this image will, once we&#8217;ve added our jQuery, cause the ad itself to open and close. </p>
<p>The second image is simply for the advertisement itself. Depending on your ad source and type, this image may or may not be necessary. If you&#8217;d like to follow along at home, <a href="http://www.cssnewbie.com/example/popout-ad/popout-ad-images.zip">you can download the image files I&#8217;m using here (Photoshop files and GIF/PNG images included).</a></p>
<h5>Writing the XHTML</h5>
<p>The XHTML is fairly simple, only requiring a few divs, images, and anchors:</p>
<pre class="html">&lt;div id=&quot;popout&quot;&gt;
	&lt;div id=&quot;cap&quot;&gt;
		&lt;a href=&quot;#&quot; id=&quot;open&quot;&gt;
			&lt;img src=&quot;images/cap.gif&quot; width=&quot;20&quot; height=&quot;350&quot; alt=&quot;Open the Ad.&quot; /&gt;
		&lt;/a&gt;
	&lt;/div&gt;
	&lt;div id=&quot;adbox&quot;&gt;
		&lt;a href=&quot;#&quot; id=&quot;close&quot; title=&quot;Close this ad.&quot;&gt;
			&lt;span&gt;Close&lt;/span&gt;
		&lt;/a&gt;
		&lt;a href=&quot;#&quot; id=&quot;ad&quot;&gt;
			&lt;img src=&quot;images/ad.png&quot; width=&quot;300&quot; height=&quot;330&quot; alt=&quot;&quot; /&gt;
		&lt;/a&gt;
	&lt;/div&gt;
&lt;/div&gt;</pre>
<p>The main div, &#8220;popout,&#8221; acts as a wrapper for the whole shebang. It contains all the other elements, and comes in handy when writing our jQuery and our CSS.</p>
<p>Next up comes the &#8220;cap&#8221; div. Technically, this div isn&#8217;t even 100% necessary &mdash; you could just as easily attach your CSS and jQuery scripts to the anchor tag it contains. But I find it&#8217;s useful to think of the cap as a wholly distinct unit from the advertisement, so I&#8217;ve put it in a separate div to help me think of it as such.</p>
<p>Inside the cap div is an anchor, &#8220;open,&#8221; which in turn contains the image of our cap. The anchor tag serves a critical role: it&#8217;s what we use in our jQuery later on to trigger the opening and closing of the ad.</p>
<p>After the cap comes the &#8220;adbox&#8221; div, which contains the real guts of our popout ad. First up is the &#8220;close&#8221; anchor, which functions as a close box. As you can see from the image above, I&#8217;ve built a close box into my ad itself: if you preferred, you could make the close button a standalone image and absolutely position it over your ad&#8230; but for the sake of simplicity in this tutorial, I&#8217;ve chosen not to here.</p>
<p>And finally, we have the &#8220;ad&#8221; anchor, which contains the advertisement itself. I can get away with just an anchor and an image because I&#8217;ve developed this ad myself, and am hosting it locally. If you were using a different ad type, such as one that were pulled in dynamically using JavaScript or the like, you&#8217;d put that code here instead (probably wrapped in a div to keep it contained).</p>
<p>And that&#8217;s all the XHTML you&#8217;ll need! So let&#8217;s move on to the CSS.</p>
<h5>Adding the CSS</h5>
<p>The first thing we need to do is establish our containing popout div on the page:</p>
<pre class="css">#popout {
	margin: 0;
	padding: 0;
	width: 320px;
	height: 350px;
	position: absolute;
	top: 200px;
	left: 0;
	z-index: 100;
	overflow: hidden; }</pre>
<p>The first couple of rules simply nullify any margins or padding that might be hanging around in other places in your CSS: the last thing we need is a rogue rule crimping our style. If you&#8217;re sure none exist, you can eliminate those lines.</p>
<p>Our width and height rules are pretty simple: they state the height of the ad (which in our case is actually the height of the cap, as our ad is slightly shorter) and the maximum width the ad will take up (when the ad is closed, it takes up much less space).</p>
<p>Next up, we&#8217;re positioning the ad on the page. These rules are useful for two reasons. First, it allows us to position the ad wherever we want on the page. I&#8217;ve chosen to start the ad 200 pixels down on the left hand side, but you can really place it wherever you want. Second, positioning the popout wrapper allows us to <a href="http://www.cssnewbie.com/harnessing-positioning-1/" title="Harnessing CSS Positioning">absolutely position elements within that wrapper,</a> which will come in handy shortly.</p>
<p>We finish up with two less common rules: z-index and overflow. The z-index is helping to ensure our ad is on top of any other content on your page: elements with a lower z-index (1 is the default) will show up below our wrapper. The overflow rule doesn&#8217;t do a lot for us initially, but is critical for our jQuery to do its magic. We&#8217;ll cover that in part 2.</p>
<p>With our popout wrapper in place, we can start styling its innards, starting with some general rules:</p>
<pre class="css">#popout a, #popout a img {
	text-decoration: none;
	border: 0;
	outline: 0; }
#popout a span {
	display: none; }</pre>
<p>The first set of rules ensures that none of our anchors or images have any borders, outlines, or underlines from our anchors and the images they contain. Normally you wouldn&#8217;t want to eliminate any sign that something had been or could be clicked, but because this is an advertisement we&#8217;re building, I think we&#8217;re allowed to bend the rules of usability for the sake of aesthetics. If you disagree, feel free to remove that rule.</p>
<p>Next up, we&#8217;re setting a general rule that comes in handy for me: any span within anchor tags will be magically disappeared. In our example, this only pertains to the &#8220;Close&#8221; text inside its corresponding anchor, but in theory you could have more text in your popout wrapper that you&#8217;d want to hide. For example, when building these ads I often load the cap image as a background image and have text inside of the anchor.</p>
<p>With the generalities out of the way, let&#8217;s start in on specifics, starting with the cap:</p>
<pre class="css">#popout #cap {
	width: 20px;
	height: 350px;
	position: relative;
	left: 0;
	z-index: 102; }</pre>
<p>Pretty basic stuff, huh? We&#8217;re setting a width and height first, which just ensures our div doesn&#8217;t take up any more space than is necessary. Then, we relatively position the ad. This is mostly done so that we can specify a z-index. Our z-index here says that we want it to be even higher than the popout ad; and you&#8217;ll see why shortly.</p>
<p>Next up, we position our close button:</p>
<pre class="css">#popout a#close {
	position: absolute;
	top: 0;
	background: transparent url(transparent.gif);
	left: 240px;
	height: 20px;
	width: 60px; }</pre>
<p>Here, we&#8217;re absolutely positioning the close button in the top-right corner of our popout wrapper div. If you&#8217;ll recall, the top-right corner is where I&#8217;d placed the close button in our image. This just ensures the close button is in the right spot, even though its contents were rendered invisible by that previous display:none rule. But you&#8217;ll notice that I&#8217;m using the &#8220;left&#8221; property to <em>push</em> our button right, instead of just positioning against the right-hand side with the &#8220;right&#8221; property. This is to take into account a bug in Opera that causes our close button to be positioned improperly when aligned along the right-hand side of our animated box (you can <a href="http://www.cssnewbie.com/jquery-popout-ad-part-2/#comment-8417">read all the juicy details in the comment thread of part 2 of this series</a>)</p>
<p>I&#8217;m also specifying a height and width &mdash; be sure to adjust yours to the size of your close button. Technically you could use a percentage or em value for the width, but I&#8217;m using pixels to make the math involved in pushing it from the left easier.</p>
<p>I&#8217;ve also added a fix to the CSS above to take care of an Internet Explorer bug. IE shrinks the clickable area of an anchor tag to be the size of its content, even if we&#8217;ve specified a width and height that gives the anchor a different size. Because we are hiding the content of this anchor using a &#8220;display: none&#8221; rule, this means the anchor is effectively unclickable in Internet Explorer. However, IE does recognize the size of the link if it&#8217;s filled with a background image. Thus, by adding a transparent background image to our anchor (I&#8217;m using a 1&#215;1 pixel transparent gif), the size and shape of the anchor is respected.</p>
<p>And finally, we&#8217;re ready to position our advertisement itself:</p>
<pre class="css">#popout #adbox {
	position: absolute;
	top: 10px;
	left: 20px;
	z-index: 101; }</pre>
<p>Our position of absolute allows us to move the ad right into position: 10 pixels from the top of the popout wrapper (because my ad is 20 pixels shorter than the cap, this centers it nicely) and 20 pixels from the left (which happens to be the exact width of the cap). And finally, we&#8217;ve set a z-index of 101, which is 1 less that the z-index of our cap. This means that our cap is &#8220;above&#8221; our ad &mdash; when we use jQuery to animate the ad in part 2, this will come in handy, allowing us to slip the ad behind the cap.</p>
<p>And that brings us to the end of part 1. <a href="http://www.cssnewbie.com/example/popout-ad/part1.html">You can see the results of our efforts (without any jQuery magic) here.</a> Stay tuned for parts 2 and 3, when things really start to get fun!</p>
<p><strong>Note:</strong> <a href="http://www.cssnewbie.com/jquery-popout-ad-part-2/">Part 2 of this series is now available here.</a> And when you&#8217;re ready, <a href="http://www.cssnewbie.com/jquery-popout-ad-part-3/">part 3 is available here.</a></p>

<p><a href="http://feeds.feedburner.com/~a/cssnewbie?a=F2LThB"><img src="http://feeds.feedburner.com/~a/cssnewbie?i=F2LThB" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/cssnewbie?a=qfZtL"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=qfZtL" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=twV0l"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=twV0l" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=s91Zl"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=s91Zl" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=29eml"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=29eml" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=BMHnL"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=BMHnL" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=7p8yl"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=7p8yl" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/388248371" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/jquery-popout-ad-part-1/feed/</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=cssnewbie&amp;itemurl=http%3A%2F%2Fwww.cssnewbie.com%2Fjquery-popout-ad-part-1%2F</feedburner:awareness><feedburner:origLink>http://www.cssnewbie.com/jquery-popout-ad-part-1/</feedburner:origLink></item>
		<item>
		<title>CSSnewbie Subscriber Contest Winner Announced</title>
		<link>http://feeds.feedburner.com/~r/cssnewbie/~3/381890714/</link>
		<comments>http://www.cssnewbie.com/cssnewbie-subscriber-contest-winner-announced/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 01:48:54 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Site News]]></category>

		<category><![CDATA[announcement]]></category>

		<category><![CDATA[contest]]></category>

		<category><![CDATA[winner]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=220</guid>
		<description><![CDATA[It's been a great, if absurdly busy, August for me, and I hope the same can be said for you. But all good things (including the month of August) must come to an end, and so to ends the <a href="http://www.cssnewbie.com/cssnewbie-subscriber-contest/">CSSnewbie Subscriber Contest.</a>]]></description>
			<content:encoded><![CDATA[<p><a href='http://flickr.com/photos/ohadby/175144072/'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/09/racing.jpg" alt="" title="Photo by Ohad. Used under a Creative Commons license." width="400" height="247" class="alignnone size-full wp-image-221" /></a></p>
<p>It&#8217;s been a great, if absurdly busy, August for me, and I hope the same can be said for you. But all good things (including the month of August) must come to an end, and so to ends the <a href="http://www.cssnewbie.com/cssnewbie-subscriber-contest/">CSSnewbie Subscriber Contest.</a></p>
<p>The contest has ended, and a winner has been selected by the true random integer generator at <a href="http://www.random.org/">random.org.</a> Each contestant was assigned a number based on the order in which I received their email (see &mdash; you&#8217;re more than an email address to me! You&#8217;re a number as well!), and a number was chosen randomly from that total.</p>
<p><strong>The winner of the subscriber contest</strong> is Italy&#8217;s own <a href="http://www.matteomoro.net/">Matteo Moro,</a> who writes on <a href="http://cssblog.it/">CSSblog.it.</a> Matteo will be receiving a copy of <a href="http://www.amazon.com/exec/obidos/ASIN/0596515057/cssnewbie-20">Eric Meyer&#8217;s <em>CSS Pocket Reference</em></a> as well as a website review here on CSSnewbie (date/type to be determined).</p>
<p>Thanks to all of you who entered CSSnewbie&#8217;s first-ever contest. I had a lot of fun reading the quips everyone tended to include in the emails they sent me &mdash; it made me check my contest inbox probably more than was necessary. The success of this contest suggests that I might hold another in the future&#8230; as soon as I come up with something new worth celebrating. August only comes around once a year, sadly.</p>
<p>If  you have any feedback on this contest, or on any future contests I might hold, feel free to either email me or leave a comment on this article. I&#8217;d love to hear what you have to say.</p>
<p>To all those who didn&#8217;t win: thanks for playing, thanks even more for reading, and I hope you stick around! I have more great articles lined up for September, including my first multi-part tutorial, which will combine elements of XHTML, CSS and JavaScript to great effect. Stay tuned!</p>

<p><a href="http://feeds.feedburner.com/~a/cssnewbie?a=ZFsdOn"><img src="http://feeds.feedburner.com/~a/cssnewbie?i=ZFsdOn" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/cssnewbie?a=HMhxtL"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=HMhxtL" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=jrWiel"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=jrWiel" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=1bmLWl"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=1bmLWl" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=fxqwdl"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=fxqwdl" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=3JNu4L"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=3JNu4L" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=Qb7zkl"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=Qb7zkl" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/381890714" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/cssnewbie-subscriber-contest-winner-announced/feed/</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=cssnewbie&amp;itemurl=http%3A%2F%2Fwww.cssnewbie.com%2Fcssnewbie-subscriber-contest-winner-announced%2F</feedburner:awareness><feedburner:origLink>http://www.cssnewbie.com/cssnewbie-subscriber-contest-winner-announced/</feedburner:origLink></item>
		<item>
		<title>5 Great Uses for the CSS Display Property</title>
		<link>http://feeds.feedburner.com/~r/cssnewbie/~3/369392663/</link>
		<comments>http://www.cssnewbie.com/5-great-uses-for-the-css-display-property/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 22:01:04 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Basic Techniques]]></category>

		<category><![CDATA[Quick Tip]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=219</guid>
		<description><![CDATA[Despite the display property's seemingly limited use, you'd be surprised how many CSS techniques rely on this little workhorse to get the job done. Here are five CSS techniques I've written about in the past that wouldn't exist without the help of the display property.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cssnewbie.com/horizontal-dropdown-menus/"><img src="http://www.cssnewbie.com/wp-content/uploads/2008/05/horizontalmenu-400.gif" alt="" border="0" /></a></p>
<p>The display property is a bit of an unheralded workhorse in the CSS world. Even though <a href="http://www.w3schools.com/css/pr_class_display.asp">the list of theoretical display property values</a> is quite long, only three of them ever see any use (primarily due to poor browser support on the others): inline, block, and none. </p>
<p>The inline value allows you to define an element to behave as though it were an inline element (like a span or an anchor tag). Conversely, the block value lets you force block-level behavior (like a div or a paragraph). And &ldquo;display: none&rdquo; simply causes an element to not display at all.</p>
<p>But despite the display property&#8217;s seemingly limited use, you&#8217;d be surprised how many CSS techniques rely on this little workhorse to get the job done. Here are five CSS techniques I&#8217;ve written about in the past that wouldn&#8217;t exist without the help of the display property.</p>
<h5>Showing/Hiding Content</h5>
<p><a href="http://www.cssnewbie.com/showhide-content-css-javascript/"><img src="http://www.cssnewbie.com/wp-content/uploads/2008/05/showhide-400.gif" alt="" /></a></p>
<p>One popular technique that relies on the display property is the <a href="http://www.cssnewbie.com/showhide-content-css-javascript/">Show/Hide Content technique (explained in much greater detail here)</a>, which uses CSS and JavaScript to show or hide additional content when the users clicks on a button.  The ability to &ldquo;hide&rdquo; content on a page is a cornerstone of the modern web: too many options at once leaves a user feeling overwhelmed, but too few options can leave your audience feeling constrained. This technique allows you to get the best of both worlds.</p>
<h5>Making Closeable DIVs</h5>
<p><a href="http://www.cssnewbie.com/message-box-javascript-css/"><img src="http://www.cssnewbie.com/wp-content/uploads/2008/04/messagebox-400.gif"/ alt=""></a></p>
<p>In-document message boxes can be quite useful when used for the powers of good &mdash; and not, say, to create annoying pop-in ads right in the middle of a page you&#8217;re trying to read. Luckily, whether used for good or evil, most all in-document popups come with a &ldquo;close&rdquo; option: and that close option is almost always the work of the &ldquo;display: none&rdquo; rule. <a href="http://www.cssnewbie.com/message-box-javascript-css/">Learn more about creating in-document message boxes here.</a></p>
<h5>Creating RSS-Only Content</h5>
<p><a href="http://www.cssnewbie.com/hiding-content-in-your-rss-feed/"><img src="http://www.cssnewbie.com/wp-content/uploads/2008/07/rssfeed.gif" alt="" /></a></p>
<p>As I wrote about in a recent article, <a href="http://www.cssnewbie.com/hiding-content-in-your-rss-feed/">hiding content in your RSS feed</a> doesn&#8217;t have to require a fancy plug-in &mdash; which is good for people who aren&#8217;t relying on a fancy content management system to generate their pages. Instead, producing RSS-only content can be as simple as hiding your content in your page with the display property &mdash; which is then ignored when picked up by RSS feed readers.</p>
<h5>Building Dropdown Menus</h5>
<p><a href="http://www.cssnewbie.com/easy-css-dropdown-menus/"><img src="http://www.cssnewbie.com/wp-content/uploads/2008/05/dropdown-400.gif" alt="" /></a></p>
<p>Without the CSS display property, fancy dropdown menus would be limited to the realm of JavaScript. However, by combining CSS&#8217;s display property and the :hover pseudo-class, you can create beautiful dropdown menus without a single line of JavaScript. Want to learn how? <a href="http://www.cssnewbie.com/easy-css-dropdown-menus/">Here&#8217;s a tutorial on creating easy CSS dropdown menus,</a> and <a href="http://www.cssnewbie.com/horizontal-dropdown-menus/">here&#8217;s a second tutorial on creating special horizontal dropdowns.</a></p>
<h5>Fixing Bugs</h5>
<p><a href="http://www.cssnewbie.com/double-margin-float-bug/"><img src="http://www.cssnewbie.com/wp-content/uploads/2008/06/doublemargin-400.gif" alt="" /></a></p>
<p>If you work on web development long enough, sooner or later some browser is going to throw a bug your way (Internet Explorer 6, I&#8217;m looking at you). But just because there&#8217;s a bug in the browser doesn&#8217;t mean that the fix has to be complicated. In fact, two of the most common Internet Explorer bugs out there &mdash; <a href="http://www.cssnewbie.com/fixing-ie6-whitespace-bug/">the IE6 Whitespace Bug</a> and <a href="http://www.cssnewbie.com/double-margin-float-bug/">the IE Double Margin Float Bug</a> &mdash; both use the &ldquo;display: inline&rdquo; property to make IE behave properly. Click the bug names for more in-depth information. </p>
<p>So when you get right down to it, the display property is a pretty useful little guy, even if only three of its values are supported. Just imagine how prolific it&#8217;d be if all its values were available!</p>
<div style="border: 1px solid #ccc; background-color: #f2f2f2; padding: 2px 10px; width: 378px; font: 12px/1.3 Arial, Helvetica, sans-serif; margin: 1em auto;">
<p><strong>CSSnewbie Subscriber Contest!</strong> Thanks for being a loyal subscriber. To enter and earn a chance at winning a free site review and CSS book, email <a href="mailto:contest@cssnewbie.com">contest@cssnewbie.com</a> with the following phrase (and <em>only</em> the phrase) in the subject line: <strong>CSSnewbie FTW!</strong></p>
<p>For more information, <a href="http://www.cssnewbie.com/cssnewbie-subscriber-contest/">see this CSSnewbie article.</a></p>
</div>

<p><a href="http://feeds.feedburner.com/~a/cssnewbie?a=ec2Lt4"><img src="http://feeds.feedburner.com/~a/cssnewbie?i=ec2Lt4" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/cssnewbie?a=b1yoEK"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=b1yoEK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=RcjEMk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=RcjEMk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=8yKlik"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=8yKlik" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=EyCMfk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=EyCMfk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=5C99WK"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=5C99WK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=otz4lk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=otz4lk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/369392663" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/5-great-uses-for-the-css-display-property/feed/</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=cssnewbie&amp;itemurl=http%3A%2F%2Fwww.cssnewbie.com%2F5-great-uses-for-the-css-display-property%2F</feedburner:awareness><feedburner:origLink>http://www.cssnewbie.com/5-great-uses-for-the-css-display-property/</feedburner:origLink></item>
		<item>
		<title>Generating Automatic Website Footnotes with jQuery</title>
		<link>http://feeds.feedburner.com/~r/cssnewbie/~3/364352228/</link>
		<comments>http://www.cssnewbie.com/generating-automatic-website-footnotes-with-jquery/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 00:46:10 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Advanced Techniques]]></category>

		<category><![CDATA[Frameworks and Libraries]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[jquery footnotes automatic generate javascript]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=217</guid>
		<description><![CDATA[Generating footnotes for HTML documents in the past was always a slow, painful task &#8212; and every time I did it, I wondered why there wasn't a better, easier way. Today, I'm happy to announce that I've come up with a better solution to web footnotes using the jQuery JavaScript framework and a few tags and attributes that already exist in XHTML. And I'm even happier to show you how to do it!]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.cssnewbie.com/example/automatic-footnotes/'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/automatic-footnotes.gif" alt="" title="automatic footnotes generated with jQuery" width="400" height="155" class="alignnone size-full wp-image-218" /></a></p>
<p>I spent a lot of time (7 long years) in academia, writing about technical communication and new media. During that time, I created many academic documents for the web. A lot of those documents had footnotes. Generating footnotes for HTML documents in the past was always a slow, painful task &mdash; and every time I did it, I wondered why there wasn&#8217;t a better, easier way.</p>
<p>Today, I&#8217;m happy to announce that I&#8217;ve come up with a better solution to web footnotes using the <a href="http://www.jquery.com/">jQuery JavaScript framework</a> and a few tags and attributes that already exist in XHTML. And I&#8217;m even happier to show you how to do it! <a href="http://www.cssnewbie.com/example/automatic-footnotes/">If you&#8217;d like to see it in action before we begin, go here.</a></p>
<h5>The Problem:</h5>
<ul>
<li>Many websites could benefit from having footnotes, but&#8230;</p>
<li>Manually creating footnotes for web documents is a slow process.</li>
</ul>
<h5>The Requirements:</h5>
<ul>
<li>Creating the footnotes should be as painless as possible (i.e., make use of as many standard tags/attributes as possible).</li>
<li>Users should be able to create footnotes that are pure commentary, book citation, web reference, or any combination thereof.</li>
</ul>
<h5>The Solution:</h5>
<p>I decided to make use of the two most common XHTML tags that might need footnote information: blockquotes and quotations (&lt;q&gt;). Both of those tags can take the &ldquo;cite&rdquo; attribute, whose value is the URL from which the quoted material originated.</p>
<pre class="html">&lt;q cite=&quot;http://www.cssnewbie.com/&quot;&gt;
	Rob Glazebrook of CSSnewbie is imminently quoatable.
&lt;/q&gt;</pre>
<p>That takes care of the URL portion of our requirements&#8230; but what about commentary-type asides or non-web citations? You can&#8217;t put those in the cite attribute, because the only acceptable value for that attribute is a URL, and any comments you put in will be rendered as such in the output (it&#8217;s ugly&#8230; trust me). So for comments and other reference material, let&#8217;s turn to the &ldquo;title&rdquo; attribute instead.</p>
<pre class="html">&lt;q title=&quot;Done with your TPS reports?&quot;&gt;
	Is this good for the company?
&lt;/q&gt;</pre>
<p>And if you&#8217;d like your footnote to look more like a standard-issue reference citation, you could even put markup inside your title.</p>
<pre class="html">&lt;q title=&quot;Zeldman, Jeffrey. &lt;em&gt;Designing with
Web Standards&lt;/em&gt; New Riders, 2003.&quot;&gt;
	We build only to rebuild.
&lt;/q&gt;</pre>
<p>Admittedly, sticking XHTML markup in your title tag is pretty bad practice, so I can&#8217;t say that I 100% recommend this tactic&#8230; but I&#8217;ve tested it, and it works (at least in XHTML Transitional).</p>
<p>So now that we know what our XHTML looks like, let&#8217;s turn to the jQuery!</p>
<pre class="js">$(document).ready(function() {
	$(&quot;#wrap&quot;).append(&quot;&lt;ol id=\&quot;footnotes\&quot;&gt;&lt;/ol&gt;&quot;);
	footnote = 1;
	$(&quot;q[cite],q[title],blockquote[cite],blockquote[title]&quot;).addClass(&quot;footnote&quot;);
	$(&quot;.footnote&quot;).each(function() {
		$(this).append(&quot;&lt;sup&gt;&quot;+footnote+&quot;&lt;/sup&gt;&quot;);
		cite=&quot;&lt;li&gt;&quot;;
		url=$(this).attr(&quot;cite&quot;);
		title=$(this).attr(&quot;title&quot;);
		if(title &amp;&amp; url) {
			cite+=&quot;&lt;a href=\&quot;&quot;+url+&quot;\&quot;&gt;&quot;+title+&quot;&lt;/a&gt;&quot;;
		} else if(title) {
			cite+=title;
		} else if(url) {
			cite+=&quot;&lt;a href=\&quot;&quot;+url+&quot;\&quot;&gt;&quot;+url+&quot;&lt;/a&gt;&quot;;
		}
		cite+=&quot;&lt;/li&gt;&quot;;
		$(&quot;#footnotes&quot;).append(cite);
		footnote++;
	});
});</pre>
<p>And now, so that everyone understands exactly what this script is doing, I&#8217;ll walk you through each section of code.</p>
<pre class="js">$(document).ready(function() {
});</pre>
<p>This bit of jQuery is saying &ldquo;wait until the document is fully loaded (&ldquo;ready&rdquo;), then run the following function. This prevents our script from running while the document is only half-loaded.</p>
<pre class="js">$(&quot;#wrap&quot;).append(&quot;&lt;ol id=\&quot;footnotes\&quot;&gt;&lt;/ol&gt;&quot;);
footnote = 1;</pre>
<p>The first line finds my element with an ID of &ldquo;wrap&rdquo; (you could use whatever element you wanted, such as the body tag), and appends (adds something to the end of) an ordered list with an ID of &ldquo;footnotes.&rdquo; This is where our script will stick all of our footnotes. The second line is just setting a variable, &ldquo;footnote,&rdquo; to a value of 1. This is the number we want our footnotes to start on.</p>
<pre class="js">$("q[cite],q[title],blockquote[cite],
blockquote[title]").addClass("footnote");</pre>
<p>This line is going through our entire document and finding every q and blockquote element with either a &ldquo;cite&rdquo; or &ldquo;title&rdquo; attribute set, and giving them all a class of &ldquo;footnote.&rdquo; </p>
<p>This is a workaround to a problem I uncovered while building the script. Originally, I was just cycling through the document, grabbing all q and blockquote elements and checking for their attributes later, using jQuery&#8217;s &ldquo;each&rdquo; function (which we&#8217;ll see in a moment). The problem is, if you specify more than one element in an &ldquo;each&rdquo; function, jQuery will build an array (good) of all of your <em>first</em> elements first, and your <em>second</em> elements second, and so on (bad, in our case). Which meant that when I went through and numbered my footnotes later in the script, all the &lt;q&gt; tags would get numbered, and then the script would start over at the top of the page and number all my &lt;blockquote&gt; tags. That resulted in all my footnotes being out of order. This fixes that problem.</p>
<pre class="js">$(".footnote").each(function() {
});</pre>
<p>Here&#8217;s the &ldquo;each&rdquo; function I mentioned previously. This line goes through the document and finds every instance of an item with a &ldquo;footnote&rdquo; class (which we just dynamically applied to all the appropriate elements), and then executes the contained function on every element it finds. It&#8217;s a cheap and easy &ldquo;foreach&rdquo; loop, basically.</p>
<pre class="js">$(this).append(&quot;&lt;sup&gt;&quot;+footnote+&quot;&lt;/sup&gt;&quot;);</pre>
<p>The first thing we do in our main function is append a footnote number to the end of the element. We put the footnote in a &ldquo;sup&rdquo; (superscript) tag to make it look like a footnote tag by default. You could use a different element if you so chose, and then use CSS to style it however you wish.</p>
<pre class="js">cite="&lt;li&gt;";
url=$(this).attr("cite");
title=$(this).attr("title");</pre>
<p>I&#8217;m setting three variables here. The first, &ldquo;cite,&rdquo; is the foundation for our footnote at the bottom of the page. Since I&#8217;m building my footnote list using an ordered list, every element within will be wrapped with &lt;li&gt; tags. Next, I&#8217;m creating a variable called &ldquo;url&rdquo; which contains the &ldquo;cite&rdquo; attribute, and a variable called &ldquo;title&rdquo; which contains the &ldquo;title&rdquo; attribute. If the attribute exists on our particular quote, the variable will be set with that attribute&#8217;s contents. If the attribute isn&#8217;t set, the variable will be a Boolean &ldquo;false.&rdquo;</p>
<pre class="js">if(title &amp;&amp; url) {
	cite+=&quot;&lt;a href=\&quot;&quot;+url+&quot;\&quot;&gt;&quot;+title+&quot;&lt;/a&gt;&quot;;
} else if(title) {
	cite+=title;
} else if(url) {
	cite+=&quot;&lt;a href=\&quot;&quot;+url+&quot;\&quot;&gt;&quot;+url+&quot;&lt;/a&gt;&quot;;
}</pre>
<p>We have three &ldquo;if&rdquo; checks and three possible outcomes here. If both the &ldquo;title&rdquo; and &ldquo;url&rdquo; variables are set, we wrap the &ldquo;title&rdquo; content in an anchor tag with an href of the &ldquo;url&rdquo; content, and add it to the end of our &ldquo;cite&rdquo; variable. If just the title is set, we just output the title. And if just the url variable is set, we output the url, wrapped in an anchor tag so it&#8217;s active.</p>
<pre class="js">cite+="&lt;/li&gt;";
$("#footnotes").append(cite);
footnote++;</pre>
<p>Now we just need to wrap up our script. First, we close the list item in our cite variable, now that the rest of its content has been filled. Then we append the contents of our cite variable to the end of the &ldquo;footnotes&rdquo; ordered list that we created at the beginning of our script. And last but not least, we increase the number of our footnote by one, so that the next footnote will be one larger than the last.</p>
<p>That&#8217;s all there is to it! <a href="http://www.cssnewbie.com/example/automatic-footnotes/">You can see this script in action here.</a> Be sure to view the source code so you can see that there is no footnote list in the code&#8230; it&#8217;s being automatically generated by our script. And of course, you&#8217;ll need to include <a href="http://www.jquery.com/">the jQuery framework</a> at the top of your document before you can run this script (view the source on <a href="http://www.cssnewbie.com/example/automatic-footnotes/">the example page</a> for a demonstration on how to do that). And you could style your footnotes any way you please: my example page contains some rudimentary styles you can feel free to borrow.</p>
<p>This script could probably be made more advanced fairly easily, and I might write another article in the future on expanding this script for added functionality. If you have any suggestions on other things you&#8217;d like to see this script do, don&#8217;t hesitate to share them in the comments! I&#8217;d also love to hear if you&#8217;re planning to use this script anywhere, if you know of a better way to write my jQuery (I&#8217;m new to the framework, so it&#8217;s possible), or anything else of that nature.</p>

<p><a href="http://feeds.feedburner.com/~a/cssnewbie?a=iL7296"><img src="http://feeds.feedburner.com/~a/cssnewbie?i=iL7296" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/cssnewbie?a=kHKrlK"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=kHKrlK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=MRXvSk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=MRXvSk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=ZTNpCk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=ZTNpCk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=kCmyhk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=kCmyhk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=4dJfDK"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=4dJfDK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=u8yJak"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=u8yJak" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/364352228" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/generating-automatic-website-footnotes-with-jquery/feed/</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=cssnewbie&amp;itemurl=http%3A%2F%2Fwww.cssnewbie.com%2Fgenerating-automatic-website-footnotes-with-jquery%2F</feedburner:awareness><feedburner:origLink>http://www.cssnewbie.com/generating-automatic-website-footnotes-with-jquery/</feedburner:origLink></item>
		<item>
		<title>Great Resources Elsewhere: August 1 to August 7</title>
		<link>http://feeds.feedburner.com/~r/cssnewbie/~3/359383102/</link>
		<comments>http://www.cssnewbie.com/great-resources-elsewhere-august-1-to-august-7/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 12:30:31 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Articles Elsewhere]]></category>

		<category><![CDATA[forms]]></category>

		<category><![CDATA[labels]]></category>

		<category><![CDATA[patterns]]></category>

		<category><![CDATA[survey]]></category>

		<category><![CDATA[textures]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=212</guid>
		<description><![CDATA[My favorite links for this last week are an eclectic mix. Here we have a collection of textures, a discussion on form design, a different sort of form development, and finally a survey. Enjoy!]]></description>
			<content:encoded><![CDATA[<p>My favorite links for this last week are an eclectic mix. Here we have a collection of textures, a discussion on form design, a different sort of form development, and finally a survey. Enjoy!</p>
<p><a href='http://beeex.net/freebies/patterns-backgrounds/ultimate-collection-of-free-textures-on-the-web-background-patterns-seamless-tiles-high-resolution'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/smashing-textures.jpg" alt="" title="smashing textures" width="400" height="80" class="alignnone size-full wp-image-213" /></a></p>
<h5><a href="http://beeex.net/freebies/patterns-backgrounds/ultimate-collection-of-free-textures-on-the-web-background-patterns-seamless-tiles-high-resolution">Ultimate Collection of Free Textures on the Web | Beeex.net</a></h5>
<p>While it might be a bit premature to call this the &ldquo;ultimate&rdquo; collection of textures, patterns, and backgrounds on the web &mdash; after all, I could just swipe this list, add one more resource, and call it the &ldquo;ultimate plus infinity&rdquo; resource &mdash; Beeex.net has nonetheless compiled a rather large and useful collection of backgrounds from around the web. Whether you&#8217;re looking for repeating patterns, large images, unique textures, or pattern generators, this is a great place to start your search.</p>
<p><a href='http://css-tricks.com/label-placement-on-forms/'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/label-placement.jpg" alt="" title="label placement" width="400" height="135" class="alignnone size-full wp-image-214" /></a></p>
<h5><a href="http://css-tricks.com/label-placement-on-forms/">Label Placement on Forms - CSS-Tricks</a></h5>
<p>Chris Coyier of CSS-Tricks posted an interesting discussion on form labels this week (and yes, that means I&#8217;m implying that discussions of form labels can in fact be interesting). The question he poses is this: does it make more sense to have a form&#8217;s labels top aligned, left aligned, or right aligned? While he doesn&#8217;t come to any clear-cut conclusions (no truly heady discussion ever does, after all), he does offer some pros and cons for each version&#8230; thus allowing you, the reader/designer, to choose the best solution for your design&#8217;s individual needs.<br />
<a href='http://www.flowdrops.com/2008/08/03/paypal-donation-form-with-css-and-jquery-for-wordpress/'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/paypal-donation-form.jpg" alt="" title="paypal donation form" width="400" height="157" class="alignnone size-full wp-image-215" /></a></p>
<h5><a href="http://www.flowdrops.com/2008/08/03/paypal-donation-form-with-css-and-jquery-for-wordpress/">PayPal donation form with CSS and jQuery for WordPress : i.Farang</a></h5>
<p>If you&#8217;ve ever considered accepting donations on your site (and if people are <em>wanting</em> to give you money, who are you to judge?), this is a good place to start looking. Pete of i.Farang has posted a fairly complete tutorial for how he developed his site&#8217;s custom Paypal donation form using a modified form from Paypal, a healthy dose of jQuery, and a bit of CSS. He even mentions how to incorporate the form into a Wordpress template, should you be so inclined (but Wordpress isn&#8217;t required to get the form to work).</p>
<p><a href='http://www.alistapart.com/articles/survey2008'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/ala-survey.jpg" alt="" title="ALA survey" width="400" height="139" class="alignnone size-full wp-image-216" /></a></p>
<h5><a href="http://www.alistapart.com/articles/survey2008">A List Apart: The Survey, 2008</a></h5>
<p>Last year, A List Apart decided to survey their web designer/developer/whatever readers in order to learn more about what they did, where they worked, and how they liked it. In the end, nearly 33,000 web-related professionals took the survey, giving our community its first real glimpse of a large-scale analysis of our own population. The results were so enlightening that ALA has decided to take another survey this year (and hopefully every year hereafter), allowing us to track our profession&#8217;s development over the course of time. I&#8217;ve already taken the survey, and if your job involves the web in any real capacity, I would strongly encourage you to take it as well.</p>

<p><a href="http://feeds.feedburner.com/~a/cssnewbie?a=7Ouoxo"><img src="http://feeds.feedburner.com/~a/cssnewbie?i=7Ouoxo" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/cssnewbie?a=Pz6g9K"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=Pz6g9K" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=q8sEbk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=q8sEbk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=tvtWjk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=tvtWjk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=tVC8mk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=tVC8mk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=3OYI3K"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=3OYI3K" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=J8nCyk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=J8nCyk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/359383102" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/great-resources-elsewhere-august-1-to-august-7/feed/</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=cssnewbie&amp;itemurl=http%3A%2F%2Fwww.cssnewbie.com%2Fgreat-resources-elsewhere-august-1-to-august-7%2F</feedburner:awareness><feedburner:origLink>http://www.cssnewbie.com/great-resources-elsewhere-august-1-to-august-7/</feedburner:origLink></item>
		<item>
		<title>Easy Rounded Corners with Border-Radius</title>
		<link>http://feeds.feedburner.com/~r/cssnewbie/~3/357897498/</link>
		<comments>http://www.cssnewbie.com/easy-rounded-corners-with-border-radius/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 00:34:59 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Advanced Techniques]]></category>

		<category><![CDATA[blockquote]]></category>

		<category><![CDATA[border]]></category>

		<category><![CDATA[border-radius]]></category>

		<category><![CDATA[comment]]></category>

		<category><![CDATA[css3]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=205</guid>
		<description><![CDATA[The realm of CSS is a realm of boxes. However, the forthcoming CSS3 specification offers us a glimmer of hope in the form of <strong>rounded corners</strong>. And better yet, a few browsers already support rounded corners! ]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.cssnewbie.com/example/rounded-corners/'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/rounded-beauty.gif" alt="" title="rounded corners" width="400" height="187" class="alignnone size-full wp-image-206" /></a></p>
<p>The realm of CSS is a realm of boxes. <a href="http://www.cssnewbie.com/understanding-the-css-box-model/" title="Understanding the CSS Box Model">Everything on the page is a box,</a> within a box, within a box. No wonder it&#8217;s so common for beginning CSS developers (or, in my case, poor graphic designers with too much CSS experience) to create boxy layouts!</p>
<p>However, the forthcoming CSS3 specification offers us a glimmer of hope in the form of <strong>rounded corners</strong>. That&#8217;s right &mdash; once CSS3 is commonly supported, we&#8217;ll be able to childproof all those pointy edges and beautify the web in the process.</p>
<p>And better yet, a few browsers already support rounded corners! As I&#8217;m writing this, you&#8217;re pretty much limited to Mozilla/Firefox and Safari 3. However, this list is bound to grow as time goes on, so it couldn&#8217;t hurt to start playing around with this feature. Especially considering that, in the browsers that don&#8217;t support rounded corners, nothing bad happens &mdash; the user just sees regular, square corners.</p>
<p>For now, to get the code to work, you&#8217;re stuck using proprietary CSS tags: they won&#8217;t validate, but they&#8217;ll just be ignored by browsers that don&#8217;t support them. The code itself is pretty simple; for example, to create a div with nice rounded corners with a radius of 5 pixels, you&#8217;d just write something like this:</p>
<pre class="css">div.rounded {
	background-color: #666;
	color: #fff;
	font-weight: bold;
	padding: 10px;
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px; }</pre>
<p>And this rule will create a div that looks like this:</p>
<p><a href='http://www.cssnewbie.com/example/rounded-corners/'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/rounded-div.gif" alt="" title="rounded-div" width="400" height="86" class="alignnone size-full wp-image-207" /></a></p>
<p>The two properties of note here are &ldquo;-moz-border-radius&rdquo; and &ldquo;-webkit-border-radius.&rdquo; The former is how to specify the radius &mdash; number of pixels from a hypothetical center point to the edge of the circle created by the rounded corner (see the image below) &mdash; in Mozilla-based browsers. The latter is doing the same thing, but for Safari.</p>
<p><a href='http://www.cssnewbie.com/example/rounded-corners/'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/rounded-detail.gif" alt="" title="rounded-detail" width="400" height="199" class="alignnone size-full wp-image-208" /></a></p>
<p>The rule isn&#8217;t just limited to curving background colors, either. If you were to add a border to the element, the border would become rounded, as well. For example, <a href="http://www.cssnewbie.com/six-ways-style-blockquotes/" title="Six Ways to Style Blockquotes">a block quote could be styled</a> like so:</p>
<pre class="css">blockquote {
	margin: 1em 20px;
	padding: 10px;
	border: 2px solid #555;
	background-color: #f2f2f2;
	color: #555;
	font-size: 140%;
	text-align: justify;
	-moz-border-radius: 10px;
	-webkit-border-radius: 10px; }</pre>
<p>Resulting in a block quote that has a lot of style, without relying on images to accomplish the task:</p>
<p><a href='http://www.cssnewbie.com/example/rounded-corners/'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/rounded-blockquote.gif" alt="" title="rounded-blockquote" width="400" height="119" class="alignnone size-full wp-image-209" /></a></p>
<p>And finally, you&#8217;re also not limited to either all rounded corners or none. Using this property, you can specify which corners you want rounded in your CSS. However, it&#8217;s important to note that the Firefox-based version of this rule has deviated a bit from the W3C standard, meaning it&#8217;s written slightly differently than the Safari-based rule. For example, consider these two rules used to round out the top-left corner of a box:</p>
<pre class="css">-moz-border-radius-topleft: 5px;
-webkit-border-top-left-radius: 5px;</pre>
<p>It&#8217;s a minor difference, in the grand scheme of things, but pretty critical if you want your rounded corners to show up where and how they should! Using the ability to round individual corners, you could generate fancy alert messages:</p>
<pre class="css">.alert {
	border: 2px solid #fc0;
	padding: 8px 10px;
	font-size: 120%;
	color: #c90;
	font-weight: bold;
	background-color: #ff9;
	-moz-border-radius-topleft: 8px;
	-webkit-border-top-left-radius: 8px;
	-moz-border-radius-bottomright: 8px;
	-webkit-border-bottom-right-radius: 8px; }</pre>
<p><a href='http://www.cssnewbie.com/example/rounded-corners/'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/rounded-alert.gif" alt="" title="rounded-alert" width="400" height="82" class="alignnone size-full wp-image-210" /></a></p>
<p>Or, you could apply rounded corners to three of the four edges of a user&#8217;s comment, resulting in a pseudo-voice bubble, all without a single image in sight:</p>
<pre class="css">.comment {
	border: 1px solid #999;
	background-color: #d8d8f4;
	margin: 1em 40px;
	padding: 15px;
	-moz-border-radius-topleft: 15px;
	-webkit-border-top-left-radius: 15px;
	-moz-border-radius-topright: 15px;
	-webkit-border-top-right-radius: 8px;
	-moz-border-radius-bottomleft: 15px;
	-webkit-border-bottom-left-radius: 15px; }</pre>
<p><a href='http://www.cssnewbie.com/example/rounded-corners/'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/rounded-comment.gif" alt="" title="rounded-comment" width="400" height="86" class="alignnone size-full wp-image-211" /></a></p>
<p><a href="http://www.cssnewbie.com/example/rounded-corners/">You can see all of my examples in action here.</a> And these are just a few ways of the hundreds of ways you can harness the power of rounded corners with just a few lines of code. With techniques like this at our disposal, it&#8217;s easy to see why we&#8217;re all so eagerly awaiting CSS3!
<div style="border: 1px solid #ccc; background-color: #f2f2f2; padding: 2px 10px; width: 378px; font: 12px/1.3 Arial, Helvetica, sans-serif; margin: 1em auto;">
<p><strong>CSSnewbie Subscriber Contest!</strong> Thanks for being a loyal subscriber. To enter and earn a chance at winning a free site review and CSS book, email <a href="mailto:contest@cssnewbie.com">contest@cssnewbie.com</a> with the following phrase (and <em>only</em> the phrase) in the subject line: <strong>CSSnewbie FTW!</strong></p>
<p>For more information, <a href="http://www.cssnewbie.com/cssnewbie-subscriber-contest/">see this CSSnewbie article.</a></p>
</div>

<p><a href="http://feeds.feedburner.com/~a/cssnewbie?a=DVcvo1"><img src="http://feeds.feedburner.com/~a/cssnewbie?i=DVcvo1" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/cssnewbie?a=7g5WYK"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=7g5WYK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=UESvck"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=UESvck" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=bx03kk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=bx03kk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=TPL9Rk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=TPL9Rk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=rSZXNK"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=rSZXNK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=35zMjk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=35zMjk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/357897498" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/easy-rounded-corners-with-border-radius/feed/</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=cssnewbie&amp;itemurl=http%3A%2F%2Fwww.cssnewbie.com%2Feasy-rounded-corners-with-border-radius%2F</feedburner:awareness><feedburner:origLink>http://www.cssnewbie.com/easy-rounded-corners-with-border-radius/</feedburner:origLink></item>
		<item>
		<title>CSSnewbie Subscriber Contest!</title>
		<link>http://feeds.feedburner.com/~r/cssnewbie/~3/355812108/</link>
		<comments>http://www.cssnewbie.com/cssnewbie-subscriber-contest/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 00:14:05 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Site News]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=203</guid>
		<description><![CDATA[
The month of August holds a lot of special significance to me. My birthday is in August (is, in fact, this Wednesday). I work for a great company that features the word &#8220;August&#8221; in its masthead. The month itself was named after Caesar Augustus, arguably a cool cat in an old-school sort of way. And [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://feeds.feedburner.com/cssnewbie'><img src="http://www.cssnewbie.com/wp-content/uploads/2008/08/cssnewbie-subscriber-contest.gif" alt="" title="cssnewbie-subscriber-contest" width="400" height="150" class="alignnone size-full wp-image-204" /></a></p>
<p>The month of August holds a lot of special significance to me. My birthday is in August (is, in fact, this Wednesday). I work for a great company that features the word &ldquo;August&rdquo; in its masthead. The month itself was named after Caesar Augustus, arguably a cool cat in an old-school sort of way. And the word &ldquo;august&rdquo; as an adjective means something majestic or awe-inspiring. Neat, huh?</p>
<p>So to celebrate all that is August and Awesome, I&rsquo;ve decided to hold <strong>the first-ever CSSnewbie Contest!</strong> The winner will receive: </p>
<ol>
<li><strong>A review of your website on CSSnewbie.</strong> If you&rsquo;re new to web development, I can offer suggestions on how to improve/update the site. If you&rsquo;re already an established web guru, I can promote the splendor that is your site and hopefully send a bit of traffic your way. If you don&rsquo;t want to promote your site, I&rsquo;d also be willing to do a private review for your eyes only.</li>
<li><strong>Eric Meyer&rsquo;s book, <a href="http://www.amazon.com/exec/obidos/ASIN/0596515057/cssnewbie-20"><em>CSS Pocket Reference: Visual Presentation for the Web.</em></a></strong> This handy-dandy 168-page book is chock full of great CSS information presented in cheat sheet format.</li>
</ol>
<h5>How It Works:</h5>
<p>You subscribe to the CSSnewbie RSS feed using either the links in the sidebar or at the bottom of this (and every) post. If you&rsquo;re already a subscriber, congratulations! You don&rsquo;t have to do anything else except remain the subscriber you are.</p>
<p>Watch for a pass-phrase to appear at the bottom of an article in the RSS feed. Remember that <a href="http://www.cssnewbie.com/hiding-content-in-your-rss-feed/" title="Hiding Content in Your RSS Feed">&ldquo;hiding content in your RSS feed&rdquo;</a> article last week? Here&rsquo;s where that comes into play. The pass-phrase won&rsquo;t be present in every article, but it&rsquo;ll be there often enough that you&rsquo;ll be able to find it if you&rsquo;re looking for it.</p>
<p>Once you&rsquo;ve found the pass-phrase, shoot an email to <a href="mailto:contest@cssnewbie.com">contest@cssnewbie.com.</a> The subject line should be the pass-phrase <strong>and nothing else.</strong> The body of the message should contain a link to the website you&rsquo;d like to have reviewed/promoted, and can also contain any other comments you&rsquo;d like to include. <strong>Email me before the contest ends</strong> at the end of the day (11:59PM Central Time) on August 31, 2008.</p>
<p>On September 1, 2008 (or thereabouts &mdash; I reserve the right to extend the contest by a week or so if it looks like a lot of people are pouring in at the last minute) I&rsquo;ll randomly (programmatically) select a winner from the list of emails. They will be notified by email, and an announcement will go up on the site. If the winner doesn&rsquo;t respond within a week of the announcement, I&rsquo;ll pick a new winner. And so on.</p>
<p>This proposition is really win-win for all involved, I think. If you subscribe to CSSnewbie, I&rsquo;ll obviously benefit from the additional readership. And if you win, you&rsquo;ll benefit from that same influx by boosting the number of people who will see your website (and you&#8217;ll get a great CSS book to boot!). And hopefully everyone else who subscribes will at least benefit from the articles that get posted here on CSSnewbie.</p>
<p>So click that subscribe button, spread the word about the contest, and let&rsquo;s see if we can&rsquo;t make August the best month ever!</p>

<p><a href="http://feeds.feedburner.com/~a/cssnewbie?a=e3ve4S"><img src="http://feeds.feedburner.com/~a/cssnewbie?i=e3ve4S" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/cssnewbie?a=d0vhkK"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=d0vhkK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=qh7KSk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=qh7KSk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=HAP1nk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=HAP1nk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=Q7fKCk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=Q7fKCk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=tKADeK"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=tKADeK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=8MENBk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=8MENBk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/355812108" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/cssnewbie-subscriber-contest/feed/</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=cssnewbie&amp;itemurl=http%3A%2F%2Fwww.cssnewbie.com%2Fcssnewbie-subscriber-contest%2F</feedburner:awareness><feedburner:origLink>http://www.cssnewbie.com/cssnewbie-subscriber-contest/</feedburner:origLink></item>
		<item>
		<title>Great Resources Elsewhere: July 25 to July 31</title>
		<link>http://feeds.feedburner.com/~r/cssnewbie/~3/352545937/</link>
		<comments>http://www.cssnewbie.com/great-resources-elsewhere-july-25-to-july-31/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 12:00:06 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Articles Elsewhere]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=196</guid>
		<description><![CDATA[PNGs (Portable Network Graphics) are one of the coolest things to happen to the web in the last decade. Unfortunately due to terrible PNG support in Internet Explorer 6 (which is arguably one of the least cool things to happen to the web in the last decade), PNGs have never really caught on. However, as IE6 usage starts to drop and PNG support in all major modern browsers, PNGs are set to make a comeback...]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.cssnewbie.com/wp-content/uploads/2008/07/pngfix.jpg" alt="" title="PNG Fix" width="400" height="137" class="alignnone size-full wp-image-197" /></p>
<h5><a href="http://labs.unitinteractive.com/unitpngfix.php">Unit Interactive :: Labs :: Unit PNG Fix</a></h5>
<p>PNGs (Portable Network Graphics) are one of the coolest things to happen to the web in the last decade. Unfortunately due to terrible PNG support in Internet Explorer 6 (which is arguably one of the least cool things to happen to the web in the last decade), PNGs have never really caught on. However, as IE6 usage starts to drop and PNG support in all major modern browsers, PNGs are set to make a comeback. But what about poor, old IE6? Well, that’s what fixes are for. And Unit Interactive had released a new PNG fixer-upper script for IE6 that is lightweight and does most all of what you’d want a PNG fixer-upper script to do.</p>
<p><img src="http://www.cssnewbie.com/wp-content/uploads/2008/07/200resources.jpg" alt="" title="200 resources" width="400" height="260" class="alignnone size-full wp-image-198" /></p>
<h5><a href="http://designm.ag/resources/freelance-designers/">200+ Resources for Freelance Web Designers | DesignM.ag</a></h5>
<p>The folks over at DesignM.ag (whose site I’d never seen, but will definitely be visiting again!) have compiled a fantastic list of over 200 resources for the freelancing folk in the web design/development community. They’ve broken their compilation into two parts: business resources and design/development resources. The business resources are all about helping you (the presumed freelancer) work better and faster: they cover everything from finding freelance jobs, to invoicing your clients, to managing your time and projects. The design resources, on the other hand, are a great resource for finding new sites to bookmark: they have stock photography sites, layout generators, <a href="http://www.cssnewbie.com/4-ways-css-can-improve-your-seo/" title="4 Ways CSS can Improve Your SEO">SEO tools</a>, and more.</p>
<p><img src="http://www.cssnewbie.com/wp-content/uploads/2008/07/dottedline.jpg" alt="" title="dotted line" width="400" height="130" class="alignnone size-full wp-image-199" /></p>
<h5><a href="http://css-tricks.com/removing-the-dotted-outline/">Removing The Dotted Outline – CSS-Tricks</a></h5>
<p>If you’re a regular Firefox user (and with the great rendering and <a href="http://www.cssnewbie.com/tool-review-firebug/" title="Tool Review: Firebug for Firefox">better</a> <a href="http://www.cssnewbie.com/firefox-error-console-review/" title="Tool Review: Firefox Error Console">plugins</a>, why wouldn’t you be?), you’ve probably noticed a certain bit of “usability” that more often than not just looks pretty darn annoying: the dotted outline Firefox puts around links or images when you click them. The outline is meant to act as a visual cue, letting you know which of the possibly closely associated links just received your ministrations. However, the effect more often than not simply clashes with the site’s overall design. Luckily there’s an easy fix, and Chris over at CSS-Tricks has written an article on removing that annoying little line. And better still, he offers solutions for adding <em>some sort</em> of visual “click” indicator back to the anchor, thus preserving usability, but not at the expense of beauty.</p>
<p><img src="http://www.cssnewbie.com/wp-content/uploads/2008/07/contactform.jpg" alt="" title="contact form" width="400" height="167" class="alignnone size-full wp-image-200" /></p>
<h5><a href="http://nettuts.com/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/">NETTUTS – Submit a Form Without Page Refresh using jQuery</a></h5>
<p>This tutorial had an awful lot to offer me. jQuery is, in my humble opinion, the coolest JavaScript framework out there to date. But clunky form redirection, on the other hand, is one of the (admittedly copious) banes of my existence. So this tutorial rocks, in that it’s using a technology I love (and plan to start writing more about here) to eliminate a problem I despise. And if you’ve ever wanted a surprisingly simple way to validate and process form inputs without having to refresh the page, I wager you’ll like this tutorial just as much as I did.</p>

<p><a href="http://feeds.feedburner.com/~a/cssnewbie?a=PFPzV0"><img src="http://feeds.feedburner.com/~a/cssnewbie?i=PFPzV0" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/cssnewbie?a=XHDvsK"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=XHDvsK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=3vUvlk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=3vUvlk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=IDOb8k"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=IDOb8k" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=x3g1Zk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=x3g1Zk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=NGLoeK"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=NGLoeK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/cssnewbie?a=6xEQDk"><img src="http://feeds.feedburner.com/~f/cssnewbie?i=6xEQDk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/352545937" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/great-resources-elsewhere-july-25-to-july-31/feed/</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=cssnewbie&amp;itemurl=http%3A%2F%2Fwww.cssnewbie.com%2Fgreat-resources-elsewhere-july-25-to-july-31%2F</feedburner:awareness><feedburner:origLink>http://www.cssnewbie.com/great-resources-elsewhere-july-25-to-july-31/</feedburner:origLink></item>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetFeedData?uri=cssnewbie</feedburner:awareness></channel>
</rss>
