The Bootstrap 4 navbar experiences content displacement when collapsed, shifting below the brand logo

My goal is to create a double navbar using the latest version of Bootstrap 4 (alpha6).

http://codepen.io/anon/pen/qrERBP

<nav class="navbar navbar-toggleable-md navbar-light navbar-inverse bg-faded" style="background-color: #000000">

    <button class="navbar-toggler navbar-toggler-right navina" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

<!-- <div class="navbar-header"> -->
    <a class="navbar-brand navina" href="/">
        <img src="/images/logow.png" class="img-fluid" alt="Responsive image">
    </a>
    <ul class="navbar-nav navina hidden-lg-up float-right">
        <img src="/images/search.png">
    </ul>
<!-- </div> -->
    <!-- <div  id="navbarNavDropdown" class="navbar-collapse collapse"> -->
    <ul class="navbar-nav mr-auto">
    </ul>
    <ul class="navbar-nav navina hidden-md-down">
        <li class="nav-item navina">
        <a class="nav-link" href="/kosik/">
            <img src="/images/kosik.png" class="img-rounded" aria-hidden="true" style="height:25px; width:25px"> Košík
            <span class="badge"></span>
        </a>
      </li>
      <li class="nav-item dropdown navina">
        <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">  <img src="/images/pouz.png" class="img-circle" style="height:25px; width:25px"><span class="caret"></span>
          Používateľ
        </a>
        <div class="dropdown-menu my-2 my-lg-0" aria-labelledby="navbarDropdownMenuLink" align="right">
            {{# if login}}
          <a class="dropdown-item" href="/user/userprofile">Tvoj účet</a>
          <a class="dropdown-item" href="/user/logout">Odhlásiť</a>
          {{ else }}
          <a class="dropdown-item" href="/user/login">Prihlás sa</a>
          <a class="dropdown-item" href="/user/signup"> Zaregistrovať </a>
          {{/if}}
        </div>
      </li>
    </ul>
    <!-- </div> -->
</nav>

When the viewport size is medium or smaller, I want the lower navbar to transform into a right-aligned burger menu on the upper navbar. The user and shopping cart icons, along with a search icon, should be positioned to the left of this burger menu.

However, when collapsing, the new icons end up below the brand element. I've tried various methods over nearly three days, but nothing seems to work, such as adding additional <button>s that stack on top of each other or playing around with floating elements and margins.

If I move the <div> elements before the <brand>, everything stacks above the Brand after collapsing.

Answer №1

Move the search icon to align with the other links on the right using ml-auto for right alignment.

<nav class="navbar navbar-toggleable-md navbar-light navbar-inverse bg-faded" style="background-color: #000000">
    <button class="navbar-toggler navbar-toggler-right navina" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <a class="navbar-brand navina" href="/">
        <img src="/images/logow.png" class="img-fluid" alt="Responsive image">
    </a>
    <ul class="navbar-nav hidden-md-down ml-auto">
        <li class="nav-item">
             <a class="nav-link"><img src="/images/search.png" alt="search"></a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="/kosik/">
                <img src="/images/kosik.png" class="img-rounded" aria-hidden="true" style="height:25px; width:25px"> Košík
                <span class="badge"></span>
            </a>
        </li>
        <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <img src="/images/pouz.png" class="img-circle" style="height:25px; width:25px"><span class="caret"></span> Používateľ
            </a>
            <div class="dropdown-menu my-2 my-lg-0" aria-labelledby="navbarDropdownMenuLink" align="right">
                {{# if login}}
                <a class="dropdown-item" href="/user/userprofile">Tvoj účet</a>
                <a class="dropdown-item" href="/user/logout">Odhlásiť</a> {{ else }}
                <a class="dropdown-item" href="/user/login">Prihlás sa</a>
                <a class="dropdown-item" href="/user/signup"> Zaregistrovať </a> {{/if}}
            </div>
        </li>
    </ul>
</nav>

http://www.codeply.com/go/ztTrZaszBU

EDIT

To always keep the extra links to the left of the toggler button, you can use flexbox utilities and margins to achieve this layout.

<ul class="navbar-nav d-flex flex-row flex-nowrap ml-auto mr-sm-5 mr-md-5 mr-lg-0">..</ul>

Updated Codeply link

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

Hover effect for Twitter-like buttons

Can someone help me figure out how to create a link control similar to Twitter's functionality? I'm referring to the way that on a tweet page, when you hover over a tweet, links appear for reply, delete, and favorite, but disappear when not hove ...

The data-tooltip feature displays information as [Object object]

There seems to be an issue with displaying text in the data-tooltip. Instead of showing the intended message, it is displaying [Object object]. import React from "react"; import { FormattedMessage } from "react-intl"; const translate = (id, value={}) = ...

Prevent issues with text overlap in HTML and CSS

My text is overlapping when I resize the window. How can I prevent this? I want the text to resize only if it collides with other elements, or stack under each other if resizing is not possible. problem I've already attempted using flex box setting ...

Ways to specify the encoding for a text iframe embedded in a webpage

Can anyone help me with document embedding in HTML? In my current project, I am directly embedding my update logs as text files into the webpage, along with a selection menu to view all the updates. However, I ran into a minor issue where the Firefox cons ...

Trouble with Bootstrap accordion staying open even after a different one is chosen

Looking for assistance! I am encountering an issue with using jQuery on Bootstrap. The accordion feature is not functioning correctly as it fails to collapse when another section is selected. https://i.stack.imgur.com/uiZPh.png The problem arises when th ...

Issue with JAWS screen reader failing to announce aria-expanded status

My aim is to ensure that the collapsed state is accessible in both NVDA and JAWS, but I am encountering issues with it displaying properly in JAWS. Does anyone have any suggestions on how to rectify this? I have included images of the code and link list b ...

Create a responsive layout of inline-block elements that adjusts to resizing

I am currently focusing on developing the website found at: The progress so far includes successfully creating a list of div.project-item elements that adjust the number of columns based on window resizing due to the use of inline-blocks. My next goal is ...

Combining various viewpoints into one cohesive SVG

Is there a way to create multiple unique perspectives within a single SVG, or replicate that effect using smart grouping techniques? I aim to display various sections of a potentially extensive SVG without the need for multiple renderings. Is there a str ...

Converting line breaks into a visible string format within Angular

After thorough research, all I've come across are solutions that demonstrate how to display the newline character as a new line. I specifically aim to exhibit the "\n" as a string within an Angular view. It appears that Angular disrega ...

What is the reason for parent rows not stretching fully across the width of the page?

I am working on creating a simple table in Vue.js with Bootstrap. When the arrow is clicked, the child row is displayed, and I want it to appear below the parent row. I achieved this by setting display:flexbox; flex-direction:column; Here is the HTML tabl ...

Having trouble grasping xPath in Selenium?

Having some HTML structures as shown below: <h4 class="box_header clearfix"> <span> <a rel="dialog" href="http://www.google.com/?q=word">Search</a> </span> <small> <span> <a rel="dialog" href="http://www.google ...

Filling Dropdown Options with Data from PostgreSQL

I've been attempting to create a dropdown list for an HTML form that is populated from a PostgreSQL table column. However, being new to this, I haven't been able to get it to work successfully. I have some code that I've been studying and tr ...

What is the best way to display the elements of an array within an HTML div element?

I've been trying to display the contents of an array in a div container on my HTML file, but I'm stuck. Here's what I currently have: function printArray() { var $container = $('.container'); $container.html(''); ...

What is the most efficient way to transmit a server-generated audio wav file to a client's web browser?

Currently, I am developing an application with Flask and need to send an audio wav file from the server side to the client. I am exploring ways to achieve this, whether by saving the wav file on disk or directly streaming it. Can anyone suggest a method t ...

Having trouble with upgrading from Bootstrap 3 to Bootstrap 4?

After upgrading from Bootstrap 3 to 4 in order to utilize the new cards functionality, I found that all of my formatting was thrown off. As a result, I reverted back to Bootstrap 3. Now, I need to display multiple images with descriptions below them in a s ...

Temporary appearance of vertical scroll bar during page load

My webpage shows a vertical scroll bar while loading, but it disappears once the page finishes loading. Any tips on how to track this issue? ...

Show PDF on an HTML webpage

I've put together my resume using latex and now I'm looking to display my pdf in a similar way to how we would add an image as a background on a webpage. The main goal is to ensure that the hyperlinks within my resume remain functional. ...

Hover over me to see the CSS animation translate upwards until it reaches a specific point

I am new to CSS animation and I am trying to create a circle that moves from one end to the other on hover. However, I am facing an issue where the circle goes off-screen when the browser size is changed. How can I make it stop at a certain point within th ...

Issue with the carousel feature displaying multiple images in Bootstrap 4.3

I attempted to create a Carousel using bootstrap that displays multiple images in a row and slides one image at a time, similar to this: https://i.sstatic.net/tw22R.png I followed this post. Instead of using bootstrap-3.3.6 and jquery-2.2.2, I used boots ...

Only the style attribute will support React CSS animations

After developing a component that changes its className based on the state, I discovered that animations only function properly when placed within the "style" attribute. In my Codesandbox project, by uncommenting line 15 in the code snippet provided, the ...