Forum Moderators: not2easy

Message Too Old, No Replies

Horizontal CSS Menu

can I have the colmns automatically stretch?

         

gryphadmin

8:45 pm on Jun 24, 2005 (gmt 0)

10+ Year Member



I'm trying to get away from a tabular format on my company's site, but I've hit a snag in the form of not being able to stretch my horizontal menu. The page is 720px wide and I want to use the entire width for the menu, but I want to be able to use it for different menus on different pages. Is there a way I can make the ul take up the entire available width and not fix the width of my buttons?


<html>
<head>
<title>Horizontal Menu testing</title>
<style type="text/css">
.menu4 {
margin: 0px;
padding: 0px;
}
.menu4 ul {
margin: 0px;
padding: 0px;
list-style-type: none;
}
.menu4 li {
margin: 0px;
padding: 0px;
float: left;
font-family: arial, verdana, helvetica;
text-decoration: none;
text-align: center;
}
.menu4 {
padding: 0px;
background: #FFFFFF none;
}
.menu4 li {
margin-right: 0px;
text-align: center;
}
.menu4 a {
display: block;
color: #FFFFFF;
text-decoration: none;
background-color:#D2A929;
border-top:1px solid #ffcc66;
border-bottom:1px solid #996600;
border-right:1px solid #996600;
border-left:1px solid #ffcc66;
}
.menu4 a:hover {
display: block;
color: #FFFFFF;
text-decoration: none;
background-color:#999933;
border-bottom:1px solid #ffcc66;
border-top:1px solid #996600;
border-left:1px solid #996600;
border-right:1px solid #ffcc66;
}
#pagecontainer{
background-color: d2a929;
margin:0px;
padding: 0px;
width: 720px;
}
#maincontent {
border-width : 0px;
padding: 0px 0px 0px 0px;
margin: 0px;
font-weight: bold;
}
</style>
</head>
<body>
<div id="pagecontainer">
<div id="maincontent">
<div class="menu4">
<ul>
<li><a href="../Solar/solar.html">link 1</a></li>
<li><a href="../Solar/solar.html">longer Link 2</a></li>
<li><a href="../Solar/solar.html">super long link 3</a></li>
<li><a href="../Solar/solar.html">link 4</a></li>
</ul>
<br clear="left">
</div>
</div>
</div>
</body>
</html>

createErrorMsg

10:29 am on Jun 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



gryphadmin, welcoome to WebmasterWorld!

Is there a way I can make the ul take up the entire available width and not fix the width of my buttons?

First, try adding the following styles to the .menu4 ul rule declaration. This causes the menu to visually fill the available space in .menu4.

float:left;
width:100%;
background-color:#D2A929;
border-top:1px solid #ffcc66;
border-bottom:1px solid #996600;
border-right:1px solid #996600;
border-left:1px solid #ffcc66;

However, it does not cause the buttons to stretch so that the full width of the menu is filled up by buttons. (This code keeps the buttons exactly how you have them, but extends the beveled bar beyond the width of the buttons.)

If you need the buttons themselves to expand, set the width on the .menu4 li rule declaration to 25% (four buttons divided into 100% is 25%; if you have five buttons, you'll want 20%; etc.).

cEM

gryphadmin

3:47 pm on Jun 27, 2005 (gmt 0)

10+ Year Member



thanks for the info cEM, I suppose I'll have to live without buttons that can stretch on the fly. since the text of each button is a different length, I'll just have to declare each width individually.