Tips for displaying the Bootstrap Navbar in a single line on the xs layout

I am working on a Bootstrap navbar that displays properly in most screen layouts, but I am having trouble getting it to show on one line in the xs layout. Even though there is enough room for it to fit on one line, it keeps breaking up into multiple lines. How can I make sure it stays on one line without breaking?

https://i.sstatic.net/6FMmT.png

    <nav class="navbar navbar-inverse">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">Company Name</a>
            </div>                
            <ul class="nav navbar-nav visible-sm-block visible-md-block visible-lg-block">
                <li class="active"><a href="#">Page 1</a></li>
                <li><a href="#">Page 2</a></li>
                <li><a href="#">Page 3</a></li>
            </ul>                    
            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown">
                    <a href="#" data-toggle="dropdown" class="dropdown-toggle"><span class="glyphicon glyphicon-cog"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Settings 1</a></li>
                        <li><a href="#">Settings 2</a></li>
                        <li><a href="#">Settings 3</a></li>
                        <li class="divider"></li>
                        <li><a href="#">Settings A</a></li>
                        <li><a href="#">Settings B</a></li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a href="#" data-toggle="dropdown" class="dropdown-toggle"><span class="glyphicon glyphicon-menu-hamburger"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Menu 1</a></li>
                        <li><a href="#">Menu 2</a></li>
                        <li class="divider"></li>
                        <li><a href="#">Menu A</a></li>
                        <li><a href="#">Menu B</a></li>
                        <li><a href="#">Menu C</a></li>
                    </ul>                        
                </li>
            </ul>

            <div style="display:none" class="navbar-collapse">
                <p class="navbar-text  fix_navbar_left_larger">Company Name</p>
                <p class="navbar-text fix_navbar_left_xs">Company Name</p>
                <p class="navbar-text visible-sm-block visible-md-block visible-lg-block"></p>
                <p class="navbar-text visible-sm-block visible-md-block visible-lg-block"><a href="#"></a></p>
                <a class="navbar-brand navbar-brand navbar-right dropdown" href="#">
                    <span class="glyphicon glyphicon-menu-hamburger"></span>
                </a>
                <a class="navbar-brand navbar-brand navbar-right" href="#">
                    <span class="glyphicon glyphicon-cog"></span>
                </a>
            </div>                        
        </div>
    </nav>

    <div class="pagecontent">
        <p class="visible-xs-block">seen on xs screens.</p>
        <p class="visible-sm-block">seen on sm screens.</p>
        <p class="visible-md-block">seen on md screens.</p>
        <p class="visible-lg-block">seen on lg screens.</p>
    </div>

</div>

Answer №1

To customize the navbar header, add the class "pull-left" like this...

<div class="navbar-header pull-left">
. Also, include the class "pull-right" to the two dropdown list items as shown here...
<li class="dropdown pull-right">
.

Check out the Fiddle

In the future, refer to the default navbar template at http://getbootstrap.com/components/#navbar for comparison with your own code to identify any errors.

Answer №2

Consider including pull-right within the specified <li class="dropdown"> elements.

Answer №3

To achieve this effect, you will need to utilize the pull-left and pull-right classes provided by Bootstrap.

Check out my example on JSFiddle

The navbar is spanning the full width of the page, so assign the pull-left class to one element and the pull-right class to another. Additionally, in order for the inner menu items to align horizontally, they must also be floated left and right accordingly. By following these steps, you can achieve the desired layout outcome :)

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 saving input data from an HTML page to a text file

How can I save the inputs from a simple form as a text file using HTML code? Here is an example of the HTML code: <div id="wrapper"> <div class="main-content"> <div class="header"> </div> ...

Enhancing collapsible list headers in jquery mobile with checkboxes

Having trouble with a jQuery Mobile website issue. Currently working on a jQuery mobile site that includes a collapsible list (). The client request is to have a checkbox inside the header, allowing users to check items off without needing to open them. T ...

Struggling to input information from a web form into a MySQL database using PHP

I'm currently facing an issue with my form not being able to submit data to the MySQL database. Strangely, I'm not receiving any error messages that could help me identify the root of the problem. I experimented by changing the action method to G ...

Embedding a CSS class within the primary class selector

Can someone help me with this HTML challenge? <div class="span3"> <div class="abc">code for first div</div> <div class="abc">code for second div</div> </div> I'm trying to hide the first "abc" division within th ...

Different types of video formats used for html5 video players

Looking for some guidance here. I'm currently in the process of developing a website that allows users to upload their own videos. For the video player, I've opted for the HTML5 player by . My main concern is ensuring that the HTML5 player can on ...

A guide on how to efficiently retrieve all images stored in a specific directory

I attempted to showcase all the images from a single directory using jQuery, but unfortunately it is not functioning as expected. My folder setup includes an 'images' folder and a 'js' folder. I followed this question on Stack Overflow ...

What is the process for converting inline SVG images on the server?

Looking to use inline SVG as a background-image for another element? Check out this example that currently only works in Chrome. If you need an alternative method, take a look at the simpler inline SVG from the RaphaelJS demo here. <svg height="480" ve ...

The div's height is not matching the CSS declaration as expected

In my HTML, I have a div called innerDetails which serves as a flex item with the following CSS properties: .cover { height: 100vh; width: 100%; } #screenCon ...

Curating personalized designs within a content management system

Currently, I am developing a SaaS platform that will feature customized styles for user accounts. The current method involves using YAML to create unique stylesheets for each account. However, as the number of accounts increases, I am starting to question ...

Scrolling Horizontally with Bootstrap Cards

I'm trying to implement horizontally scrolling cards using Bootstrap V.5, like this: <div class="container-fluid py-2"> <div class="d-flex flex-row flex-nowrap" style="overflow: auto;"> <div cl ...

Creating a seamless and interactive online platform

I am in the process of designing a website that has a sleek and dynamic layout, rather than just a static homepage. Let me explain further: Here is my current setup so you can understand what I am trying to achieve. By dynamic, I mean that when the page ...

Set the current time to ISO8601 format

I need assistance with creating a "time passed" counter for my website based on an API call that returns data in the following format: "created_at": "2018-05-16T14:00:00Z", What is the best approach to calculate and display the time that has passed since ...

Preventing click events with pointer-events property in CSS while still allowing scrolling

Is there a way to use pointer-events: none to disable click events on a specific container while still allowing scroll functionality and an overlay? You can view my fiddle here: https://jsfiddle.net/1eu6d3sq/1/ Currently, when I apply pointer-events: non ...

Update the information within an HTML element upon clicking a menu option

Is there a way to dynamically load the content of various HTML files into a specific element on my index.html page when different menu links are clicked? This would help avoid duplicating menus across multiple HTML files and make maintenance much easier. ...

In IE9/10, the absolutely positioned pseudo element within a table cell does not fully overlay its parent

My layout includes nested div elements displayed as a table and table-cell, with each cell containing an absolutely positioned :before element that covers the entire cell. While this setup works perfectly in most browsers, I am facing an issue in IE9, 10, ...

What is a solution to prevent style.css from being recognized as the Jekyll Page?

Currently, I am utilizing an expression {% assign mypages = site.pages | sort: "order" %} {% for page in mypages %} {% unless page.exclude %} <a href="{{page.url|absolute_url}}"> {{ page.shortname }} <span class="rate">{% include indexmod.h ...

What is the best way to assign a unique ID to every element in this situation?

Here is the given code: var words = ['ac', 'bd', 'bf', 'uy', 'ca']; document.getElementById("wordTable").innerHTML = arr2tbl(2); function arr2tbl(ncols) { return words.reduce((a, c, i) => { ...

Using an inline-block within a positioned absolute element

I am curious about the behavior of inline-block elements inside absolutely positioned elements. To better explain, I have provided an example below. We can see in the code snippet why the .icon within the .tag is not displayed like the previous .icon (whic ...

Issues with implementing ng-show and ng-disabled functions in AngularJS

I am currently working on a simple demo HTML page that involves client side form validation. My goal is to incorporate Bootstrap, AngularJS, and jQuery into this project, even though I am relatively new to AngularJS. However, I am facing some issues with ...

Enhance your video with Bootstrap 4 by overlaying text and buttons

I am in search of a solution that resembles the following design, but it needs to be styled using Bootstrap 4. Here is my current code snippet: <section class="banner embed-responsive-item"> <video class="hidden-sm-down" autoplay="" loop=""& ...