473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How can I set the width of List elements

Hi,

I have an unordered list that displays for elements horizontally. I'd
like each to take up 25% of the browser window but my code does not
work. Can someone help? The code is shown below.

HTML Code
-----------------
<div id="footer">
<ul>
<li id="our_company">Our Company</li>
<li id="vessel_schedules">Vessel Schedules</li>
<li id="make_a_booking">Make a Booking</li>
<li id="rate_request">Rate Request</li>
</ul>
</div>

CSS Code
---------------
#footer {
margin: 0;
padding: 0;
clear: both;
}

#footer ul {
margin: 0;
padding: 5px;
list-style: none;
background-image: url(../images/menurest.jpg);
background-repeat: repeat;
}

#footer li {
display: inline;
color: white;
font-weight: bold;
}

#our_company {
width: 25%;
}

#vessel_schedules
width: 25%;
}

#make_a_booking
width: 25%;
}

#rate_request
width: auto;
}
Jun 27 '08 #1
1 2145
On 26 mei, 19:48, donpro <donpro-2...@rogers.comwrote:
Hi,

I have an unordered list that displays for elements horizontally. I'd
like each to take up 25% of the browser window but my code does not
work. Can someone help? The code is shown below.

HTML Code
-----------------
<div id="footer">
<ul>
<li id="our_company">Our Company</li>
<li id="vessel_schedules">Vessel Schedules</li>
<li id="make_a_booking">Make a Booking</li>
<li id="rate_request">Rate Request</li>
</ul>
</div>

CSS Code
---------------
#footer {
margin: 0;
padding: 0;
clear: both;

}

#footer ul {
margin: 0;
padding: 5px;
list-style: none;
background-image: url(../images/menurest.jpg);
background-repeat: repeat;

}

#footer li {
display: inline;
color: white;
font-weight: bold;

}

#our_company {
width: 25%;

}

#vessel_schedules
width: 25%;

}

#make_a_booking
width: 25%;

}

#rate_request
width: auto;

}
http://www.alistapart.com/articles/multicolumnlists
and this is the part i think youll be interested in...

The technique is simple: give the list items a fixed width and float
them left.

The list items wrap horizontally like words in a paragraph. Generally
speaking, when a series of blocks are floated left or right, they
align horizontally and wrap around when they reach the maximum width
of their container. If just three items can fit on one row, as in this
example, the list naturally wraps into rows of three columns.

The XHTML markup is a straightforward list with no special classes or
other attributes required. To prevent subsequent page elements from
being affected by the float I’ve contained the list in a <divand
cleared the float with a (non-semantic) <br />:

<div class="wrapper">
<ol
><li><a href="#">Aloe</a></li
<li><a href="#">Bergamot</a></li
...
><li><a href="#">Oregano</a></li
<li><a href="#">Pennyroyal</a></li
</ol>
<br />
</div><!-- .wrapper -->

The essential CSS is brief:

/* allow room for 3 columns */
ol
{
width: 30em;
}

/* float & allow room for the widest item */
ol li
{
float: left;
width: 10em;
}

/* stop the float */
br
{
clear: left;
}

/* separate the list from subsequent markup */
div.wrapper
{
margin-bottom: 1em;
}
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: puzzled | last post by:
Okay, so my subject sounds a bit crass. As much as I'd like to totally embrace css and avoid "deprecated" usage, sometimes the deprecated stuff is so much easier and more effective. Plus, it at...
4
by: Matt | last post by:
Hi, Got an unordered list with 100% width, with 5 list items of 20% width styled to fill the width of the container element. Renders fine in Mozilla, but when you change the size of the window...
2
by: Marek Mänd | last post by:
How do i set/specify minimum width (min-width) and minimum height (min-height) to the table cell (td/th)? No, I dont want explicit width setting. No, I dont want spacer GIF's. Can I do it...
3
by: Robert Mark Bram | last post by:
Hi All! Has anyone seen an example of the following javascript powered control: - a dropdown select menu - the width of the control is set. Assume by "control" I mean the visible part of the...
3
by: i_dvlp | last post by:
I'm trying to replicate a fancy drop-down control (MS-egads!) with form <select><option> It doesn't look like you can specity width as an attribute or define width with CSS. It looks like my...
16
by: FuzzyLogik | last post by:
By width, I don't mean weight. I have a row of <li>'s, with a bottom-border. I want the bottom-border to only go 90% of the <li> (centered) Is there any way to do this? I have it in this...
1
by: skijor | last post by:
I have created a vanilla drop-down menu and want the width of the sub-menu elements to be as wide as the widest element in the drop-down. This would make each flush on the right border. It works...
0
by: Markus | last post by:
Hello I encountered a very annoying behaviour of IE7 with max-width on elements inside a table cell - it seems to be related to the max-width bugs on list items and floated elements (discussed...
5
by: Summercool | last post by:
wow... i didn't know that, for <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:// www.w3.org/TR/html4/loose.dtd"> <span style="width: 100px; background:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.