Jquery vertical menu with a dynamic sliding animation from the right side to the left side

Hello everyone, I am looking to have my vertical menu slide from right to left instead of the typical top to bottom sliding that comes with using .toggle() in jQuery. Specifically, when the hamburger menu is clicked, I want the menu to slide out from right to left. If anyone has any tips or solutions, I would greatly appreciate it.

So far, I haven't been able to achieve the desired sliding effect using jQuery, as I've only experimented with the .toggle function.

.ham-menu{
    width: 35px;
    display: block;
    z-index: 2;
    position: relative;
    top: 10px;
    right: 15px;
    cursor: pointer;
}

.ham-menu .line{
    background: green;
    width: 100%;
    display: block;
    margin-top: 3px;
    height: 4px;
    border-radius: 2px;
}
.first-section{
    padding: 0;
}
.first-section .slide-menu{
    width: 20vw;
    height: 100vh;
    background-color: #000;
    z-index: 1;
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.list-menu{
    list-style: none;
    text-align: center;
    font-size: 30px;
}
.list-menu li{
    margin: 20px;
}
.list-menu a{
    text-decoration: none;
    color: #fff;
}
<div class="ham-menu">
        <span class="line"></span>
        <span class="line"></span>
        <span class="line"></span>
</div>

<div class="first-section container-fluid">
        <div class="slide-menu">
            <ul class="list-menu animated">
                <li><a href="#">Home</a></li>
                <li><a href="#">About</a></li>
                <li><a href="#">Contact</a></li>
                <li><a href="#">Footer</a></li>
            </ul>
        </div>
    </div>

Answer №1

Does this meet your requirements?

Link to CodePen

.section-one{
  display: none;
  padding: 0;
}

JAVASCRIPT:

$('.menu-button').click(function(){
  $('.section-one').toggle();
})

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 value of ajax data at index 0 is not defined

When using AJAX to retrieve the number of rows from a SQL query in PHP, the JSON return shown in the Firefox Network tab is [{"number":2}], with the number 2 being without quotes. However, when trying to access the value (2) using data[0]["number"] or dat ...

Attempting to transfer information from a JSON file to a Netflix-inspired platform

Images I am currently working on integrating data from my json file export const products = [ { name: 'iPhone 11', image: '/assets/images (7).jpeg', time: '1 hour 14mins', age: '+16&apo ...

Convince me otherwise: Utilizing a Sinatra API paired with a comprehensive JS/HTML frontend

As I embark on the journey of designing a social website that needs to support a large number of users, I have come up with an interesting approach: Implementing Sinatra on the backend with a comprehensive REST API to handle all operations on the website ...

Utilize Angular functions in every controller in your application

Currently, I have important functionality code within app.run(function... in Angular: app.run(function($rootScope, $window) { // Obtain window dimensions $window.width = angular.element($window).width(); $window.height = angular.element($window).he ...

Highly complex regular expressions in nth-check causing inefficiencies during npm installation of react-router-dom

Feeling new and inexperienced with how to react, I attempted to execute the command "npm i react-router-dom" but it ended up stopping the download process and displaying several errors. In my search for a solution, I stumbled upon this reference to some ...

Challenges I'm Facing with my Vue.js API Integration using axios

I am currently working on a bookstore application using Vue.js. The book data is stored in this API . However, I am encountering issues displaying the information on my HTML page with the provided function and I am struggling to identify the root cause: ...

two adjacent elements filling the entire height of the window at 100% dimensions

Is there a way to place two elements side by side, with one of them (the textarea) always being 100% height of the window? I've looked at similar questions here but can't figure out how to make it work. Can you help me with this? html: <div ...

"Preload the search query from the table, link it, and then send it to Ajax for

Currently, I have a dynamically generated table using ajax and a json file. The table consists of three segments: name, ID, and a link for more detailed information on each result. Here is an example of how the table looks: PATO:0001243 light blue ...

Inquiring Mind: jQuery Box

I am using a jQuery boxy plugin to display my captcha overlay: <script> $(document).ready(function() { var zahl1 = Math.floor(Math.random()*11); var zahl2 = Math.floor(Math.random()*31); //$("#cap").html("Wie viel ist "+zahl1+" + "+z ...

Creating HTML or PHP pages using jQuery

Is it possible to generate a file using jQuery? I am creating a website maker. On the left side, I have a list of elements such as: ---------------------------------------------------------------- Elements Attri ...

personalize auto-suggestions in AngularJS

Here is a link to a custom search implementation using autocomplete in angularjs. Is it possible to modify this so that the matching starts from the first character? HTML <div ng-app='MyModule'> <div ng-controller='DefaultCtrl& ...

Having trouble implementing min and max date validation in Angular UI-Bootstrap datepicker with UI-Bootstrap version 1.3.3

My goal is to implement validation in my datepicker, preventing the user from selecting a date within 30 days before or after the current date. Here's the code snippet I'm currently using for the datepicker: <div class="form-group" ng-class=" ...

Vue.js is displaying API data in the browser's console, but it is not appearing on the webpage

I am currently learning about API design and attempting to make an API call that retrieves data from an online API server using the vue.js project through CLI. While I can see the results in the browser console, I'm encountering issues with displaying ...

Tips for ensuring a custom list item remains at the top when the screen size decreases

My unordered list with custom bullets is displaying some unexpected behavior. When the screen size drops below 364px, the list items wrap to two lines. However, the custom bullet ends up on the second line instead of the first. How can I fix this for smal ...

Obtain a collection of strings from an array of objects based on specified criteria

What is the most efficient method to extract an array of specific strings from an array of objects, where a certain condition needs to be met? Solution Attempt: const array = [{ "Item": "A", "Quantity": 2 ...

"Utilizing d3 to parse and track variables within JSON data

To calculate the number of occurrences of s1, s2, and s0 in JSON data and use this information to plot a multiline chart with date (path of date is as follows reviews_details>>variable vf of JSON) on the X-axis versus the number of reviews (s1/s0/s2 ...

Tips for changing the color of MUI TextField in React.JS?

Is there a way to customize the color of the TextField frame? It always shows up as black, making it hard to use in dark mode. I am looking to change the color of both the label and the input line. return ( <div align="center" ...

Tips to successfully save and retrieve a state from storage

I've encountered a challenge while working on my Angular 14 and Ionic 6 app. I want to implement a "Welcome" screen that only appears the first time a user opens the app, and never again after that. I'm struggling to figure out how to save the s ...

Tips for locating the initial <body .....> tag within a text using PHP?

Struggling with the preg_match function, especially when it comes to finding the first body tag. I've attempted to locate the tag in various formats: <body class="blah"> <body style="blah: blahblah;"> <body> Successfully found the ...

How to retrieve the button value in HTML

One of the HTML components I am working with is a button that looks like this: <button>Add to cart</button> My goal is to retrieve the text within the button, which in this case is "Add to cart." To achieve this, I need to extract this value ...