Click to See Complete Forum and Search --> : styling a list
mattastic
08-08-2007, 03:46 AM
Hi Folks,
Can anyone tell me how I can style the list below, to look like the attached image?
Thankyou
<ul>
<li><a href="?linkid=foo" accesskey="e">link</a> </li>
<li><a href="?linkid=foo" accesskey="e">link</a> </li>
<li><a href="?linkid=foo" accesskey="e">link</a> </li>
<li ><a href="?linkid=poo" accesskey="e">link</a> </li>
<li><a href="?linkid=foo" accesskey="e">link</a> </li>
<li><a href="?linkid=foo" accesskey="e">link</a> </li>
<li><a href="?linkid=foo" accesskey="e">link</a> </li>
<li><a href="?linkid=foo" accesskey="e">link</a> </li>
<li><a href="?linkid=foo" accesskey="e">link</a> </li>
</ul>
ryanbutler
08-08-2007, 08:15 AM
Here's something to get you started:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css" media="screen">
ul#listcol1{
float:left;
list-style-type:none;
}
ul#listcol2 {
float:left;
list-style-type:none;
}
ul#listcol3{
float:left;
list-style-type:none;
}
a:link{
text-decoration:none;
color:#000;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:.8em;
}
</style>
</head>
<body>
<ul id="listcol1">
<li><a href="#">link one</a></li>
<li><a href="#">link two</a></li>
<li><a href="#">link three</a></li>
</ul>
<ul id="listcol2">
<li><a href="#">link four</a></li>
<li><a href="#">link two</a></li>
<li><a href="#">link three</a></li>
</ul>
<ul id="listcol3">
<li><a href="#">link four</a></li>
<li><a href="#">link two</a></li>
<li><a href="#">link three</a></li>
</ul>
</body>
</html>
You could probably make a rectangle in your graphics editor and then assign it as a wrapper and then nest the lists inside to simulate equal height.
mattastic
08-08-2007, 08:21 AM
Thanks for your reply, is it possible to something using a single list?
Centauri
08-08-2007, 09:42 AM
Yes, using floats and a little trickery with negative margins to allow the width of the ul to hide the right margin of the third column :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
<!--
* {
margin: 0;
padding: 0;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
#menu {
background-color: #CEDBEE;
width: 52em;
overflow: hidden;
padding: 5px 0;
margin: 10px auto;
}
#menu li {
list-style: none;
float: left;
border-right: 1px solid #999999;
margin: 0 -1em 0 1em;
display: inline;
}
#menu a {
color: #000000;
text-decoration: none;
display: block;
width: 15em;
height: 1.5em;
line-height: 1.5em;
padding-left: 2em;
float: left;
font-weight: bold;
}
#menu a:hover {
color: #E1017B;
text-decoration: underline;
}
-->
</style>
</head>
<body>
<ul id="menu">
<li><a href="?linkid=foo" accesskey="e">link</a></li>
<li><a href="?linkid=foo" accesskey="e">link</a></li>
<li><a href="?linkid=foo" accesskey="e">link</a></li>
<li><a href="?linkid=poo" accesskey="e">link</a></li>
<li><a href="?linkid=foo" accesskey="e">link</a></li>
<li><a href="?linkid=foo" accesskey="e">link</a></li>
<li><a href="?linkid=foo" accesskey="e">link</a></li>
<li><a href="?linkid=foo" accesskey="e">link</a></li>
<li><a href="?linkid=foo" accesskey="e">link</a></li>
<li><a href="?linkid=foo" accesskey="e">link</a></li>
<li><a href="?linkid=foo" accesskey="e">link</a></li>
</ul>
</body>
</html>
Cheers
Graeme
mattastic
08-09-2007, 04:55 AM
Thats look great thanks.
Is there anyway you can stop the item text from repeating underneath a different list item?
This is happening when I use longer text names, I've attached a screenshot.
If you note the link in the middle of the image "Centre of Vocational Excellence" the word 'excellence' is repeating underneath the item below.
Thankyou
Centauri
08-09-2007, 05:30 AM
That should just be a matter of increasing the width of #menu and #menu a so that the text fits.
And the centred text doesn't look as good as left aligned in this application.
mattastic
08-09-2007, 05:55 AM
Thanks for your reply.
Is there anyway I can wrap the text inside the list item?
So I dont have to resize the menu for different length names?
Centauri
08-09-2007, 06:12 AM
You can do that by removing the height from #menu a, however wrapping to another line breaks the layout and link order. I would tend to keep the link text as even and short as possible, and using the title attribute to supply additional popup information.