Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-01-2009, 09:02 PM   PM User | #1
theflyingminstr
Regular Coder

 
Join Date: Jul 2007
Posts: 191
Thanks: 0
Thanked 0 Times in 0 Posts
theflyingminstr is an unknown quantity at this point
Header Buttons Question

Hi in the code below I have 8 menu links. What would be the best way to have them all evenly spread across the entire width without the space to the left?

Thanks so much

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<style type="text/css">

BODY{ color: White; font-family: Arial, Helvetica, sans-serif; font-size: 10pt; margin: 0; padding: 0; }
a{ color: #FFFFFF; text-decoration: none; }

#HEADER{	width:760px; margin-left:auto; margin-right:auto;}
#HEADER ul{ margin: 0; padding-left: 0; height: 44px; line-height: 44px; display: block; list-style: none; background-color: #1F2C56; }
#HEADER li{ display: inline; background-color: #395A8D;  float: right;  }
#HEADER li a{ height: 44px; line-height: 44px; display: block; padding-left: 25px; padding-right: 30px; border-left: 1px solid Black;  float: left; }
#HEADER li a:hover{ background-color: #1F2C56; text-decoration: none;}
#HEADER .Visual{ height:263px; background-repeat: no-repeat;  background-color: #1F2C56;  border-top: 3px solid Black;   }

</style>

</head>

<body>

<div id="HEADER">
	<h1>Welcome</h1>
	<ul>
		<li><a href="link8.html">Link 8</a></li>
		<li><a href="link7.html">Link 7</a></li>
		<li><a href="link6.html">Link 6</a></li>
		<li><a href="link5.html">Link 5</a></li>
		<li><a href="link4.html">Link 4</a></li>
		<li><a href="link3.html">Link 3</a></li>
		<li><a href="link2.html">Link 2</a></li>
		<li><a href="link1.html">Link 1</a></li>
	</ul>
	<div class="Visual"> </div>
</div>

</body>

</html>
theflyingminstr is offline   Reply With Quote
Old 04-01-2009, 09:19 PM   PM User | #2
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello theflyingminstr,
Try this for starters, the key changes are highlighted in red -
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<style type="text/css">
body{
	color: #fff;
	font: 10pt Arial, Helvetica, sans-serif;
}
* {
	margin: 0; 
	padding: 0; 
}
#header{	
	width:760px; 
	margin: 0 auto;
}
#header ul{ 
	height: 44px; 
	line-height: 44px; 
	display: block; 
	list-style: none; 
	background: #1F2C56; 
}
#header li{ 
	display: inline; 
	background: #395A8D;  
	float: right;  
}
#header li a{ 
	height: 44px; 
	line-height: 44px; 
	display: block; 
	width: 94px;
	text-align: center;	
border-left: 1px solid Black;  
	float: left; 
}
#header li a:hover{ 
	background: #1F2C56; 
	text-decoration: none;
}
#header .visual{ 
	height:263px; 
	background: #1F2C56;  
	border-top: 3px solid Black;   
}
a{ color: #FFFFFF; text-decoration: none; }
</style>
</head>
<body>
<div id="header">
	<h1>Welcome</h1>
        <ul>
            <li><a href="link8.html">Link 8</a></li>
            <li><a href="link7.html">Link 7</a></li>
            <li><a href="link6.html">Link 6</a></li>
            <li><a href="link5.html">Link 5</a></li>
            <li><a href="link4.html">Link 4</a></li>
            <li><a href="link3.html">Link 3</a></li>
            <li><a href="link2.html">Link 2</a></li>
            <li><a href="link1.html">Link 1</a></li>
        </ul>
	<div class="visual"> </div>
</div>
</body>
</html>
Some other centered menu examples here:
one
two
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

Last edited by Excavator; 04-01-2009 at 09:37 PM..
Excavator is offline   Reply With Quote
Old 04-01-2009, 09:26 PM   PM User | #3
theflyingminstr
Regular Coder

 
Join Date: Jul 2007
Posts: 191
Thanks: 0
Thanked 0 Times in 0 Posts
theflyingminstr is an unknown quantity at this point
Hey that's awesome, thanks so much!

Edit:

One thing I noticed is that if needs to wrap text to the next line it pushes the text very far down into the visual area.

Ex:

<div id="header">
<h1>Welcome</h1>
<ul>
<li><a href="link8.html">Link 8 Link 8 Link 8</a></li>
<li><a href="link7.html">Link 7</a></li>
<li><a href="link6.html">Link 6</a></li>
<li><a href="link5.html">Link 5</a></li>
<li><a href="link4.html">Link 4</a></li>
<li><a href="link3.html">Link 3</a></li>
<li><a href="link2.html">Link 2</a></li>
<li><a href="link1.html">Link 1</a></li>
</ul>
<div class="visual"> </div>

Last edited by theflyingminstr; 04-01-2009 at 09:33 PM..
theflyingminstr is offline   Reply With Quote
Old 04-01-2009, 09:37 PM   PM User | #4
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Cleaned up a little more -
Code:
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
	font: 14px "Comic Sans MS";
	text-align: center;
	background: #FC6;
}
* {
	margin: 0;
	padding: 0;
	outline: none;
	border: none;
}
#container {
	width: 760px;
	margin: 30px auto;
	background: #999;
	overflow: auto;
}
h1 {
	height: 44px;
	line-height: 44px;
}
ul#menu { 
	height: 44px; 
	margin: 0 0 300px;
	line-height: 44px;
	list-style: none; 
	border-bottom: 3px solid #000;
}
#menu li{  
	display:inline;
}
#menu li a{
	width: 94px;
	height: 44px;
	float: left;
	line-height: 44px;
	display: block;
	text-align: center;
	text-decoration: none;
	color: #fff;
	background: #395A8D;
	border-left: 1px solid Black;
}
#menu li a:hover{background: #1F2C56;}
</style>
</head>
<body>
<div id="container">
    <h1>Header text goes here</h1>
        <ul id="menu">
            <li><a style="border:0;" href="link1.html">Link 1</a></li>
            <li><a href="link2.html">Link 2</a></li>
            <li><a href="link3.html">Link 3</a></li>
            <li><a href="link4.html">Link 4</a></li>
            <li><a href="link5.html">Link 5</a></li>
            <li><a href="link6.html">Link 6</a></li>
            <li><a href="link7.html">Link 7</a></li>
            <li><a href="link8.html">Link 8</a></li>
        </ul>
<!--end container--></div>
</body>
</html>
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

Last edited by Excavator; 04-01-2009 at 09:46 PM..
Excavator is offline   Reply With Quote
Old 04-01-2009, 09:41 PM   PM User | #5
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Quote:
Originally Posted by theflyingminstr View Post
Hey that's awesome, thanks so much!

Edit:

One thing I noticed is that if needs to wrap text to the next line it pushes the text very far down into the visual area.

Ex:
Yeah, it's never good when you full width menu needs to wrap. Specify px sized text and make sure it all fits.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 04-01-2009, 09:45 PM   PM User | #6
theflyingminstr
Regular Coder

 
Join Date: Jul 2007
Posts: 191
Thanks: 0
Thanked 0 Times in 0 Posts
theflyingminstr is an unknown quantity at this point
Gotcha thanks!!
theflyingminstr is offline   Reply With Quote
Old 04-01-2009, 10:27 PM   PM User | #7
theflyingminstr
Regular Coder

 
Join Date: Jul 2007
Posts: 191
Thanks: 0
Thanked 0 Times in 0 Posts
theflyingminstr is an unknown quantity at this point
Quote:
Originally Posted by Excavator View Post
Cleaned up a little more -
Code:
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
	font: 14px "Comic Sans MS";
	text-align: center;
	background: #FC6;
}
* {
	margin: 0;
	padding: 0;
	outline: none;
	border: none;
}
#container {
	width: 760px;
	margin: 30px auto;
	background: #999;
	overflow: auto;
}
h1 {
	height: 44px;
	line-height: 44px;
}
ul#menu { 
	height: 44px; 
	margin: 0 0 300px;
	line-height: 44px;
	list-style: none; 
	border-bottom: 3px solid #000;
}
#menu li{  
	display:inline;
}
#menu li a{
	width: 94px;
	height: 44px;
	float: left;
	line-height: 44px;
	display: block;
	text-align: center;
	text-decoration: none;
	color: #fff;
	background: #395A8D;
	border-left: 1px solid Black;
}
#menu li a:hover{background: #1F2C56;}
</style>
</head>
<body>
<div id="container">
    <h1>Header text goes here</h1>
        <ul id="menu">
            <li><a style="border:0;" href="link1.html">Link 1</a></li>
            <li><a href="link2.html">Link 2</a></li>
            <li><a href="link3.html">Link 3</a></li>
            <li><a href="link4.html">Link 4</a></li>
            <li><a href="link5.html">Link 5</a></li>
            <li><a href="link6.html">Link 6</a></li>
            <li><a href="link7.html">Link 7</a></li>
            <li><a href="link8.html">Link 8</a></li>
        </ul>
<!--end container--></div>
</body>
</html>
Thank you Excavator
theflyingminstr is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:56 PM.


Advertisement
Log in to turn off these ads.