small screen right-side navigation with Bootstrap 4

My goal is to have the logo image on the left and the navigation on the right for xs devices, and the logo in the center with navigation on the left for sm devices. However, I am facing an issue where the navigation does not align to the right on xs devices.

The challenge at hand is: How can I align the navigation to the right on xs devices?

<div class="container-fluid border-bottom">
<div class="row d-flex align-items-sm-center">
<div class="col-6 col-sm-2 logo pt-2 pb-2 text-sm-center order-sm-2"> <img src="myimage.png"> </div>
<div class="col-6 col-sm-5 order-sm-1">
  <nav class="navbar navbar-expand-lg navbar-light">
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup"
        aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button>
    <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
      <div class="navbar-nav"> <a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a> <a
                class="nav-item nav-link" href="#">Azienda</a> <a class="nav-item nav-link" href="#">Prodotti</a> <a class="nav-item nav-link disabled"
                    href="#">Cataloghi</a> </div>
    </div>
  </nav>
</div>
<div class="d-none col-sm-block col-sm-5 order-sm-3">&nbsp;</div>
</div>
</div>

Answer №1

If you're looking to make the layout responsive, you can use the flexbox utility classes like

justify-content-end justify-content-sm-start
...

<div class="container-fluid border-bottom">
    <div class="row d-flex align-items-sm-center">
        <div class="col-6 col-sm-2 logo pt-2 pb-2 text-sm-center order-sm-2"> <img src="//placehold.it/130x40"> </div>
        <div class="col-6 col-sm-5 order-sm-1">
            <nav class="navbar navbar-expand-lg navbar-light justify-content-end justify-content-sm-start">
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button>
                <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
                    <div class="navbar-nav align-items-sm-start align-items-end"> 
                    <a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
                    <a class="nav-item nav-link" href="#">Company</a> 
                    <a class="nav-item nav-link" href="#">Products</a> 
                    <a class="nav-item nav-link disabled" href="#">Catalogs</a> 
                    </div>
                </div>
            </nav>
        </div>
        <div class="d-none col-sm-block col-sm-5 order-sm-3">&nbsp;</div>
    </div>
</div>

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

instructions for creating a hover effect where one div vanishes when hovering over another div

Is there a way to make the line visible when hovering over my circular div? #line { display: none } <div id='circle'> <div id= 'line'> ...

What are the best strategies to prevent text from appearing jumpy while fading in word by word?

I'm struggling to create a smooth fade-in effect word by word without causing the first word to suddenly jump to the left when the second word appears. To better explain my issue, I've provided a jsfiddle link: http://jsfiddle.net/6czap/504/ If ...

WordPress does not allow self-referencing within the same site

I am currently working on a wordpress site and I am trying to create a link that directs to a specific section on the same page. This is the code I am using: <a href="#offer" target="_self">test</a> And here is the code for the landing secti ...

Overlapping Bootstrap cards conundrum

Does anyone know how to align Bootstrap cards and make them responsive? I have them centered, but they are overlapping and sticking to the left side. This is for email development with a maximum width of 680px. Any assistance would be greatly appreciated! ...

Finding the current HTML page URL in Ionic 2: A step-by-step guide

Can the URL of the current HTML page be obtained and then converted to PDF using the cordova-pdf-generator package? ...

Transfer the data from a post request through routes following the MVC pattern

Encountering an issue when attempting to submit a post form with username and password, as an error stating Cannot POST /validateUser is displayed. The structure of my form is as follows: <!DOCTYPE html> <html> <head> <title> ...

Aligning content within a table cell using the Div tag

I am struggling with a <td> that looks like this: <td valign="middle" class="table_td td top" style="width: 347px"> <div id="Style" style="position:absolute;"> <img src="images/additional-keywords-image.gif" style="background: ...

OptinMonster's innovative feature - the Pardot form with an inline button

Having trouble integrating an HTML Pardot form into OptinMonster's floating footer option. I'm looking to align all three fields inline, along with the button. Can anyone assist me in placing the button inline with the fields? HTML: <fo ...

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(), ...

Is it common for the `col` class in Bootstrap 4 Grid System to have no padding?

This is my first time using Bootstrap version 4. Currently, I have a footer that utilizes the new flex col classes. It looks great on desktop, but on mobile, the columns are stacked so closely together that there is no vertical margin or padding. Is this ...

Adjust the size of the buttons based on the width of the screen

I have successfully implemented a dropdown menu with both text and an icon. However, I am now faced with the challenge of removing the text while retaining the icon when the screen width is reduced to a maximum of 768px. Is it possible to modify the conten ...

I wish to substitute a form field with a different one once the value of another field matches a specific condition

The issue I'm facing is that the field disappears once "US" is chosen and does not revert back to the options when another choice is made. teacher_signup.html {% block content %} <h2>Sign Up As Teacher</h2> <form method="post> ...

Hover over the image to reveal sliding text

I am attempting to incorporate a CSS3 hover effect into my images, where hovering over an image will cause some text to slide up on a white background. However, I have encountered issues with conflicting code, as I also have overlay text and a 'new&ap ...

Achieving full width for the elements in a row with Flexbox: A step-by-step guide

I am dealing with a flexbox grid that contains random width images: https://i.stack.imgur.com/pfPeU.jpg I want to stretch the elements in each row to full width to eliminate any white space - Is there a way to achieve this using CSS? justify-content do ...

CSS-only countdown animation

I've been experimenting with a pure HTML/CSS countdown animation, but I'm facing challenges in getting it to run smoothly. Currently, I'm focusing on minutes and seconds only. One issue I encountered is that the digit representing tens of mi ...

Error: Code cannot be executed because the variable "sel" has not been defined in the HTML element

Every time I try to click on the div, I encounter an error message stating 'Uncaught ReferenceError: sel is not defined at HTMLDivElement.onclick' I am currently developing with Angular 8 and this error keeps popping up. I have read through simil ...

iOS devices are experiencing issues with touchstart and touchend events not functioning when utilizing jquery mobile and cordova

During a previous project, I encountered no problems with the following code snippet. It effectively utilized touchstart and touchend events to adjust the CSS of a button: <script> $('input[type="button"]').on('touchstart', func ...

There seems to be an issue with the border displaying correctly within the div element

I am currently working on developing a tag input system, but I am encountering some CSS issues. What I am aiming for is to have a green border that surrounds and contains the 2 divs inside it, however, this is not happening as expected. You can see the fi ...

Lose the scrollbar but still let me scroll using the mouse wheel or my finger on the fullscreen menu

I am currently working on a fullscreen menu design. However, when the menu appears, some elements are not visible unless I apply the overflow-y: scroll property to the menu. But I don't like the appearance of the additional scrollbar that comes with i ...

Difficulty encountered while implementing a carousel using HTML, CSS, and JavaScript

I'm currently working on creating a carousel using only HTML, CSS, and JS. While it is functional, it does not perform as smoothly as I had anticipated. After completing one full round of images, there is an approximate 8-second delay before it star ...