Tips for shifting icons from the left to the right when collapsing a sidebar menu

Trying to solve a challenge with the sidebar width transition! How can I move icons to the right only when the sidebar is at a width of 50px, within the specified area?

The current look:

https://i.sstatic.net/GIc4n.png

Desired outcome:

https://i.sstatic.net/LAWOj.png

$(document).ready(function() {
});
$("#menu-toggle").click(function(e) {
  e.preventDefault();
  $("#wrapper").toggleClass("active");
  
  $('#abc').addClass("d-flex flex-row-reverse");
});
#wrapper {
  padding-left: 250px;
  transition: all 0.4s ease 0s;
}

#wrapper.active {
  padding-left: 50px;
}

#wrapper.active #sidebar-wrapper {
  left: 50px;
}

@media (max-width:767px) {
  #wrapper {
    padding-left: 0;
  }
  #sidebar-wrapper {
    left: 0;
  }
  #wrapper.active {
    position: relative;
    left: 250px;
  }
  #wrapper.active #sidebar-wrapper {
    left: 250px;
    width: 250px;
  }
}

Answer №1

To resolve the issue using Bootstrap 4, follow these steps:

After the sidebar collapses, apply the following classes to the label element:

d-flex flex-row-reverse

That's all you need to do!

Additionally, for better alignment, it is advised to include these padding classes for the icon:

px-3 pt-1 (padding-horizontal 3 units and padding-top 1 unit)

Your updated label code should appear as follows:

<label class="d-flex flex-row-reverse" style="display:block"><i class="fa fa-users px-3 pt-1"></i> Administration</label>

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

Injecting dynamic content using JavaScript

My goal is to develop a web page where clicking on any of the three images will cause the content to be inserted into the empty div located above the image links. Below is the JavaScript code I'm using: <script type="text/javascript" src="js/jque ...

Using javascript to dynamically change text color depending on the selected item

I am currently working on a website for a snow cone stand and I want to incorporate an interactive feature using JavaScript. Specifically, I would like to color code the flavor list based on the actual fruit color. The flavor list is already structured i ...

Enhancing react-to-print functionality for optimal performance across various browsers and mobile platforms

Currently, I am developing a sample react-to-print resume template to be included in a larger portfolio website. While testing the page on Chrome and Edge browsers on a laptop, everything seems optimized. However, there are issues when using Firefox; the b ...

trigger a p:ajax event by employing a right-click action

Currently, I am utilizing JSF and Primefaces 5.2. A peculiar observation I made is that when a commandLink is used with the onclick event and p:ajax, it creates a selection effect. <h:commandLink id="commandLink"> <p:ajax event="click"/> </ ...

Having trouble getting the jquery ui datetimepicker to function properly in my node.js application using ejs and express

I am currently trying to implement the functionality found at this link: Below is an excerpt of my code: <html> <head> <script src="http://trentrichardson.com/examples/timepicker/js/jquery-1.7.1.min.js"> </script> < ...

using variables as identifiers in nested JSON objects

Within my code, there is a JSON object named arrayToSubmit. Below is the provided snippet: location = "Johannesburg, South Africa"; type = "bench"; qty = 1; assetNumber = 15; arrayToSubmit = { location : { type : { 'qty' ...

Is there a skilled coder available to troubleshoot this carousel's HTML code?

Hello, I am struggling with the code snippet below that uses Bootstrap to create a carousel. The next and previous buttons are not working properly. <div id="testimonial-carousel" class="carousel slide" data-ride="carousel&qu ...

When utilizing a Slick carousel with three slides and setting autoPlay to true, the slider-nav behaves as if there are five slides

I am currently using the Slick carousel plugin and I want to feature a display of 3 photos. The issue is that when I set slidesToShow=2, everything works perfectly fine, but when I try to set slidesToShow=3, which equals the total number of slides, the bot ...

Leveraging the power of AJAX for sending post requests in a Node.js Express application with

I have a newsletter section on my website that collects name and email information. I want users to be able to submit the form without reloading or redirecting the page, saving their data in MongoDB for future use in sending newsletters. It would also be c ...

Webkit browsers do not properly clip content with rounded corners when using position:relative

In webkit browsers like Chrome, rounded corners do not properly cut off content when using position:relative; Check out this demonstration. Here is the HTML: <div class="outer"> <div class="inner"> </div> <div> And here ...

Automatically scroll the page upon loading if the user is at the top of the page

Is there a way to trigger an action only when the page is detected to be at the very top, without executing it otherwise? I think maybe using an if statement could work, but I'm not entirely sure how to go about it. For instance, I'd like the pa ...

Getting the value of a file input type on an Ajax or JQuery page using PHP

When working with Ajax / JQuery to pass variable values from input fields like text, textarea, and select to a PHP process page, everything functions correctly. However, there seems to be an issue when trying to retrieve the value of an input type file var ...

The secrets of z-index: Ensuring nested elements stay behind their parent element

Check out this demo to see the problem: http://jsfiddle.net/5sqxQ/2/ I am trying to make the sub menu appear below the main menu. I also want to use JavaScript to slide the menu from underneath when hovering over the parent li element. I don't real ...

Simple method to send information from an MVC controller to jQuery.ajax

We have a project using ASP.NET MVC that involves sending form data to a controller via jQuery.ajax. Sometimes, the controller may encounter exceptions due to incorrect SQL statements. I want to catch these exceptions in a TRY CATCH block and provide detai ...

Assigning alphanumeric characters to the axis for identification purposes

review the code in index.html <!DOCTYPE html> <html> <head> <title>D3 test</title> <style> .grid .tick { stroke: lightgrey; opacity: 0.7; } .grid path { stroke-width: 0; } .ch ...

When using Codeigniter and AJAX to delete an item from a table, the page unexpectedly becomes

I successfully integrated ajax into my pagination and search functionality, which appears to be working well. However, I encountered an issue when attempting to refresh the list after deleting an item - the page would simply return blank. I am seeking guid ...

Encountering cross-domain error when attempting Google Maps API GET request

I have been working on a JavaScript function that utilizes the Google Maps places API to retrieve information. Here is the function I have written: function makeCall(url) { var data = $.ajax({ type: "GET", url: url, async: f ...

Scrolling seamlessly on websites with a single page

I am developing a single-page website that uses different section IDs instead of multiple pages. It's functioning properly, but I want to implement smooth scrolling to the sections rather than just statically jumping to them on the page. Jsfiddle: ht ...

Adjustable height for the absolute element

Having a bit of an issue with the height of the absolute div. About: .wrapper - I want the wrapper to automatically adjust its height but be limited by a max-height. (No scrolling for the wrapper) .title - Just a title .content - The problem aris ...

Detecting the scroll events of elements with the overflow:hidden property

Looking to synchronize scrolling between two different panels or divs? In one element, there's an overflow: auto while the other has overflow: hidden (trying to mimic a grid with frozen columns). I've managed to sync the scroll when it occurs w ...