Animate a lone div once and for all

I'm attempting to create a vertical category menu similar to the one on . I've successfully implemented the vertical menu with transition effects. However, my issue is that I only want the transition to occur the first time a category is clicked. Subsequently, I want all elements within the category to open without any transition.

#header .header_section .header_content .header_right_part .search_bar_part .category_part .category_main_box .category_info_part {
    /* width: 75%; */
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    background-color: rgba(246, 212, 160, .9);
    /* transform: translateX(-100%); */
    /* opacity: 0; */
    visibility: hidden;
    transition: all 0.5s;
    transition-duration: 0.5s;
    z-index: -1;
    left: 25%;
    overflow: hidden;
    width: 0;

}


 #header .header_section .header_content .header_right_part .search_bar_part .category_part .category_main_box .category_left_list > ul > li:hover .category_info_part{
    display: block;
    /* transform: translateX(0%); */
    /* opacity: 1; */
    visibility: visible;
    overflow: hidden;
    width: 863px;
}

Currently, the transition effect applies to all elements within the menu. My goal is for the transition to only occur on initial click, and then stay static. Is there a way to achieve this? Thank you in advance.

Answer №1

To utilize JavaScript, you have the ability to modify classes of specific elements (find instructions here and here).

My suggestion is to define all transition information within a designated class:

.transitionOn {
  /* include all properties relevant for the desired transition effect */
}

This approach allows you to implement an onclick event to remove the transitionOn class from elements where you no longer want the transition effect applied. To ensure the transition completes before removal, consider adding a timeout.

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

active option in Opencart 2.1 is set to "selected"

I've implemented the AJAX module d_quickcheckout to speed up the checkout process on opencart 2.1 (not the default one). However, I'm encountering an issue with a field in the payment address section that is always pre-selected with the region/st ...

Tips for maintaining the position of items with absolute positioning while resizing:

Hello, I am seeking help with an issue in my code. My problem is as follows: I have two items and one frame. The frame has a position relative to the two items (children) which have positions set to absolute. Ideally, these children should always remain ...

Endless repetition in Angular with ng-bind

After multiple attempts, I have not been successful in getting my get_tracking() function to properly return an object with the summary property. In order to resolve this issue, I am seeking a solution to either bind the summary property to the pack object ...

quickest method for attaching a click listener to dynamically added elements in the document object model

When adding multiple elements to the DOM, how can we ensure that these elements also have a click handler attached to them? For instance, if there is a click handler on all elements with the "canvas-section" class, and new "canvas-section" elements are con ...

extracting URL parameters using AJAX

I have successfully created an AJAX request using the GET method, passing variables to the URL and receiving a response. Now, I need to retrieve the current URL variables by clicking on a newly created button in order to proceed with further processing. Th ...

CSS - Help! Seeing different results on Internet Explorer

I'm currently handling an OSCommerce website, and I'm trying to figure out why this issue is occurring. You can view the website at this link: The layout looks completely different on Internet Explorer, and I'm puzzled as everything should ...

Enhancement from the original JavaScript class framework created by John Resig

Greetings everyone, Lately, I've been on the lookout for a straightforward JavaScript class framework that focuses solely on basic inheritance. After some research, I stumbled upon John Resig's sample framework shared on his blog, and it seems t ...

I'm having trouble getting my Bootstrap Navbar list aligned in the center

I've been attempting to align my menu list items in the center of the bootstrap navbar but have had no success. Despite trying various CSS styles, the items remain on the left side. Please take a look at my HTML and CSS below and let me know if there ...

Creating a function in AngularJS to select all checkboxes

I recently started working with Angular and I implemented a select all checkbox that checks all the boxes using ng-model/ng-checked. <th> <input type="checkbox" id="selectAll" ng-model="selectAll"/> </th> <th ...

Switching between Login Form and Register Form in VueJS template

Recently, I attempted to switch between the 'Login Form' and 'Register Form' using code that I found on codepen Flat HTML5/CSS3 Login Form. While the code functioned properly on its own, when integrated into a Vue Template, the form fai ...

The mobile-responsive dropdown navigation bar functions well on browsers with small widths, but does not work properly on my phone

I am experiencing an issue with the mobile responsive dropdown navigation bar on my website. It works perfectly fine on a small width browser, but when I try to open it on my phone, nothing happens. This is puzzling me as I am new to making websites respon ...

What could be preventing my HTML replacement assignment from functioning properly?

Whenever a choice is made, I want to substitute the current content with different content. My current attempt is to update the content from "HuckFinn" to "Tom Sawyer will be added later" when the user selects "Tom Sawyer" from the drop-down menu. However, ...

Leverage the Redux store as the source of data for sending a POST request

For my React project, I designed an input interface and saved the data in a Redux state. Afterward, I set up a new action for making an API call to post the data. When using a constant value as the "data" parameter, everything functions properly. However ...

Unauthorized access for POST request in WooCommerce API: 401 error

Let's start by examining the complete code to better understand the issue at hand. Here is the WooCommerce API authentication using the consumer key and secret from the file checkout.ts: this.WooCommerce = WC({ url:"http://localhost/ ...

Is there a way to show a message when I hover over a different text?

I've been attempting to show a text when hovering over another text, but for some reason it's not working. I've followed all the steps from similar questions, but unfortunately, it still doesn't seem to be functioning correctly. Here i ...

Create a PDF file discreetly

Currently, I am working on a classic asp page that generates a PDF and serves it to the browser. My goal is to create a loading page that preloads the PDF in the background before presenting it to the user, along with a visually appealing indication of ong ...

Using media queries in CSS to create responsive designs

<link type="text/css" rel="stylesheet" media="only screen and (max-device-width: 480px)" href="/assets/css/phone.css" /> <link type="text/css" rel="stylesheet" media="only screen and (min-device-width: 768px)" href="/assets/css/tablet.css" /&g ...

Preserving scroll location in Laravel when posting updates

I am facing an issue with the commenting system in my Laravel application. Whenever a user submits a comment, the page reloads and takes the user back to the top of the page. I would like the page to return the user to the same position where the original ...

combining: enhancing the value of the background-image property

Here is a mixin that I would like to modify: .a () {background-image: url(one.png);} I want to create a new class .b which inherits properties from .a, but also includes an additional background image layer, like this: .b { .a; ...