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

<channel>
	<title>Mesmer Lab &#187; unordered list</title>
	<atom:link href="http://www.mesmerlab.com/tag/unordered-list/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mesmerlab.com</link>
	<description>Tech and trends in web design+development.</description>
	<lastBuildDate>Tue, 22 Jun 2010 00:59:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Create a Menu Tree with CSS</title>
		<link>http://www.mesmerlab.com/create-a-graphic-menu-tree-with-css/</link>
		<comments>http://www.mesmerlab.com/create-a-graphic-menu-tree-with-css/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 00:30:34 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[unordered list]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.mesmerlab.com/?p=232</guid>
		<description><![CDATA[In this article I&#8217;ll show you how to get rid of the stock disc that is on the typical unordered list &#60;UL&#62;. This solution will work no matter how many characters are in your list item &#60;LI&#62;. 
You&#8217;ll create two images, throw a little CSS code in the mix, and end up with a very [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.mesmerlab.com/wp-content/uploads/2009/02/feature-image.png" alt="Create a Visual Submenu Tree with Pure CSS" title="Create a Visual Submenu Tree with Pure CSS" width="203" height="226" class="alignright size-full wp-image-314 postimage" />In this article I&#8217;ll show you how to get rid of the stock disc that is on the typical unordered list &lt;UL&gt;. This solution will work no matter how many characters are in your list item &lt;LI&gt;. </p>
<p>You&#8217;ll create two images, throw a little CSS code in the mix, and end up with a very flexible system that will grow with almost anything you throw at it. You can use the already present colors to help your lists tie in with the design. I&#8217;ve used this on a project and the client really liked how it turned out. So continue reading and I&#8217;ll guide you step by step on how to add this customization to your toolbelt. Your clients will love you for it.<span id="more-232"></span></p>
<p><a href="http://www.mesmerlab.com/demo/ul-tree.html" target="_blank">View the demo</a>.</p>
<h3>Step One: Create Two Images</h3>
<p><img src="http://www.mesmerlab.com/wp-content/uploads/2009/02/ul-many-closeup.png" alt="LI background image, long" title="LI background image, long" width="96" height="187" class="alignright size-full wp-image-303 postimage" />Open up your image editor of choice and create a new file 16px wide by 100px tall, or however tall you think a single list item will be in your situation. </p>
<p><img src="http://www.mesmerlab.com/wp-content/uploads/2009/02/ul-end-closeup.png" alt="LI background image, end" title="LI background image, end" width="96" height="90" class="alignright size-full wp-image-304 postimageleft" />You can get a little creative with it, but I drew a simple 1px line. Setting the background transparent will keep your images future-proof if you ever want to change the background color of the site. </p>
<p>So you will end up with two images, one relatively tall with the horizontal bar at the top and another relatively square with the horizontal part ending where it meets the vertical.</p>
<h3>Step Two: Write the CSS Code</h3>
<p>Now open up your code editor of choice. I&#8217;ve used Dreamweaver forever, but I&#8217;m starting to use Notepad++ more often.</p>
<h5>Clear All Inherent Styling</h5>
<p>The first part of the CSS code is extremely important because Internet Explorer still has the majority of the browser share. It is good practice to have a reset file like <a href="http://meyerweb.com/eric/tools/css/reset/index.html">this one</a>. If you&#8217;re not going to use a reset.css file, you must clear the layout of your list.</p>
<blockquote><pre><code>ul {margin:0;padding:0;}</code></pre>
</blockquote>
<h5>Create The Menu Container</h5>
<p>This is optional, in case you already have a home for your menu. But all subsequent code assumes that the &#8217;submenu&#8217; class is applied to your list&#8217;s parent.</p>
<blockquote><pre><code>.submenu {
	width: 200px;
	border: 1px solid #555;
	font: normal bold 12px Verdana, Arial, sans-serif;
	padding:10px;
	color: #3877C4;
	}</code></pre>
</blockquote>
<h5>UL Code</h5>
<p><img src="http://www.mesmerlab.com/wp-content/uploads/2009/02/ul-code.png" alt="Top and bottom padding for spacing, left padding to offset from header text." title="Top and bottom padding for spacing, left padding to offset from header text." width="200" height="185" class="alignright size-full wp-image-346 postimage" />This code will format the unordered list. Add a little top and bottom padding for spacing. The left padding offsets the list from the header text.</p>
<blockquote style="float:left;width:320px;"><pre><code>.submenu ul {
	padding:10px 0 10px 20px;
	}</code></pre>
</blockquote>
<h5>LI Code</h5>
<p><img src="http://www.mesmerlab.com/wp-content/uploads/2009/02/li-code.png" alt="Puts in some breathing room in case there are multiple lines. Gets rid of the stock icon. Adds some bottom padding for spacing." title="Puts in some breathing room in case there are multiple lines. Gets rid of the stock icon. Adds some bottom padding for spacing." width="180" height="157" class="alignright size-full wp-image-350 postimage" />The first line puts in a little breathing room if/when your text expands into multiple lines. Setting the &#8216;list-style-type&#8217; to none gets rid of the stock icon. To end up, we apply a little bottom padding for visual goodness.</p>
<blockquote style="float:left;width:340px;"><pre><code>.submenu li {
	line-height:15px;
	list-style-type:none;
	padding:0 0 8px 0;
	}</code></pre>
</blockquote>
<h5>Second Tier UL Code</h5>
<p><img src="http://www.mesmerlab.com/wp-content/uploads/2009/02/2ndul-code.png" alt="Top padding to push down from the LI parent. Left padding to indent." title="Top padding to push down from the LI parent. Left padding to indent." width="180" height="107" class="alignright size-full wp-image-354 postimage" />We are now into the second level of the menu. A little top padding pushes this UL down from its LI parent. The left padding indents the UL and can be modified to your taste.</p>
<blockquote style="float:left;width:340px;"><pre><code>.submenu li ul {
	padding: 5px 0 0 18px;
	}</code></pre>
</blockquote>
<h5>Second Tier LI Code</h5>
<p><img src="http://www.mesmerlab.com/wp-content/uploads/2009/02/2ndli-code1.png" alt="Left padding to push text off of the image." title="Left padding to push text off of the image." width="179" height="54" class="alignright size-full wp-image-358 postimage" />Now we&#8217;re into the good stuff. Most of your second tier list items will use this piece of code. Make sure you use the correct path to your image file. This is the tall graphic I had you create earlier. Of course we don&#8217;t want it to repeat. And the left padding pushes your LI text over so we can see your shiny new image.</p>
<blockquote style="float:left;width:563px;"><pre><code>.submenu li ul li {
	background-image:url(ul-long.gif);
	background-repeat:no-repeat;
	padding-left:18px;
	}</code></pre>
</blockquote>
<h5>Second Tier LI Code &#8211; Last LI</h5>
<p><img src="http://www.mesmerlab.com/wp-content/uploads/2009/02/2ndli-code-end.png" alt="Zero padding. The 18px from .submenu li ul takes care of this. We&#039;re also swapping the background image." title="Zero padding. The 18px from .submenu li ul takes care of this. We&#039;re also swapping the background image." width="162" height="15" class="alignright size-full wp-image-361 postimage" />So up until this point we have only used a single class, the one applied to the container. To be compatible with all browsers we must employ a class to put the endcap on the list. Now we use the smaller graphic of course. We reset the bottom padding to zero because the second tier UL code does this already.</p>
<blockquote style="float:left;width:563px;"><pre><code>.submenu li ul li.end {
	background-image:url(ul-end.gif);
	padding-bottom:0;
	}</code></pre>
</blockquote>
<h5>Second Tier LI Code &#8211; :last-child</h5>
<p><img src="http://www.mesmerlab.com/wp-content/uploads/2009/02/last-child.png" alt="Internet Explorer doesn&#039;t recognize the :last-child pseudo-class." title="Internet Explorer doesn&#039;t recognize the :last-child pseudo-class." width="176" height="206" class="alignright size-full wp-image-362 postimage" /><span style="color:red;">This code is not suggested for deployment. This is only for demonstration purposes.</span></p>
<p>So as you might know, Internet Explorer likes to employ its own dialect of CSS. One piece of very useful code that is missing in all IE flavors is the :last-child pseudo class. To be fair, :first-child works fine. When not in demonstration mode with three different menus you&#8217;ll want to use the code below. To facilitate the demo of :last-child alongside two other menus I have dropped a &#8216;lastchild&#8217; class on the second tier UL on the demo page, third box.</p>
<p>Open the page in Firefox, Chrome and Safari. You&#8217;ll see no difference in the far right menu. Open in IE and you&#8217;ll get the standard LI code with the tall graphic on the last LI. Maybe they&#8217;ll add it in IE 8.1?</p>
<blockquote><pre><code>.submenu li ul li:last-child {
	background-image:url(ul-end.gif);
	padding-bottom:0;
	}</code></pre>
</blockquote>
<div class="clear"></div>
<p><a href="http://www.mesmerlab.com/demo/ul-tree.html" target="_blank">View the demo</a>.</p>
<h3>Final Thoughts</h3>
<p>Try out some of these ideas to spruce up my simple design.</p>
<ul>
<li>Arrow on the right side of the images</li>
<li>Curve the vertical line into the horizontal line</li>
<li>Use an animated gif to make your list more dynamic</li>
<li>Use a single sprite instead of two images.</li>
</ul>
<p>If you&#8217;re going to use alpha transparency in your image, you&#8217;ll want to save as a PNG-24. Doing this will skew your colors slightly in Internet Explorer. This is because of the gamma correction saved in the image. Every browser except IE disregards the gamma value. I&#8217;ll show you how to correct this in an upcoming article.</p>
<p>Let me know how you liked this tutorial. Any comments and suggestions are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mesmerlab.com/create-a-graphic-menu-tree-with-css/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
