Issue with left-aligned navigation in Bootstrap

Having some trouble getting my logo to align correctly on the top navigation bar. It looks fine in a small view, but when I stretch it out, the logo shifts to the right. I want the logo to stay all the way to the left regardless of screen size.

I've tried using .text-left and pull-left classes, but they don't seem to be working for me.

Currently, I am using Bootstrap for my code. Here is what I have so far:

Thank you in advance!

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>TITLE GOES HERE</title>

  <!-- Bootstrap -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>

<body>

  <nav class="navbar navbar-default navbar-fixed-top" style="background-color: #1C2D8E">
    <div class="container">
      <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>
        <a class="text-left" id="logo" href="#">LOGO GOES HERE</a>
      </div>
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="../navbar/">Settings</a>
          </li>
          <li><a href="../navbar-static-top/">Support</a>
          </li>
          <li class="active"><a href="./">Help<span class="sr-only">(current)</span></a>
          </li>
          <li><a href="../navbar-static-top/">Logout</a>
          </li>
        </ul>

      </div>
      <!--/.nav-collapse -->
    </div>
  </nav>

  <!-- JQuery (necessary for Bootstrap's javascript plugins) -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
  </script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js">
  </script>

</body>

</html>

Answer №1

According to the guidelines, ensure that the left alignment is achieved by using the navbar-brand class.

Update

 <a class="text-left" id="logo" href="#">LOGO GOES HERE</a>

to

 <a class="navbar-brand" id="logo" href="#">LOGO GOES HERE</a>

And eliminate the enclosing container tag:

 <div class="container"></div>

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>TITLE GOES HERE</title>

  <!-- Bootstrap -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>

<body>

  <nav class="navbar navbar-default navbar-fixed-top" style="background-color: #1C2D8E">
       <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>
        <a class="navbar-brand" id="logo" href="#">LOGO GOES HERE</a>
      </div>
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="../navbar/">Settings</a>
          </li>
          <li><a href="../navbar-static-top/">Support</a>
          </li>
          <li class="active"><a href="./">Help<span class="sr-only">(current)    </span></a>
          </li>
          <li><a href="../navbar-static-top/">Logout</a>
          </li>
        </ul>

      </div>
      <!--/.nav-collapse -->
  </nav>

  <!-- JQuery (necessary for Bootstrap's javascript plugins) -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
  </script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js">
  </script>

</body>

</html>

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

Generate two separate CSS files (Mobile and Desktop versions) by compiling a Stylus (.styl) file using Node.js

Can a single Stylus file be compiled into two separate CSS files? For example, one optimized for mobile without the -moz and webkit elements, and another for cross-browser applications? Thank you. ...

Retrieve the initial 100 links using XPath and PHP

I wrote the following code to extract href's (links) from a web resource that contains more than 1000 links: $dom = new DOMDocument(); @$dom->loadHTMLFile('https://www.domain.me/'); $xpath = new DOMXPath($dom); $entries = $xpath->quer ...

What is the best way to make a sticky floating sidebar that stays fixed while scrolling?

I'm facing a challenge on my website where I want a sidebar on the left to stay with the user as they scroll. The sidebar should scroll along with the user until it's 5px from the top of the page, at which point it should remain fixed in place. ...

My presentations are not functioning as expected, could there be a problem with my HTML, CSS, or JavaScript coding?

My website utilizes a Slideshow feature to display images for blog posts. Recently, I attempted to include multiple slideshows within an article, which unfortunately caused all of the slideshows to malfunction. As it stands now, when the code is executed, ...

Here is a step-by-step guide on how to use JavaScript to eliminate the page title, URL, date and

When printing a page using window.print, is there a way to exclude the page title, URL, page number, and date/time from appearing? ...

Acquire HTML content and save it in a MYSQL database: A Step-by-Step Guide

How can I effectively store an HTML page with CSS in a MYSQL database? Is this even feasible? What type of column should be used for storage? And how can I retrieve the stored formatted HTML and display it correctly using PHP? If the page contains imag ...

Display a loading spinner while the search bar makes an API request in Angular

I'm struggling with incorporating a loading spinner display when a user enters a search term in the search bar. When there is a change detected in the search term property, an API request is made to populate the lists in the view with the relevant dat ...

Rotating Cursor during AJAX loading process

I utilize a WebGrid across many of my pages to showcase various products. Within the code snippet below, you can see how an item is added to the database when a user clicks on it: public bool ToCart(int userId, string partNumber, ...

Triggering HTML5 form validation after correctly setting a custom error message with setCustomValidity

I have implemented a custom error message using the setCustomValidity() function for every input with the type=number in my form to display translated error messages when an incorrect number is entered. However, I have encountered an issue where the erro ...

The CSS is getting overridden by the a:-webkit-any-link user agent stylesheet

I've found myself faced with a page full of lists and links that I need to style individually. No matter what I try, the fonts and colors keep getting overridden by an unknown user agent stylesheet. I've experimented with styling the divs using c ...

Equal Height Cards in Material UI

Looking to create a row of three horizontal cards with uniform height that adapt to screen size. For example: Card A | Card B | Card C ...

Dependency on the selection of items in the Bootstrap dropdown menu

I am currently struggling with a few tasks regarding Bootstrap Dropdown Selection and despite looking for information, I couldn't find anything helpful. Check out my dropdown menu Here are the functions I would like to implement: 1) I want the subm ...

"Efficiently trimming off any text past the final character using

I have a variable in Smarty named {$url} which contains the following URL: $url = https://www.example.com/?parameter=hello:world:itsme I need to remove everything after the last ":" in the URL. The desired output is: $result = https://www.example.com/? ...

Make the child element's height 100% when the parent's width is not set

Having trouble implementing the height:100; property on hover in my portfolio section. I've tried several solutions from similar questions without success. Although it works with media queries, I believe there's a better way to achieve this but I ...

Even with the text field populated and clearly existing, Firefox is still throwing a null error when trying to retrieve it using

Hey there! I'm currently working on a sample HTML page and I'm facing an issue with retrieving data from a text field. No matter what I try, I keep encountering the following error: TypeError: document.getElementById(...) is null Let me share t ...

The words spill across the navigation bar

I am facing an issue with my navbar where the text overflows and creates extra space due to a white background. I have tried resolving this for a while but haven't been successful. I need help from someone knowledgeable in this area. Here are some im ...

The parent div's height is not compatible with the CSS grid

I created a CSS grid layout featuring a header, side menu, and scrollable content. My goal is to test this layout in a container div where I've specified the width and height. The layout adjusts well according to the container's width, but seem ...

Responsive design for iPad and larger screens - adjusting to different screen sizes

Does anyone know of a CSS code that can effectively target both iPad and desktop devices with a max-width of 768? I attempted the following code, however it seems to only work for desktops: @media only screen and (max-width: 768px) Due to this limitatio ...

Use jQuery to gather all the values from an HTML select element

I am using PHP to generate a HTML select option based on folders in a directory. Now, I am looking for a way to retrieve the value of the selected option in my jQuery script. I am familiar with $('#select :selected').text() and $(#select).val(), ...

The Safari browser is having trouble rendering the website's CSS and HTML properly

Check out this example of how the website should look on Chrome for Android: https://i.stack.imgur.com/RzUSp.jpg And here is an example from Safari on iPad Mini 2: https://i.stack.imgur.com/PAj2i.jpg The Safari version doesn't display the proper fon ...