i,e,
<div id="container">
<div id="1" width="33.3%">
<div id="2" width="33.3%">
<div id="3" width="33.3%">
</div>
Main Topics
Browse All TopicsI have a horizontal css based menu that currently floats left and the spacing between items is contolled by padding on the right of each li.
My client wants these menu items to evenly spread across the menu_bar div so that they are centered, and equally distributed.
Can anyone help with that?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
well not necessarily if you do this in javascript by counting the menu items (in case someone adds them and then adding the width attribute...if someone adds a menu, sooner or later that's going to break the page anyway, so I would figure using percentages would be the best way to go about it...but as glcummins said...maybe you're right and there is a better way...
Please post some code and just-in-case do you know javascript?
Sure! Here you go!
CSS:
.menubar { background-color: #342016; width: 780px; height: 20px; color: #fff; font: 8pt Verdana, Tahoma, Helvetica, sans-serif; margin: 0; padding: 0; }
#navmenu { height: 20px; position: relative; width: 780px; z-index: 10000; background-color: transparent; background-repeat: no-repeat; background-attachment: scroll; background-position: left top; text-align: center; margin: 0; padding: 0; }
#navmenu ul { padding: 0; margin: 0; color: #fff; text-decoration: none; padding: 3px 0 0 50px; }
#navmenu li { display: inline; white-space: nowrap; }
#navmenu li a { color: #fff; font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-decoration: none; padding-right: 60px; }
#navmenu li a:hover { color: #fff; font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-decoration: underline; }
++++++++++++++++++++++++++
FROM THE INDEX.PHP:
<div class="menubar">
<div id="navmenu">
<script type="text/javascript" src="<?php echo $this->baseurl;?>/templates/
<jdoc:include type="modules" name="menu" style="none" />
</div>
++++++++++++++++++++++++++
from the rendered page:
<div class="menubar">
<div id="navmenu">
<script type="text/javascript" src="/joomla/templates/js_
<ul class="menu">
<li id="current" class="active"><a href="http://xxx.com/jooml
<li class="haschild"><a href="/joomla/index.php/ab
<li class="haschild"><a href="/joomla/index.php/se
<li class="haschild"><a href="/joomla/index.php/kn
</ul>
</div>
</div>
Yes, they are evenly spaced and centered because I hand coded the padding that the ul and li elements use. But, if the client adds another menu item from the joomla admin panel - then the menu will fall apart.
thus I was looking for a more dynamic way to control the spacing. ..perhaps it isn't (yet) possible.
I see. Okay, let me look a little closer.
Since this code is generated by Joomla, it may be difficult to get something to work properly. Everything will probably need to be done in CSS unless you are comfortable changing PHP code in Joomla itself to alter the output.
I will see what I can come up with using only CSS and get back to you.
As i've stated, you can do this with javascript, determine how many div's will be needed and then divide by that number and use the percentage to set all to equal...Refer to my earlier post. This will definitely work.
Only other way is to write everything in PHP, where you create divs dynamically, keep a count of them and again, base width off how many divs are needed.
Business Accounts
Answer for Membership
by: silemonePosted on 2008-09-05 at 12:02:10ID: 22402492
bet way would to divide the container and then make width = to the number of 100/number of pieces...