Forum Moderators: not2easy
<!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>nms test</title>
<style type"text/css">
#wrapper {
width:100%;
}
#menu {
width:100%;
background-color:#664246;
border:1px solid green;
}
#menu ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#menu ul li {
display:inline;
}
#menu ul li a {
font-family: Bangle, "Benguiat Bk BT", Palatino, "Palatino Linotype", Georgia, Times, "Times New Roman";
color: #FFFFFF;
text-decoration: none;
text-align:center;
letter-spacing:0.1em;
padding: 0px 10px;
}
#menu ul li a:hover {
color: #fff;
background-color:#0b75b2;
}
</style>
</head>
<body>
<table id="wrapper" cellpadding="0" cellspacing="0">
<tr>
<td id="search"></td>
</tr>
<tr>
<td id="menu">
<ul>
<li><a id="btn1" href="#">Home</a></li>
<li><a id="btn2" href="#">Links</a></li>
<li><a id="btn3" href="#">About Us</a></li>
<li><a id="btn4" href="#">Pilgrimage</a></li>
<li><a id="btn5" href="#">Gift Shop</a></li>
<li><a id="btn6" href="#">How to Help</a></li>
<li><a id="btn7" href="#">Contact</a></li>
</ul>
</td>
</tr>
<tr>
<td id="rule"></td>
</tr>
<tr id="bottom">
<td></td>
</tr>
</table>
</body>
</html>
If it's not possible, can i horizontally center the list menu in the browser window?
#menu ul {
list-style-type: none;
margin: 0;
padding: 0;
/* add the two rules below */
text-align: center; /* center the li elements */
white-space: nowrap; /* acts like min-width, the li elements won't wrap */
}
#menu ul li { /* change the display type */
display:inline-block; /* see IE conditional */
}
<!--[if lt IE 8]>
<style type="text/css" media="screen">
#menu ul li {
display: inline; /*IE 6 & 7 to force display:inline-block to work on a block level element */
}
</style>
<![endif]-->
#menu ul {
list-style-type: none;
margin:0 25%;
padding: 0;
}
#menu ul li {
display:inline;
padding: 0px 1%;
}
#menu ul {
list-style-type: none;
margin:0;
padding: 0;
text-align: center;
white-space: nowrap;
}
#menu ul li {
display:inline;
padding: 0px 1%;
}
Btw, it's a shame that the extra code has to be employed just to cater to browser differences. Can't they all just get a long?
<!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>nms test</title>
<style type"text/css">
#wrapper {
width:100%;
}
#menu {
border:1px solid white;
}
#menu ul {
margin:0;
padding:0;
text-align:center;
white-space:nowrap;
list-style-type:none;
height:27px;
background: #664246 url(../images/bg-nav.gif) repeat-x 0 0;
/*
*/
}
#menu ul li {
display:inline-block;
padding:0px 1%;
}
#menu ul li a {
font-family: Bangle, "Benguiat Bk BT", Palatino, "Palatino Linotype", Georgia, Times, "Times New Roman";
color: #FFFFFF;
text-decoration: none;
text-align:center;
vertical-align:middle;
letter-spacing:0.1em;
}
#menu ul li a:hover {
color: white;
background-color:#0b75b2;
}
</style>
</head>
<body>
<table id="wrapper" cellpadding="0" cellspacing="0">
<tr>
<td id="search"></td>
</tr>
<tr>
<td id="menu">
<ul>
<li><a id="btn1" href="#">Home</a></li>
<li><a id="btn2" href="#">Links</a></li>
<li><a id="btn3" href="#">About Us</a></li>
<li><a id="btn4" href="#">Pilgrimage</a></li>
<li><a id="btn5" href="#">Gift Shop</a></li>
<li><a id="btn6" href="#">How to Help</a></li>
<li><a id="btn7" href="#">Contact</a></li>
</ul>
</td>
</tr>
<tr>
<td id="rule"></td>
</tr>
<tr id="bottom">
<td></td>
</tr>
</table>
</body>
</html>
<style type="text/css" media="screen">
#wrapper {width:100%;}
#menu {border: 1px solid #fff;}
#menu ul {
list-style:none;
margin:0;
padding:0;
text-align:center;
white-space:nowrap;
height: 27px;
background: #664246 url(../images/bg-nav.gif) repeat-x 0 0;
}
#menu ul li {
display:inline-block;
padding: 0 10px; /* IE only like this in px put you can put onto the <a> instead see below */
}
#menu ul li a {
font-family: Bangle, "Benguiat Bk BT", Palatino, "Palatino Linotype", Georgia, Times, "Times New Roman";
color: #FFFFFF;
text-decoration: none;
/*text-align:center;*/
/* vertical-align: middle;*/
line-height: 27px; /*try this for vertical alignment it makes links take same height as menu items as well as centering vertically*/
letter-spacing: 0.1em;
padding: 0 10px; /* added here for IE but it seems like FF doesn't like it unless it's px either! */
float: left; /* optional, but it makes the links fill the same height as menu */
}
#menu ul li a:hover {
color: white;
background-color:#0b75b2;
}
</style>
<!--[if lt IE 8]>
<style type="text/css" media="screen">
#menu ul li {
display:inline;
}
</style>
<![endif]-->