Issue with left transition (in menu) not functioning as expected

I am facing an issue with the transition effect on my menu. To see the problem, you can visit www.glennvanroggen.nl

When using jQuery and clicking #show, it should toggle the class .menu_out on .menu.

 $(document).ready(function(){
        $('#show').click(function(){
            $('.content').toggleClass("content_out");
        });
        $('#show').click(function(){
            $('.menu').toggleClass("menu_out");
        });
    });

However, I have noticed that the transition is not functioning as expected. The menu moves to the left without any transition effect. Strangely, adding an opacity transition worked fine. I am puzzled by this behavior.

.menu {
    position: fixed;
    left: -200px;
    width: 200px;
    height: 100%;
    bottom: 0;
    border-right: 1px solid #F0D4B0;
    background-color: #002129;
    -webkit-transition: left 0.3s ease-in;
    -moz-transition: left 0.3s ease-in;
    -o-transition: left 0.3s ease-in;
    -ms-transition: left 0.3s ease-in;
    transition: left 0.3s ease-in;
    -webkit-transition: background-color 5s ease-out;
    -o-transition: background-color 5s ease-out;
    -moz-transition: background-color 5s ease-out;
    -ms-transition: background-color 5s ease-out;
    z-index: 2;
    -webkit-transition: opacity 0.4s ease-in;
    -moz-transition: opacity 0.4s ease-in;
    -o-transition: opacity 0.4s ease-in;
    -ms-transition: opacity 0.4s ease-in;
    transition: opacity 0.4s ease-in;
    opacity: 0.2;
}

.menu_out {
    left: 0px;
    width: 200px;
    height: 100%;
    border-right: 1px solid #F0D4B0;
    background-color: #002129;
    z-index: 2;
    opacity: 1
}

Below is the HTML structure:

<nav class="menu">
    <div id="show">
        <p>Menu</p>
    </div>
    <div id="profile">
            <img src="images/glenn.jpg" alt="my face"/>
            <p>where dreams come true.</p>
        </div>
    <ul>
        <li><a href="index.html">Me</a></li>
        <li><a href="work.html">Work</a></li>
        <li><a href="love.html">Love</a></li>
        <li><a href="contact.html">Contact</a></li>
    </ul>
</nav>

I'm hopeful that someone can assist me in resolving this issue. Thank you for your help in advance!

Answer №1

You have defined 2 transitions, with the second one (opacity) taking precedence over the first. To include multiple transitions, use this syntax:

transition: opacity 0.4s ease-in, left 1s ease-in;

Alternatively, you can use 'all' when the transition is the same for all modified properties:

transition: all 0.4s ease-in;

(Remember to add vendor prefixes as needed)

Make sure your JavaScript code looks like this:

$('#show').click(function(){
    $('.content').toggleClass("content_out");
    $('.menu').toggleClass("menu_out");
});

Check out the LIVE DEMO here

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

How to vertically center an image and text in a div using Bootstrap 4

Bootstrap 4: Is there a way to horizontally center a div that includes both an image and text positioned to the right of the image? +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | Heading ...

Prevent the form submission when both of these values meet the required criteria

Hi, I have implemented code to validate IDs entered in two input fields on my form. The code is working correctly, but I am facing an issue with stopping the form from submitting if both fields are not valid. Currently, I disable and enable the submit bu ...

Load an external script once the page has finished loading by leveraging the power of $(document).ready() in conjunction with $.getScript()

Is it possible to load a script in the header of a website instead of at the bottom? I've been trying but it's not working as expected. Here is an example of what I'm attempting: HTML file: <!DOCTYPE html> <html lang="en"> < ...

Implementing Jquery after async ajax refresh in an asp.net application

My ASP.net page is heavily reliant on jQuery. Within this page, I have a GridView placed inside an UpdatePanel to allow for asynchronous updates. <asp:GridView ID="gvMail" runat="server" GridLines="None" AutoGenerateColumns="false" ...

Using TypeScript, you can replace multiple values within a string

Question : var str = "I have a <animal>, a <flower>, and a <car>."; In the above string, I want to replace the placeholders with Tiger, Rose, and BMW. <animal> , <flower> and <car> Please advise on the best approach ...

What is the best way to create a horizontal line above a div to serve as a home bar?

.topbar { background-color: white; position: fixed; margin: -10%; z-index: 10; height: 10%; width: 110%; } I have created this code for a div element, intending it to serve as a navigation bar on my website. My goal is to include an orange line at the top ...

Issue with global variable not being properly assigned within the AJAX success function

Check out this snippet of code: I'm currently utilizing the Jamal framework. Event: { getEvents: function(){ var events; $.ajax({ type: "POST", url: anchor("Events/getEvents"), ...

When utilizing var_dump in PHP, the SQL query may return an empty array with an output of array(0

I am puzzled as to why my Query is not retrieving any data, despite its title My JQuery: $(".output").click(function() { var noteid = $(this).data("noteid"); $("#right-box").load("connectionDetails.php", { noteid: noteid }); }); My connectionDet ...

Ways to control the number of boxes that are checked

I am currently working on a script to restrict the number of checkboxes that can be checked, but I am encountering an issue where the script is disabling all checkboxes on the page. Is there a way to only disable a specific checkbox within a certain div? ...

What is the best method for aligning forms vertically within a page layout?

I'm working on designing a contact form, but I'm having trouble getting everything to align properly. Specifically, I can't seem to get the form elements to line up vertically and I also want the Message label to appear on the top left side ...

Tips for combining two server-side forms on a single ASP.NET web page using C#

Looking to create an HTML page with two server-side forms - any suggestions on how I can achieve this or is there another approach I should consider? Thank you. (Let me know if you need the code). ...

I am curious if there is a wysiwyg web editor extension specifically designed for VS2010 available?

In my experience, I have been working with C#, HTML coding using VS2010 and MVC. Utilizing VS2010 has proven to be an invaluable tool for me in this process. Currently, I find myself needing to create some straightforward static web pages. I am wondering ...

What is the reason behind Chrome's fullscreen mode turning the background black?

I created a webpage with full-screen functionality and made sure to use the correct CSS properties to ensure that my gradient background covers the entire screen perfectly. However, I encountered an issue when clicking the full-screen button in Chrome - th ...

Guide to displaying a function result in Vue 3

I have just started learning vue js and I am facing an issue. I want to display the value returned by the following function in a table row: The function is: getGroup(id){ this.users.forEach(element =>{ if(element.id===id) ...

Using Jquery to assign negative values in CSS styling

Here is the jQuery code snippet I am working with: <script type="text/javascript" src="js/jquery.js"> </script> <script type="text/javascript"> $(document).ready(function() { get_font_size(); set_sidebar(); }); function get_f ...

Obtaining an identification using JQuery for content that is constantly changing

I am currently developing dynamic content tabs using PHP, with one of the objects being a datatable within the tab. In order to define the ID via PHP, I use the following code: PHP: echo '<table class="table table-striped table-bordered table-hov ...

Does applying a style to an element that already has the same value result in a decrease in performance? Alternatively, do all browsers simply overlook it?

Assuming I have an element with the style top: 5px, and then I execute element.style.top = "5px";, will the browser readjust its position and trigger a layout again? Or does it recognize that there is no need to change anything? (Is this behavior specified ...

Should we pause JQUERY AJAX to prioritize usability, or only when absolutely necessary?

I am struggling with my LoadingStatus Function, which has two options: SHOW and HIDE. When a JQUERY POST is made, the Show option triggers to display, while the HIDE option occurs after the RESPONSE comes back. The problem I'm encountering is that s ...

What is the best way to customize the width of the navigation tool bar for iPhone and iPad devices

I need assistance with adjusting the navigation toolbar on my webpage for both iPhone and iPad. Currently, the toolbar displays correctly on iPad but only shows two hyperlinks on iPhone 6 screen. How can I resize the navigation bar to ensure all hyperlinks ...

Optimizing HTML/CSS performance: Comparing flexbox and tables for handling extensive datasets

Creating a React table component with hundreds of lines and variable cell widths can be complex. Would it be better to implement this using flexbox or a traditional table structure in HTML/CSS? ...