What is the best way to make a hamburger menu appear on the right side of the screen?

After working tirelessly on converting one of our websites to be mobile-friendly, I've hit a roadblock. While the standard approach is to place the hamburger menu on the left and have the content slide to the right, I'm interested in doing the reverse. Despite following a helpful tutorial on hamburger menus for mobile sites and implementing the necessary changes in the JS and CSS files, nothing seems to be functioning properly.

In my JavaScript file, I adjusted the code as follows:

//Animate margin for the entire container using jQuery UI
    jQuery("#container").animate({ "marginRight": ["70%", 'easeOutExpo'] }, {
        duration: 700
    });

//Animate margin for the whole container back to its original state with a jQuery UI animation
    jQuery("#container").animate({ "marginRight": ["0", 'easeOutExpo'] }, {
        duration: 700,

In the CSS file, I simply switched any rules that had "right: 0;" to "left: 0;" and vice versa. However, despite seemingly functional code when debugging in Firebug, the content doesn't slide to the left on the site. Any assistance or advice would be greatly appreciated!

Answer №1

Understanding the script can be challenging, but I have attempted to decipher it. Here are the necessary modifications:
Additionally, please note that there is no marginRight option in jQuery animate.

Replace:

//set margin for the whole container with a jquery UI animation
jQuery("#container").animate({ "marginRight": ["70%", 'easeOutExpo'] }, {
  duration: 700
});

with:

jQuery("#container").animate({"marginLeft": ["-70%", 'easeOutExpo']}, {
  duration: 700
});

In the CSS:
Look for #hamburger
Change float:left; to float:right;

Locate the nav element
Replace left: 0px; with right:0px;

EDIT: Replace left: 0px; with right:-20px;
updated working fiddle

Lastly, find #contentLayer
Replace right: 0; with left:0;

Here is the working jsfiddle link, enjoy the changes

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

The excessive load time of my ajax request within a for loop is causing delays when calling a php file

My Ajax request is taking a long time to load as I'm calling the ajax function from 1 to 3000. It queries the database for each value and returns if the value exists in the database. function GetData(id) { id = id; jQuery.ajax({ type: "GET", ...

Difficulties with toggling jQuery menus

I am trying to create a sidebar that will appear with a full screen fade over the entire page when I click on the 'navigate' text. Currently, the sidebar appears and my header text moves to the left. However, I am struggling to make it responsiv ...

Customizing GTK with CSS: Altering button background color on click event

Currently I am working on creating an application using GTK and styling it with CSS. One of the requirements is to change the background of a button when clicked, specifically for a built-in video player. The desired behavior is to have the 'play&apos ...

What is the best way to use jQuery to smoothly transition the current scroll position to a desired target scroll position?

I am looking to incorporate scroll animation into my block. The goal is for the block to smoothly scroll from its current position on the page to a specific target position. I am familiar with the .animate() method in jQuery, but I have not come across ...

Issue with a Bootstrap panel displaying incorrect border formatting

I am currently working with Angular UI Bootstrap and facing an issue with an accordion component. Everything works perfectly fine in the development environment with the full version of the Bootstrap Cerulean file. However, when I minify the CSS file for p ...

steps for setting up an endless scroll masonry grid

I have incorporated masonry js to display content on my website. Now, I am interested in adding infinite scrolling functionality using this script. I came across a demo that showcases this feature. However, I am struggling to figure out how to implement ...

A guide on wrapping text within a Material-UI MenuItem

I am struggling to display text in a popover in multiple lines for UI reasons. I have tried updating the code but so far, I have not been successful. Any suggestions? <Popover anchorEl={target} open={open} anchorOrigin={{ horizontal: 'middle& ...

Having trouble with the image resizing in Bootstrap 5 on Safari?

I am facing an issue with a website: There are four images under the section "Serviceangebote" that appear as square icons representing circles. I have no trouble viewing them correctly on Windows (Chrome, Firefox, Edge) and Android devices. The images ar ...

The Ajax request is functioning perfectly, but only on the index page

Utilizing a mobile app template within the Framework7 framework for Cordova app development requires making ajax requests on each page to fetch data from a PHP web service. While an ajax request in index.html functions properly, replicating the same reques ...

Avoid automatic semicolon insertion in Visual Studio Code

Currently, I am utilizing Visual Studio Code for my coding tasks. I specifically do not prefer the auto insertion of semicolons after CSS properties by VS Code. However, it keeps providing me with an autocomplete option that I find undesirable. Is there a ...

Is there a way to confirm that a file has been chosen for uploading prior to form submission, by utilizing the jquery validator?

I have a section on my website where users can upload files. I am trying to implement validation to ensure that a file has been selected before the form is submitted. Currently, I am using the jQuery form validator plugin for handling form validations. Th ...

I need assistance organizing a set of cards on a webpage using Bootstrap 4. Can you help me with this task?

Looking for assistance in organizing cards on a web page using Bootstrap 4. Can anyone lend a hand? <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4I ...

What is the best way to connect this image and comments div using only CSS?

I'm trying to ensure the comments div is the same height as the image above so they can be aligned side by side. Below is my current code: <div class="main_image_wrapper"> <img class="main_image" src="*dynamic generated image*" style="ma ...

Tips for adding a border to a table cell without disrupting the overall structure of the table

Looking for a way to dynamically apply borders to cells in my ng table without messing up the alignment. I've tried adjusting cell width, but what I really want is to keep the cells' sizes intact while adding an inner border. Here's the sim ...

The script functions perfectly in jsfiddle, yet encounters issues when used in an HTML

I stumbled upon a seemingly peculiar issue with my script in jsfiddle: https://jsfiddle.net/oxw4e5yh/ Interestingly, the same script does not seem to work when embedded in an HTML document: <!DOCTYPE html> <html lang="en"> <head> & ...

I'm feeling overwhelmed by trying to send data from Jquery to php and then successfully retrieving the data

Here's the HTML snippet I'm working with: <form action="http://localhost/xiuno" method="post"> <h1>TEST</h1><br/> <input type="submit" value="submit" id="submit"/> </form> <script type="text/javasc ...

Turn off padding in material ui card

Currently, I am utilizing a material UI card and upon inspecting the card, I noticed the presence of this unique class: "MulticardContent-root". This class adds padding of 16 which I would like to remove. Strangely, it is not located within the styles co ...

Joomla website layout using Bootstrap columns set to MD-6 but not contained within a single

I seem to be experiencing an issue with Joomla SP page builder. After creating a row and adding 2 columns MD-6, they are not lining up properly in one row. Any assistance would be greatly appreciated. You can view the issue at: Here is a screenshot of t ...

Interactive phone photo gallery

I am looking to create a mobile webpage that allows me to swipe my finger left or right in the middle of the page to scroll between images. Here is an example photo: I want to be able to swipe through the images with my finger. Any suggestions on how I ...

position the div correctly above the table

I am currently working on creating a scheduler that has specific requirements: Show the working hours for each resource Show the interviews, allow changing the interview duration by resizing, and move the interviews using drag-and-drop functionality. I ...