Click to See Complete Forum and Search --> : How can I create this with CSS


gregmatic
10-31-2003, 01:51 PM
I have a vertical column of links in a table, and I would like to convert it to CSS. If anyone has the time, I would greatly appreciate the help.

Original code:


<table border="0" align="left" bgcolor="#000066" width="220" cellspacing="0">
<tr>
<th><font color="#cccccc">Our Products</font></th>
</tr>


<!-- Vertical Nav Bar Links Nested in Table 2 -->
<tr>
<td align="center"><table border="3" align="center" bgcolor="#cccccc" width="180" cellspacing="0">

<!-- Begin Vertical Nav Bar Links Table 3 -->

<tr>
<td align="center"><a href="aodcat.htm" title="AOD Performance Products">AOD Products</a></td>
</tr>

<tr>
<td align="center"><a href="aodecat.htm" title="AODE and 4R70W Performance Products">AODE/4R70W Products</a></td>
</tr>

<tr>
<td align="center"><a href="e4odcat.htm" title="E4OD and 4R100E Performance Products">E4OD/4R100E Products</a></td>
</tr>

<tr>
<td align="center"><a href="electronicscat.htm" title="Our Innovative Electronic Products">Electronic Products</a></td>
</tr>

<tr>
<td align="center"><a href="othercat.htm" title="Other Transmission Related Products">Other Products</a></td>

</tr>

</table></td>

<tr>
<td>&nbsp;</td>
</tr>

</table>

Greg

Charles
10-31-2003, 02:03 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Lorem ipsum</title>

<style type="text/css">
<!--
#main {margin-left:11em}
#menu {position:absolute; top:1em}
.separator {display:none}
#menu a {display:block; margin:1em 0em; width:10em}
-->
</style>

<div id="main">
<h1>Lorem ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipitlobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor *** soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem.</p>
</div>

<div id="menu">
<h4>Our Products</h4>
<a href="aodcat.htm" title="AOD Performance Products">AOD Products</a>
<span class="separator">|</span>
<a href="aodecat.htm" title="AODE and 4R70W Performance Products">AODE/ 4R70W Products</a>
<span class="separator">|</span>
<a href="e4odcat.htm" title="E4OD and 4R100E Performance Products">E4OD/ 4R100E Products</a>
<span class="separator">|</span>
<a href="electronicscat.htm" title="Our Innovative Electronic Products">Electronic Products</a>
<span class="separator">|</span>
<a href="othercat.htm" title="Other Transmission Related Products">Other Products</a>
</div>

gregmatic
10-31-2003, 02:11 PM
Thanks, I greatly appreciate it. You code faster than I type :D

gregmatic
10-31-2003, 03:17 PM
I've read about id versus classes a couple of places, but I don't quite understand what the advantages of each are. Can you use a class anywhere you can use an id?

Is the id easier or better in some cases?

spufi
10-31-2003, 03:37 PM
Class is used to define something that will be used more than once, and id is used to define something that will be used only once.

<div class="blueBox">

<div id="menu">

gregmatic
10-31-2003, 03:44 PM
If you put an id in an external style sheet I'm assuming it can be used once per page?

spufi
10-31-2003, 04:05 PM
An id should be defined only once per page regardless if the CSS is defined externally, or not. Using the id attribute is like giving something a name, and if you name two different things the same thing, then how do you know which one of the two gets something applied to it? Just think of using id to define what is going to be your header. Do you really define two things as being headers? Not really.

gregmatic
11-03-2003, 07:43 AM
How can I get the same background colors I had?

DaveSW
11-03-2003, 09:46 AM
#menu {position:absolute; top:1em; background-color: #cccccc;}

I think that was the color you are referring to lol. Change it if it's not.

spufi
11-03-2003, 10:00 AM
I would get rid of the word products in your menu links since it is already in the menu header.

CSS:

#menu2 { width:12%; background-color:#006; color:#FFF; padding:0px 15px 15px 15px; text-align:center; }
#menu2 h4 { margin-bottom:5px; }
li { list-style-type:none; padding:5px; }
ul { margin:0; padding:0; background-color:#CCC; border:3px solid #FFF; }

HTML:

<div id="menu2">
<h4>Our Products</h4>
<ul>
<li><a href="aodcat.htm" title="AOD Performance Products">AOD Products</a></li>
<li><a href="aodecat.htm" title="AODE and 4R70W Performance Products">AODE/ 4R70W Products</a></li>
<li><a href="e4odcat.htm" title="E4OD and 4R100E Performance Products">E4OD/ 4R100E Products</a></li>
<li><a href="electronicscat.htm" title="Our Innovative Electronic Products">Electronic Products</a></li>
<li><a href="othercat.htm" title="Other Transmission Related Products">Other Products</a></li>
</ul>
</div>

TomDenver
11-03-2003, 01:56 PM
ID is used in JavaScript (as well as CSS), which I believe is why you don't want 2 things on one page using the same ID, because it would break any JavaScript that references that ID.

pyro
11-03-2003, 02:33 PM
Actually, the reason is because an ID is a document unique identifier. http://www.w3.org/TR/REC-html40/struct/global.html#adef-id