Expanding the Boostrap menu to occupy the entire width

I want the menu to span the width of its container instead of being aligned to the left.

[LOGO A|B|C            ]
[LOGO   A  |  B  |  C  ]

Here is my test code. How can this be achieved using bootstrap?

.navbar-brand{width: 405px;}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <ul class="nav navbar-nav table-responsive">
      <li class="active"><a href="#">Home</a></li>
      <li><a href="#">Page 1</a></li>
      <li><a href="#">Page 2</a></li>
      <li><a href="#">Page 3</a></li>
    </ul>
  </div>
</nav>

Answer №1

To implement a responsive navigation bar, you can utilize the flex-box property in CSS.

.navbar-brand {
  width: 405px;
}

@media screen and (min-width:768px) {
  .navbar>.container-fluid {
    display: flex;
  }
  ul.nav.navbar-nav {
    flex: 1 1;
    display: flex;
  }
  .navbar-nav>li {
    flex: 1 1;
  }
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <ul class="nav navbar-nav table-responsive">
      <li class="active"><a href="#">Home</a></li>
      <li><a href="#">Page 1</a></li>
      <li><a href="#">Page 2</a></li>
      <li><a href="#">Page 3</a></li>
    </ul>
  </div>
</nav>

Answer №2

Are you in need of something similar to this?

.navbar-nav {
  display: flex;
    width: 100%;
    justify-content: space-between;
}
    
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    
     
    <ul class="nav navbar-nav table-responsive">
    <li class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a>
    </li>
      <li class="active"><a href="#">Home</a></li>
      <li><a href="#">Page 1</a></li>
      <li><a href="#">Page 2</a></li>
      <li><a href="#">Page 3</a></li>
    </ul>
  </div>
</nav>

Answer №3

To align the menu to the right, you can use the following code for the .navbar-nav:

.navbar-nav {
  float: right !important;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <ul class="nav navbar-nav table-responsive">
      <li class="active"><a href="#">Home</a></li>
      <li><a href="#">Page 1</a></li>
      <li><a href="#">Page 2</a></li>
      <li><a href="#">Page 3</a></li>
    </ul>
  </div>

Answer №4

Are you looking for a design similar to this?

.navbar-header {width: 160px;}
.navbar-nav.table-responsive {
   width: calc(100% - 160px);
   border: 0;
   margin-left: 0;
   margin-right: 0;
   display: flex;
   flex-wrap: wrap;
}
.navbar-nav > li {
   float: left;
   flex-grow: 1;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    <div class="navbar-header pull-left">
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <ul class="nav navbar-nav pull-left table-responsive">
      <li class="active"><a href="#">Home</a></li>
      <li><a href="#">Page 1</a></li>
      <li><a href="#">Page 2</a></li>
      <li><a href="#">Page 3</a></li>
    </ul>
  </div>
</nav>

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

Ensuring form labels are properly aligned with input-group-prepend in Bootstrap

Currently, I am developing a python/django website using bootstrap, and I have encountered an issue that I cannot resolve independently. It has been quite some time since I last worked with python/django/bootstrap, so I may be overlooking something? <fo ...

Toggle between data display formats in Django's template

As a newcomer to Django, I'm unsure if what I'm looking for is available in pure Django templates. I have the main page of my application that retrieves data from a database, and displays the information in a div styled with Bootstrap for a bett ...

Ways to prevent text and maps from overlapping in CSS

I'm currently working on a website where I've implemented a map that calculates the distance from the current location. The map is functioning properly, but now I'm trying to add text below it and running into an issue with overlap. To see ...

What could be the reason for an iOS web app to become unresponsive on the initial loading screen?

I recently completed the development of an HTML5 webapp, and during my local server tests on desktop browsers, iOS Safari, and as a homescreen bookmark webapp, everything ran smoothly. The offline functionality with the cache.manifest file also worked flaw ...

Avoiding using ID selectors when working with a checkbox hack

I've shared about my project previously. Twice, actually. While the responses have given me better insight into my situation, they haven't been directly applicable. I take responsibility for this as I was posting an incomplete version of the fina ...

Discover the amazing capabilities of Beautiful Soup's find function in extracting numerical data from Google

Just finished watching a tutorial on beautiful soup and decided to put it to the test by scraping some data from Google. After searching for "coronavirus UK" I aimed to extract the current number of confirmed cases. A table on the upper right side of the ...

The slideUp and slideDown functions are not functioning properly

Whenever a user clicks on image-exp, I want description-exp to slide down while other description-exp slides up. I am currently using a Bootstrap template available at this link. To demonstrate the issue, I created a JSFiddle that can be accessed here. H ...

Creating visually appealing tables with nested tables using CSS for styling including borders and backgrounds

Looking to create webpages that have a variety of tables, including a main table with a header (marked 2 on the picture) and several data tables for the user (marked 1 on the picture). To style these specific data tables, I've added some custom CSS: . ...

What is the best way to set inner text using jQuery?

The code snippet below demonstrates a specific issue: <span id="test1">some text</span> <span id="test2">some text</span> Upon loading the content, the following JavaScript is executed: alert($('test1').text(); $(' ...

Fetching jQuery library via JavaScript

Having trouble loading the JQuery library from a JavaScript file and using it in a function. JS1.js $(document).ready(function () { //var id = 728; (function () { var jq = document.createElement('script'); jq.type = 'te ...

Struggling to make a variable pass in an Ajax post script

Having trouble passing the "filename" variable from main.php to save_sign.php. Can anyone provide assistance? main.php <? $filename="222222"; ?> <script> $(document).ready(function() { $('#signArea').signat ...

Instructions for integrating AJAX into a PHP script

I am looking to incorporate AJAX into my PHP file so that when I delete an item from a list, the data automatically reloads and the list is updated with the new information. I have created a list of all my data along with a delete button. Below is the PH ...

The execution of my JavaScript code does not pause for the completion of an ajax request

I'm currently working on a register validation code in JavaScript. One of the key aspects checked by the validation function is whether the email address provided by the user already exists in the database. To handle this, I'm implementing ajax, ...

"Resolving the issue of overflow in dropdown submenus using Css

Observing my CSS menu in the provided image: https://i.sstatic.net/cJMge.jpg Upon hovering over "Haschildren," I notice: https://i.sstatic.net/gJ5M8.jpg The concern arises regarding the overflow issue (grey area around sub-voices). Despite tweaking the u ...

Move the div to the bottom of its container

Is there a way to place a div at the bottom of its containing div? <style> .outside { width: 200px; height: 200px; background-color: #EEE; /*for visibility*/ } .inside { position: absolute; bottom: 2px; } </style> <div c ...

Arranging elements within a div using inline positioning

Currently, I am trying to arrange elements within a div. Below is the div that needs positioning: https://i.sstatic.net/5nZUt.jpg This is the desired layout: https://i.sstatic.net/vXSV9.jpg Here is the HTML and CSS code snippet: #channel-header * { ...

Picture that perfectly matches the height of the window

I am looking to create a website design similar to this where an image fills the window until you scroll down. I am not sure how to accomplish this. Would using jQuery be the best option? I haven't been able to find much information on this. While my ...

Issues with Angular's *ngIf directive not functioning correctly

Within my template, I have a block of HTML that controls the visibility of a div. <div *ngIf="csvVisible"> <p>Paragraph works</p> </div> This particular code snippet belongs to my component. export class SettingsComponent imple ...

Utilizing the HTML method of jQuery on a jQuery element

Currently, I am attempting to modify the inner html of an element. When I utilize the following code: $('.best-photos-button')[0].innerHTML="Add More Photos"; the change is successful. However, if I try to use .html() instead of ".innerHTML" in ...

Update the content of a div element using the information from a JSP file using

I have encountered an error when trying to replace the content of a div with that of a JSP file. The error message I receive is "Uncaught SyntaxError: Unexpected token ILLEGAL." Interestingly, this issue only arises when the JSP file contains multiple lin ...