What's the best way to ensure my text spans the entire width of the bootstrap navbar?

I want my text to span the entire width of the navigation bar, similar to this example

Currently, it looks like this

I am utilizing the most recent bootstrap CSS and also have my own custom stylesheet.

Here is the HTML code for reference:

<!doctype html>
<html>
    <head>
        <title>Title</title>
        <link rel="stylesheet" href="css/main.css">
        <link rel="stylesheet" href="css/bootstrap.min.css"/>
        <link rel="stylesheet" href="css/bootstrap-responsive.min.css">
        <link href='http://fonts.googleapis.com/css?family=Lato&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <body>
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-3">
                <img src="img/logo.png" id="logo" class="img-responsive">
                </div>
                <div class="col-md-4" id="searchbox">
                    <div id="search-input">    
                        <div class="input-group col-md-12">
                            <input type="text" class="form-control input-lg"/>   
                        </div>        
                    </div>        
                </div>    
                <div class="col-md-1" id="search-button">
                    <span class="input-group-btn">
                        <button class="btn btn-info btn-lg" type="button">
                            <i class="glyphicon glyphicon-search"></i>
                        </button>
                    <span>
                </div>
                <div class="col-md-3" id="login-name">
                    <p> Logged in: John Smith </p>
                </div>
                <div class="col-md-1">
                    <a href="#"><i class="glyphicon glyphicon-cog" id="settings-cog"></i></a>
                </div>
            </div>
            <div class="row">
              <!-- Static navbar -->
             <nav class="navbar navbar-default navbar-static-top">
                <div class="navbar-header">
                  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                  </button>
                </div>
                <div id="navbar" class="navbar-collapse collapse">
                  <ul class="nav navbar-nav">
                    <li><a href="#">Home</a></li>
                    <li><a href="#about">Projects</a></li>
                    <li><a href="#contact">News</a></li>
                    <li><a href="#contact">Careers</a></li>
                    <li class="active"><a href="#contact">Contact Us</a></li>
                    <li><a href="#contact">About Us</a></li>
                    <li><a href="#contact">Case Studies</a></li>
                    <li><a href="#contact">Blog</a></li>
                    <li><a href="#contact">Customers</a></li>
                  </ul>
                </div><!--/.nav-collapse -->
             </nav>   
            </div>
        </div>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <script src="/js/bootstrap.min.js"></script>
    </body>
</html>

Answer №1

Check out this code snippet inspired by the bootstrap website:

    /* Adjust the navigation bar to fill the entire space of the .navbar */
.navbar .navbar-inner {
    padding: 0;
}

.navbar .nav {
    margin: 0;
    display: table;
    width: 100%;
}

.navbar .nav li {
    display: table-cell;
    width: auto;
    float: none;
}

.navbar .nav li a {
    font-weight: bold;
    text-align: center;
    border-left: 1px solid rgba(255, 255, 255, .75);
    border-right: 1px solid rgba(0, 0, 0, .1);
}

.navbar .nav li:first-child a {
    border-left: 0;
    border-radius: 3px 0 0 3px;
}

.navbar .nav li:last-child a {
    border-right: 0;
    border-radius: 0 3px 3px 0;
}

Have you had a chance to try implementing this code?

It's quite simple: Make sure the Navbar is set to 100% width and use display:table;, then adjust the inner elements with

width: auto;
display:table-cell;

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

Transitioning from JQuery to JavaScript with Carousel Bootstrap 5

I would like to implement a bootstrap 5 carousel that displays multiple items and slides one at a time. My goal is to convert the existing Jquery code into pure Javascript so that I can eliminate the dependency on Jquery. I came across this solution which ...

Display/Conceal content with JQuery on a PHP webpage

I am having trouble with the following code. My intention is to show/hide the content between the #info id when clicking buttons, but nothing seems to be happening. Could you help me identify the issue? echo '<script> $( "#show' . $r ...

Guide to setting a universal background image in ReactJS for all pages

I attempted to add an image as a background to all pages, but encountered some challenges along the way. Initially, I tried setting the background image in the style of the body tag within index.html: <body style="background-image: url(%PUBLIC_URL% ...

Add distinctive formatting for the final element that is not the last child

Presented with a fascinating challenge, I find myself with an ever-changing number of .child.red children. I am in need of referencing the last .child.red element dynamically using styles. Although I have attempted to achieve this on my own, I am curious a ...

Issues with formatting of lists

Need help with CSS styling for multiple lists #basic li, #standard li, #premium li { padding-left: 30px; padding-top: 3px; padding-bottom: 5px; background-image: url(../assets/misc/blue_yes.png); background-repeat: no-repeat; background-position: 0 .5em; ...

How can I activate an event with Jquery when the CSS is modified?

I'm wondering if there is a way to create a method or use an event listener that will be triggered when a CSS change occurs. Specifically, my stylesheet includes media queries and I am interested in knowing if it's possible to attach a listener ...

Aligning two buttons within a div using Bootstrap

Hello and thank you for taking the time to read this! I am facing an issue with Bootstrap where I cannot seem to center 2 buttons inside a div. Currently, the buttons are aligned to the left. How can I get them centered? Here is the code snippet: <d ...

What is the best way to ensure that a specified number of list items (li) will align properly within the width of an unordered list (ul

I'm attempting to make all the li elements' width match that of my ul element. Here is the code I am using: http://jsfiddle.net/4XR5V/2/ I have looked at some similar questions on the website and tried adding: ul { width: 100%; display: tab ...

Optimizing carousel image dimensions for various screen sizes

I'm currently working on a full screen carousel in HTML and I'm curious about the optimal image size to ensure it resizes properly on all screen sizes without any distortion. Can anyone help me out with this? ...

Has CSS3 been recognized as an official standard?

Can you confirm whether CSS3 has been officially recognized as a W3C standard or is it currently in the status of "CR" (Candidate Recommendation)? ...

Text selection is disabled

During my work on the test website, I encountered an issue. I've included all of my code as I'm unsure where the problem lies. View the jsfiddle here. As shown in the jsfiddle, the top section of text on the website is unselectable. I'm seek ...

How can JavaScript be used to parse an HTML string and convert it into tabular data in the form of a 2D array

My goal is to parse an HTML string client-side using React with TypeScript as our frontend framework. During the parsing process, I need to extract the styles associated with each element, whether it be inline styles, inherited styles, or styles defined wi ...

Show a SweetAlert message if a specific Div Class is not found within the page

Seeking assistance with displaying a SweetAlert popup only if a certain div class is not found on the page. It appears to work when using an ID, but not with classes. Any suggestions on how to trigger this popup if the specified div class is absent? < ...

Trouble concealing information in Gmail and Outlook, issue persists

I need to create an email with two different links, one to be visible only in Gmail and the other only in Outlook. I discovered that I should use mso-hide for Outlook and display none for Gmail, but neither seem to be working as expected. When I use displa ...

What is the best method for passing HTML code (complete with tags) through 'data-title' to CSS content using attr(data-title)? Alternatively, is there another approach that can be used for

I successfully implemented hover tooltips in my HTML code using the following method: HTML (Django templates): <div class="hint-quest-mark"> &nbsp;?<span class="hint-title" data-title="{{ class_ ...

moving a simulated element to a new location

Looking for some help with my html/CSS code that creates a unique element at the bottom of a div with an image background. The shape I've created is positioned at the bottom of the div... Below is the HTML: <div style="background-image:url(&apos ...

Attempting to eliminate all choices except for the initial one

I have a dropdown menu that needs to dynamically reset its values when an item is deleted without refreshing the page. The issue I'm encountering is that the default option keeps getting removed. Here's the HTML code: <select id="my_SiteGrou ...

Vue.js is not incrementing the counter as expected

I've encountered an issue with a button that has a click event to increment data value by 5, but instead of adding 5 it is appended by 5. Click here for the code example <div id="react"> <button @click='counter += 5'>Increment& ...

Guide to displaying or concealing the header using PHP

Once the add button is clicked, the text should be hidden and the form should be displayed. Check out my code below: <h2 style="font-size: 2em; margin-bottom: 0.75em; margin-left: -1%;">Specify Co-Owners for self occupied property</h2> <div ...

Creating a dynamic image slider that smoothly glides across a webpage

I've been working on a carousel (image slider) for my website and I need some help. Specifically, I want to reposition the entire slider slightly to the left on the webpage. You can see the slider in action on this site: and I also created a jsfiddle ...