Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

04 May 2007

Really easy CSS Menu


When you start creating your website your first thought when it comes to the menu is to use a table.

Well, you can create a table for the menu, there's nothing wrong with that, but using tables isn't always the best choise.

So, this is an example where I'm using an unordered list (ul), to create my menu:


 <div id="MenuListContainer">
<ul>
<li><a href="#">Home Page</a></li>
<li>|</li>
<li><a href="#">Resources</a></li>
<li>|</li>
<li><a href="#">Webmasters</a></li>
<li>|</li>
<li><a href="#">Terms</a></li>
<li>|</li>
<li><a href="#">About</a></li>
<li>|</li>
<li><a href="#">Contact</a></li>
</ul>
</div>



As you can see, using the unordered list become more easily to deploy and configure your menu.


The CSS styles to use are the following:

<style type="text/css" media="screen">
div#MenuListContainer {
width: auto;
height: auto;
text-align: left;
vertical-align: top;
margin: 0px 0px 0px 0px; /* T R B L */
padding: 0px 0px 0px 0px; /* T R B L */
}

div#MenuListContainer ul {
display: inline;
list-style-type: none;
margin: 0px 0px 0px 0px; /* T R B L */
padding: 5px 5px 5px 5px; /* T R B L */
background-color: #eeeeee;
}

ul li {
display: inline;
margin: 0px 0px 0px 0px; /* T R B L */
padding: 5px 5px 5px 5px; /* T R B L */
font-family: Georgia, Serif;
font-size: 10pt;
color: #000000;
text-align: center;
line-height: 1.6em;
}

li a:link {
color: #000000;
text-decoration: none;
}
li a:visited {
color: #696969;
text-decoration: none;
}

li a:hover {
color: #8b0000;
text-decoration: none;
}
</style>


And this is how it looks in IE7:


01 May 2007

Transforming a Div into a Table


I've seen a lot of people debating about tables and divs. Some of them are saying to use tables and not divs and vice-versa.
Now, I'm showing you an example of how you can transform a div into a table.

Note that this example doesn't work in IE7 (IE7 is messing it badly), but it works in Firefox just great.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Transforming a Div into a Table</title>

<style type="text/css" media="screen">

div.table { display: table;}
div.row { display: table-row; }
div.cell { display: table-cell; width: 100px; }
div.caption { display: table-caption; caption-side: top; text-align: right; }

div.c1 { text-align: right; background-color: #eeeeee; }
div.c2 { text-align: center; }

div.TableHeaderGroup { display: table-header-group; color: Red; }
div.TableRowGroup { display: table-row-group; font-style: italic; }
div.TableFooterGroup { display: table-footer-group; color: Blue; }

</style>
</head>

<body>

<div class="table">

<div class="caption">Table caption</div>

<div class="TableHeaderGroup">
<div class="row">
<div class="cell c1">Cell 1</div>
<div class="cell c2">Cell 2</div>
</div>
</div>

<div class="TableRowGroup ">
<div class="row">
<div class="cell c1">Cell 1</div>
<div class="cell c2">Cell 2</div>
</div>
</div>

<div class="TableFooterGroup">
<div class="row">
<div class="cell c1">Cell 1</div>
<div class="cell c2">Cell 2</div>
</div>
</div>

</div>


</body>
</html>