Tips for ensuring consistent alignment of the final navigation item

I'm having trouble understanding why the layout collapses when I resize the window horizontally. I've attempted to adjust the width of the div and tried using display:block. My website is built with Bootstrap 3, although I don't believe that's the root cause of the issue.

h1 {
font-family: 'LatoBold';
color: #ff990f;
}
/*----------------------------------  Header  ----------------------------*/
    #header {
        position: relative;
        margin-bottom: 1em;
        min-width: 100ex;
        white-space: nowrap;
    }

    #header > .inner {
        height: 95px;
    }

    /* njnavbar
    ************************************/
    #header .njnavbar {
        position: absolute;
        bottom: 0px;
        right: 0px;
        height: 42px;
        min-width: 90ex;
        white-space: nowrap;
    }

    #header .njnavbar * {
        font-family: 'LatoBlack', Arial, Verdana, sans-serif;
        font-size: 16px;
        color: #FFF;
        text-transform: uppercase;
        text-shadow: #08121b 0px 1px 1px;
    }

    #header .njnavbar ul {
        margin-right: 15ex;
    }
    #header .njnavbar ul li {
        float: left;
        line-height: 42px;
        margin: 0 10px;
        list-style: none;
    }

    #header .njnavbar ul li.last {
        margin-right: 0!important;
    }

    #header .njnavbar > ul > li > a:hover {
        color: #e5ca38;
    }

    /* Phone Number
    ************************************/
    #header .phone {
        position: absolute;
        top: 1ex;
        margin-top: .5ex;
        right: 10px;
        padding-left: 30px;
        height: 26px;
        line-height: 26px;
        font-size: 18px;
    }

    #header .phone strong {
        font-family: 'LatoBlack';
    }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
            <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
        <title>example.COM</title>

        <!-- Bootstrap -->
        <link href="./assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
        <link rel="stylesheet" href="css/fonts.css" type="text/css" />
        <link rel="stylesheet" href="assets/css/login.css" type="text/css" />
      </head>

      <body>
        <div id="header"><div class="inner">
        <h1>example.COM</h1>
          <div class="phone">
           For inquiries, call <strong>888-555-1212</strong> | <strong>888-555-1213</strong>
          </div>
          <div class="njnavbar" style="min-width:90ex">
            <ul>
                <li><a href="index.html">Home</a></li>
                <li><a href="about.html">About</a></li>
                <li><a href="services.html">Services</a></li>
                <li><a href="longer_asdfchoiceasd.html">longer choiceasdf</a></li>
                <li><a href="#">Customers</a></li>
                <li class="last"><a href="contact.html">Contact</a></li>
            </ul>
          </div> <!-- /njnavbar -->
        </div></div> <!-- /inner /#header -->
        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
        <!-- Include all compiled plugins (below), or include individual files as needed -->
        <script src="./assets/bootstrap/js/bootstrap.min.js"></script>
      </body>
    </html>

Answer №1

The issue appears to be connected to the CSS property called float.

#header .njnavbar ul li {
    float: left; /*delete this line*/
    display: inline-block; /*replace with this line*/
}

By making this adjustment, the white-space: nowrap; feature on the parent element should function correctly.

Additionally, it is important to use caution when working with the ex unit in CSS as it is not commonly used unless you have a specific understanding of its implications.

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

Tips for effectively utilizing the :valid pseudo-class in Material-UI components to dynamically alter the border styling

Currently, I am attempting to adjust the border color of Mui TextFields using createTheme from Mui v5 when the input is valid. The border itself is defined within the ::before and ::after pseudoclasses. For the TextFields, I am utilizing variant="stan ...

Opting for <button> over <a>

I am currently working with ReactJS in conjunction with a Bootstrap Nav Bar. Bootstrap utilizes an <a> tag for the navigation buttons. I am aiming to have the buttons scroll down to a different component on the page without resorting to using an href ...

Securing HTML pages with ASP.NET MVC authentication

Within my MVC application, there are a few static (pure html) pages that require authentication to prevent unauthorized access. Is there a method to achieve this without transferring all the code to asp files and incorporating a controller, which would t ...

Running a shell script on a website should always be done in a single instance

When I use html/php to call a bash script on a website, I have multiple html-buttons that initiate the same script with different arguments. The issue arises when each button click opens a new instance of the script. Is there a way to somehow resume the r ...

Tips for transforming a hover menu into a clickable menu

The scenario above demonstrates that when hovering over the dropdown menu, it displays a submenu. However, I want the submenu to be displayed after clicking on the dropdown text. Could anyone provide assistance on how to change the hovermenu to a clickabl ...

Mysterious JQuery attribute

I've come across a piece of code that utilizes an unfamiliar selector that I can't seem to figure out: $("div[tag=" + someVariable + "]").css("display", "block"); From what I gather, the selector is searching for a div element with an attribute ...

Creating a dropdown menu that seamlessly populates elements without any empty spaces

My team at the company is using a menu created by another developer. I recently added a dropdown selection to the first item on the menu, but I've run into an issue where the dropdown box does not fully fill the item, and I can't seem to fix it. ...

Styling a rectangle in p5.js: Tips and tricks

In my p5.js code, I created a rectangle using rect(): rect(10, 10, 10, 10); Now, I want to add some style to it with a box-shadow effect: box-shadow: 20px 20px 50px #00d2c6, -30px -30px 60px #00ffff; However, when I tried to apply the style using the doc ...

Identifying when a system window covers an iframe

After watching a fascinating YouTube video (https://www.youtube.com/watch?v=TzPq5_kCfow), I became intrigued by how certain features demonstrated in the video could be implemented using JavaScript. One specific question that arose for me was how one can d ...

What is the best method for showcasing numerous dropdown lists using JavaScript along with conditional if-else statements?

Hello everyone, I am currently new to javascript and I'm attempting to build a small web application using javascript. However, I am facing an issue with printing the drop-down list output. Could someone please assist me in resolving this problem? < ...

When using NextJs, running the commands 'npm build' and 'npm start' can sometimes cause style inconsistencies

Currently working on a project with NextJs (sorry, no screenshots allowed). Running 'npm run dev' for development works perfectly fine, but when I switch to 'npm run build' and then 'npm start', the website displays overlappin ...

Using the ternary operator in React to implement inline styles

Within my React/Typescript project, I aim to dynamically exhibit a color based on the presence or absence of a value in payload[1]. In the code snippet below, note the usage of an inline style tag. <li className="recharts-tooltip-item" style={ ...

Why does the AngularJS ngRepeat filter permanently remove null values?

Check out this JSFiddle demonstration I created to illustrate the problem: http://jsfiddle.net/s6Lj2/2/ Observe that in the dataset $scope.places = [{ name: 'Chicago', status: 'Active', analyst: 'Sam', recor ...

Retrieve the ID of a specific row within a table in a datatables interface by selecting the row and then clicking a button

My goal is to have a table displayed where I can select a row and then have the option to edit or delete that row with a query. To achieve this, I need a primary key that won't be visible to the user. This is how my table is set up: <table id=&apo ...

Mobile WEBSITE Development with Ionic Framework

Exploring the potential of utilizing the Ionic Framework for my mobile website has piqued my curiosity. Are there any concerns I should be aware of when running Ionic Framework on mobile browsers? My plan is to leverage the framework's CSS and JS capa ...

On one webpage, IE 11 is correctly styling certain visited hyperlinks while failing to do so for others

Although I acknowledge that others have asked similar questions, none seem to address the exact issue I am facing, nor do they offer practical solutions or clear explanations. Issue I'm encountering a problem where some visited hyperlinks in IE 11 f ...

Issue with transition duration not affecting bootstrap button functionality

I am attempting to incorporate a transition effect on specific bootstrap buttons. The issue lies with the height and width properties. They change instantly without taking into account the transition duration property. Keep in mind that all other propert ...

Utilize React Material UI Slider to dynamically adjust Border Radius in your web design

Utilizing React Material UI's components like the slider and button is essential for this project. The main objective is to dynamically change the border radius of the button using the value obtained from the slider. However, there seems to be a chall ...

Problem with Express server not fetching or applying public stylesheet

As I delve into the world of serving pages with node, express, and ejs, I encountered an issue with linking a stylesheet to my index.ejs file using a public folder. Despite setting up the link correctly in the HTML code, the styles were not loading when I ...

Transforming a Bootstrap Background Image to a Captivating Video Display

Here is the CSS code snippet that I'm having trouble with: .masthead { position: relative; width: 100%; height: auto; min-height: 35rem; padding: 15rem 0; background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 75% ...