简体   繁体   中英

How can I distribute navigation li tags evenly across a set width

I'm having trouble spacing out my navigation bar evenly across the 4 column grid. I want it so each li is more like a button block and they are equal in widths so that the hover-on border top are all symmetrical.

Here's the website: http://designobvio.us/portfolio/index.html

HTML:

    <div class="nav-wrapper grid_4">
       <nav>
          <ul>
            <li>
              <a href="/" id="">portfolio</a>
            </li>
               <li>
              <a href="/" id="">resume</a>
            </li>
               <li>
              <a href="/" id="">blog</a>
            </li>
            <li>
              <a href="." id="about-btn">about me</a>
            </li>
          </ul>
      </nav>
    </div><!--end of nav-wrapper-->

Heres my CSS:

.nav_-wrapper nav ul{}
.nav-wrapper nav ul li  
  {
float:right;
display: -moz-inline-stack;
display: inline-block;
vertical-align: top;
margin: 5px;
zoom: 1;
margin-top:35px;
padding:
    *display: inline;
   }
.nav-wrapper nav ul li a {
list-style:none;

text-decoration:none;
font-size:13.5px;

   }

Nothing a position: relative; can't fix. Check this: http://jsfiddle.net/X8G2H/

Your HTML can stay the same, but your CSS transforms into this:

.nav-wrapper nav ul li  {
    float:right;
    display: block;
    vertical-align: top;
    margin: 5px;
    zoom: 1;
}

.nav-wrapper nav ul li a {
    list-style:none;
    text-decoration:none;
    font-size:13.5px;
    display:  block;
    padding-top: 34px;
    width: 59px;
    text-align: center;
}

.nav-wrapper nav ul li a:hover {
    border-top: 5px solid #E58;
    position: relative;
    top: -5px;
}

I did change some properties (padding and margin) but this should work well in any browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM