Solved

css horizontal menu - equally spacing menu items and right edge alignment

Posted on 2009-07-15
8
788 Views
Last Modified: 2012-05-07
I am using a list for a menu, and I need  all <li> items equally spaced withing given container. Plus the last item of menu (contact) should be aligned against the right edge of container.  So the last letter of the last word is actually touching the right edge.
I tried to do float and use padding, but it is obviously not what i need.

Thank you,

Stacy
0
Comment
Question by:ctasik
  • 4
  • 3
8 Comments
 
LVL 14

Expert Comment

by:flob9
ID: 24863459
Please, provide a sample of the html page.
0
 

Author Comment

by:ctasik
ID: 24863524
<div id="header">
    <h1>portfolio</h1>
             
    <ul>
   
    <li><a href="index.htm" class="current">HOME</a></li>
    <li><a href="curr_act.htm">CURRENT ACTIVITIES</a></li>
    <li><a href="gallery.htm">GALLERY</a></li>
    <li><a href="theatre.htm">THEATRE</a></li>
    <li><a href="teaching.htm">TEACHING</a></li>
    <li><a href="contact.htm" class="last">CONTACT</a></li>
         
    </ul>
  </div> <!--header-->


css
------------------------------------------
#header ul {
      margin: 0;
      padding: 0;
      list-style: none;
      position: absolute;
      bottom: 0px;
      width:700px;
      font-size: 1.1em;
      right: 0px;
            }
      
#header li {
      float: left;
      }
      
#header li a:link, #header li a:visited {
      display:block;
      background: #FFFFFF;
      padding: .2em 0em;
      text-decoration: none;
      color:#000000;
      /*margin-right: .5em*/
      margin-left:20px;
      font-family: Arial, Helvetica, sans-serif;
      }            

      
#header li a:hover, #header li a:active {
      color:#666666;
      background:#FFFFFF;
            }
      
#header li a.current, #header li a.current:hover, #header li a.current:active {
      color:#666666;
      background: #FFFFFF;
      cursor: default;
   }
   
0
 
LVL 14

Accepted Solution

by:
flob9 earned 125 total points
ID: 24863638

#header ul {
      margin: 0;
      padding: 0;
      list-style: none;
      position: absolute;
      bottom: 0px;
     /* width:700px;*/
      float:right; /* added */
      font-size: 1.1em;
      right: 0px;
}

Open in new window

0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:ctasik
ID: 24863679
* width:700px;*/
      float:right; /* added */
I tried to float it right, but then Firefox puts all menu items <li> backwards... and Safari doesn't.

0
 
LVL 14

Expert Comment

by:flob9
ID: 24863787
It is working for me with safari 4 and firefox 3.5.

"Firefox puts all menu items <li> backwards" <<< what do you mean ?
0
 
LVL 3

Expert Comment

by:russianryebread
ID: 24863848
If the elements are backwards, float them the other way...  You can re-arrange the order of a floated list by the direction you float the <li> elements inside the <ul>
0
 

Author Comment

by:ctasik
ID: 24865457
Actually it didn't work:)
The distance between menu item is control by margin-left: 20 px
ul float right & il float left  still leaves a distance to the right, because the space occupied by font of <li> items + space in between them still doesn't equal 100%.

I need somehow to tell them to occupy all the space inside ul edge to edge, 100 %. I tryed using percentage value, but each word is different length. So equal percentage method doesn't work.
0
 

Author Comment

by:ctasik
ID: 24865481
so my question now is

How to make <li> items

<li><a href="index.htm" class="current">HOME</a></li>
    <li><a href="curr_act.htm">CURRENT ACTIVITIES</a></li>
    <li><a href="gallery.htm">GALLERY</a></li>
    <li><a href="theatre.htm">THEATRE</a></li>
    <li><a href="teaching.htm">TEACHING</a></li>
    <li><a href="contact.htm" class="last">CONTACT</a></li>

spread inside lu edge to edge with equal spaces between them.

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to Left-Align Navigation bar? 4 26
Looking for magnifying glass wingding font 3 17
Width of Page is Affecting Side Menu 6 25
Hide cell in a table 2 10
This article discusses four methods for overlaying images in a container on a web page
Find out what you should include to make the best professional email signature for your organization.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question