Switch the Bootstrap navigation bar orientation from left to right

Can anyone help me create a navigation bar like the one shown in this image? It needs to toggle from right to left with a close button. I've tried everything and searched everywhere with no luck. Thanks in advance! Link to Image

Answer №1

Consider implementing a navbar similar to this

$(document).on("click", "#hide-navbar, #show-navbar", function() {
  $("#navbarsExample04").toggleClass("d-none");
  $("#hide-navbar").toggleClass("d-none");
  $("#show-navbar").toggleClass("d-none");
})
.navbar-collapse.collapse.d-none,
#hide-navbar.d-none,
#show-navbar.d-none {
  display: none !important;
}

.navbar-expand #show-navbar.navbar-toggler {
  display: block;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js" integrity="sha384-o+RDsa0aLu++PJvFqy8fFScvbHFLtbvScb8AjopnFD+iEQ7wo/CG0xlczd+2O/em" crossorigin="anonymous"></script>
<script src="https://use.fontawesome.com/eed659c9d4.js"></script>

<nav class="navbar navbar-expand bg-transparent">
  <a class="navbar-brand" href="#"><img src="https://picsum.photos/50/30"> ABC</a>


  <div class="navbar-collapse collapse" id="navbarsExample04" style="">
    <ul class="navbar-nav ml-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>

    </ul>

  </div>
  <button class="navbar-toggler d-block ml-auto" type="button" id="hide-navbar">
    <span class="fa fa-times"></span>
  </button>
  <button class="navbar-toggler d-none ml-auto" type="button" id="show-navbar">
    <span class="fa fa-bars"></span>
  </button>
</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

Steps for smoothly transitioning an element into a row and animating its neighboring elements to adjust their width using VueJS

Is there a way to smoothly slide-in an element in a row and have the other elements adjust their widths accordingly while maintaining their relative sizes? <div style="width: 100%; display: flex"> <div id="firstColumn" ...

Issue with the close button formatting in the React Bootstrap 4 modal window

In my quest to create a modal window in ReactJS using Bootstrap 4, I encountered an issue with CSS formatting for the close button. Interestingly, Bootstrap 3 worked fine with the CSS. You can check out my code here. Any advice would be greatly apprecia ...

ToggleButtonGroup in Material UI is a great way to create toggle

I am trying to implement the ToggleButtonGroup feature from Material UI in my React application. I am facing an issue where I am unable to pass values into my state correctly. The code snippet provided below shows that while the Select component works fi ...

The submit button is getting disrupted by the background image being set

Implement the following CSS code to set a background image on a single-page app (Angular). .page::before { content: ''; position: absolute; background-size: cover; width: 100%; height: 100%; background-image: url("../../assets/weird. ...

show information on a separate screen following the selection of a choice

After selecting an option, how can I make #formid appear where the form is filled in with the stock selected in the option section? <div class="form-group"> <label for="exampleFormControlSelect1">Item Name</label> <select clas ...

Cease the act of sending submissions through JavaScript ajax requests

I need to prevent a form submission based on the result of an ajax request... Here is the code I attempted to implement: The chreg() function is supposed to return a boolean value from the ajax request, but it's not working! Javascript: function ch ...

Tips for adjusting an @media css for a material-ui react component

After posting this inquiry about overriding a CSS property in a material-ui component, I received a helpful example. However, I encountered difficulty when attempting to set the height of the Toolbar component due to an overarching @media specification. My ...

What is causing the navigation bar items to shift with the logo when attempting to position it to the left?

Whenever I attempt to shift .logo to the left, it also drags all the other navbar items (Home, Features, Pricing, Disabled) along with it. All I want is for .logo to move to the left without affecting the positioning of the other navbar items. I should me ...

Perform a bash command using PHP when an HTML button is clicked

Today, my brain seems to be on vacation. Currently, I have set up a Raspberry Pi with vlc running and connected to a mounted screen on the wall. There is a web page with simple controls to manage the pi, switch between different vlc streams, or stop stream ...

Encountering a JavaScript error due to an erroneous character when trying to parse

I need to convert a `json` string into an object format that is extracted from a `.js` file. Here is the `JSON` string located in `document.js`: [ { "type": "TableShape", "id": "63c0f27a-716e-804c-6873-cd99b945b63f", "x": 80, ...

How to position a "figure" element at the center using CSS creatively (without relying on Div elements)

Struggling with my first website creation, I encountered a challenge in centering three inline-block images using CSS. Despite successfully using the figure tag to title and display the images, I couldn't get them to align horizontally from the cente ...

The HTML Style for implementing HighChart title text does not work when exporting files

I have inserted the <br/> and &nbsp; HTML tags into the HighChart titles. The style changes successfully appear in the chart view, but unfortunately, when exported as PNG or JPEG images, the text style fails to apply in the resulting images. To s ...

How come my MySQL date is decreasing by one day when using JavaScript?

My todo list is stored in a MySQL database with columns for todoTitle and todoDate. However, when I display the todoDate on my website, it shows the date decremented by one day. For example, if the date in the database is 2016-12-20, it will show as 2016-1 ...

The erratic nature of Tailwind actions

Currently, I am immersed in a Livewire project and attempting to implement some Tailwind theme configurations. However, the process does not appear to be coherent whatsoever. Here is an excerpt of my Tailwind configuration: theme: { extend: { f ...

Using jQuery to retrieve the ID of a <td> element within an entire table

I'm attempting to retrieve the id of a specific table cell within an entire table structure. For instance, <table> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> & ...

Transition color seamlessly from the left side to the right side upon hover

Here is a simple code snippet for creating a line that changes color on hover: li::after { height: 2px; display: block; background: rgb(195, 195, 195); border-right: 1px white; content: ''; } li:hover:after { position: relative; ...

How come my web page is not displaying the guages from guage.js?

I am utilizing guage.js to create a graph based on this Fiddle. However, upon adding the same code to my website, the rendering does not appear as expected: https://i.sstatic.net/fIkQr.png Upon inspecting in Chrome developer tools, I noticed that the ele ...

Issue with nivo-lightbox not opening upon clicking image

I have diligently followed the instructions to set up this JavaScript plugin, but unfortunately it doesn't seem to be functioning properly. The plugin I'm using can be found here: All the links to the CSS, theme, and JavaScript files are display ...

How can you position an image and text side by side without specifying the width using a div?

Having some trouble aligning an image (which is contained in a div) and some text (also in a div) on the same line without setting a width for the text. Here's what I've tried so far. <div id="container"> <div id="image" style="flo ...

Leveraging the powerful Google Maps API to enhance your mapping experience with

After making updates to my code, I managed to keep the Map intact while adding a script to place markers. Unfortunately, the step to add markers is not functioning properly. The data with coordinates is fetched from SQL, converted to JSON using C# and then ...