What is the best way to evenly distribute navigation li tags within a specific width?

I'm struggling to evenly space out my navigation bar across the 4 column grid. I want each list item to function more like a button block and have equal widths so that the hover-on border tops are all symmetrical.

Check out the website:

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-->

Here is 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;
}

Answer №1

Just a touch of position: relative; is all you need. Take a look at this example: http://jsfiddle.net/X8G2H/

Your HTML code can remain unchanged, but your CSS code should be updated to the following:

.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 made some slight adjustments (padding and margin), but this solution works effectively across various browsers.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Configuring ng-options with personalized indices

I am a beginner learning AngularJS and I'm working on setting up ng-options with unique indexes. In my tables, I want to use the Primary Key as the index. For example, if the Primary Keys are 1, 3, 4, 5, I only want those indexes in my select. First ...

What are the steps to adjust the width of a website from the standard size to a widescreen

Is it possible to create a "floating" screen adjustment on websites? I know you can set the standard size of pixels, but how do sites adjust for different screen sizes like wider laptop screens? Does it automatically detect the reader's screen size an ...

Variations in browser rendering of SVGs as CSS list-style-images

After creating a simple SVG of a red circle to serve as the list-style-image for my website, I discovered the concept in this Stack Overflow response: The solution worked seamlessly across all browsers except Internet Explorer. In IE, the SVG image render ...

What happens when dynamically loaded static resources are loaded?

Currently, I am dynamically injecting HTML into a page using JQuery AJAX. The injected HTML contains script and link tags for JS and CSS files respectively. The issue I am facing is that my initPage() function runs before the script containing its definiti ...

Angular routing does not properly update to the child's path

I've organized my project's file structure as follows: app/ (contains all automatically built files) app-routing.module.ts components/ layout/ top/ side/ banner/ pages/ ...

Show all entries belonging to a specific ID on individual rows for each ID using PHP

I have a table generated from inner joins that displays different articles associated with outfit IDs. id_outfit | name | article ---------------------------------------- 56 | one | shoe.png 56 | one | dress.png 56 | one ...

Adjust the color of text using the <text-shadow> technique

The default 'text-shadow' for white text in a <div> is defined as follows: When the text color is changed to #627CA9 by clicking on it, I want the 'text-shadow' to be updated to match the new color. text-shadow: 0 0 1px #FFFFFF, ...

"Employing a Backend Task Runner for a jQuery-Based Mobile Application

Currently, I am utilizing jQuery Mobile in conjunction with HTML5 to provide support for Android and iOS devices. Is there a control or technology that functions similarly to a background worker? My goal is to send data to the server without interrupting t ...

Tips for creating a function that utilizes a select option value

I'm struggling with a form that includes two select inputs. I want the second input to only be enabled if the first one has been selected. I attempted using an onclick event, but it didn't work out as expected. Can anyone provide assistance? (apo ...

How can I determine whether a value is present in a data attribute using jQuery?

I'm working with a HTML div that looks like this: <div id="myDiv" data-numbers="1 4 5 3 9 88 57 "></div> Within the data-numbers attribute of the div, there are random numbers separated by white space. My goal is to determine whether ...

Tips for automatically displaying the scroll bar continuously on iOS 15 without requiring user interaction

We have a Web Application that displays a scroll bar for users to navigate through the content. The scroll bar functions correctly on desktop browsers and Android browsers, but not on Apple devices running iOS 15 (Safari Browser). Current Behavior : In ...

Mobile device does not respond to HTML button click

Currently, I am developing a web application. On one of my HTML pages, I have the following code snippet: <div class="div2"> <button id="buttonid" type="button" class="btn-submit pull-right" onclick="alert()">BOOK NOW</button> <d ...

Enhancing the visual appeal of a standard jQuery slider with thumbnails

Recently, I incorporated the Basic jQuery slider into my website, which can be found at . As a novice in jQuery but well-versed in HTML and CSS, I have managed to make it work seamlessly on my site. However, I am curious to know if there is a way to displa ...

A couple of inquiries (Bounce, Align)

I am attempting to center the text within the circles and make them bounce when the circle is hovered (the text inside the circle). Check it out here: http://jsfiddle.net/cJ3se/ Would appreciate any assistance. Denver ...

When you click on a sublevel in the vertical CSS and JavaScript onclick menu, it disappears automatically

I'm a beginner when it comes to Javascript, and I'm still getting the hang of CSS/HTML. Currently, I am working on creating a vertical menu using CSS and javascript. My goal is to have the sublevels appear on the right side of the menu when someo ...

Prevent Scrolling on Body with W3 CSS

While implementing scroll body lock packages like body-scroll-lock, react-scrolllock, or tua-body-scroll-lock alongside the W3 CSS package, I have encountered an issue where the body remains unlocked even when the designated element is active or open (e. ...

The Transition Division Is Malfunctioning

I've encountered an issue where I am trying to move a div by adjusting its left property, but no transition is taking place. Regardless of the changes I make to my code, the result remains the same. Below is the current state of the code. Can anyone i ...

Is the function failing to detect the updated variable because it is not declared as a global variable?

I have created a quiz with 7 select boxes and a submit button, aiming to display a warning error if the select boxes are not changed or show the score if they are changed. I initialized a variable called 'changed' as false. When a select box is ...

What are the steps to disable CSS in order to speed up the execution of automation tests?

Source: What is the optimal method to temporarily disable CSS transition effects? When testing JavaScript, I typically utilize JavascriptExecutor, however, none of the aforementioned blogs shed light on how this can be achieved. I attempted: js.execu ...

Serving static files in Django

Currently diving into Django and encountering a hurdle with static files. I've followed the setup in both the settings and HTML, but unfortunately, they are not loading on the website. Seeking assistance to resolve this issue! **settings.py:** STATIC ...