Attempting to preserve the CSS transform effect as I switch between menu options

Whenever I stop hovering over my element, it reverts back to its original position. However, I want it to remain in place when I am navigating through the "sousmenu" menu and only return to its original position when I am not hovering over the "sousmenu". I am not very familiar with creating custom jQuery scripts, so I'm a bit confused in this situation. Thank you for your assistance!

.line-menu{
z-index: 10;
display: list-item;
  background-color: #b6a083;
  height: 1px;
  width: 30px;
  font-size: 1px;
  padding: 1px;
  color: white;
  margin-right: 5px;
  margin-left: 15px;
margin-top: 10px;
  opacity: .7;
}

.class-menu{
position: relative;
z-index: 10;
display: block;
margin-top: 50px;
margin-left: 30px;
}

.class-menu:hover > .elem-one{
animation: lag-down 0.2s;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}

@keyframes lag-down {
  0% {
    transform: rotate(0);
  }
  100% {
-webkit-transform: translate3d(0, 100%, 0);
    transform: translateY(13px);

  }
}

 .class-menu:hover > .elem-three{
animation: lag-up 0.2s;
-webkit-animation-fill-mode: forwards;
-moz-animation-fill-mode:forwards;
animation-fill-mode: forwards;
}
 @keyframes lag-up {
  0% {
    transform: rotate(0);
  }
  100% {
-webkit-transform: translate3d(0, 100%, 0);
    transform: translateY(-13px);
  }
}

#menu{
    /*height: 21px;*/
    list-style-type: none;
    margin: 0;
    padding: 0;
    border: 0;
    position: absolute;
}
#menu li a:hover {background-color: none;}
#menu li a:active {background-color: #FFF;}
#menu .sousMenu{
position: absolute;
top: 0px;
z-index: 1;
    display: none;
    list-style-type: none;
    margin: 1px;
    line-height: 1.8;
    font-size: 1.5em;
    font-family: DidotBoldItalic;
    background-color: rgba(255,255,255,0.9);
    /*opacity: 0.5;*/
    width: 290px;
    height: 690px;
    padding-left: 50px;
    padding-top: 110px;
    border: 0;
}
#menu .sousMenu li{
    float: none;
    margin: 0;
    padding: 0;
    border: 0;
}
#menu .sousMenu li a:link, #menu .sousMenu li a:visited{
display: block;
color: black;
font-family: 'Futura_light';
margin: 0;
border: 0;
text-decoration: none;
}
#menu .sousMenu li a:hover{
 background-image: none;
color: #b6a083;
}
#menu li:hover > .sousMenu {
 display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<section id="menu">
    <li><a href="#" class="class-menu"><div class="line-menu elem-one"></div><div class="line-menu elem-two"></div><div class="line-menu elem-three"></div></a>
            <ul class="sousMenu">
                    <li><a href="idea.html">IDEA</a></li>
                    <li><a href="legend.html">LEGEND</a></li>
                    <li><a href="#">PRODUCTS</a></li>
                    <li><a href="#">WORK WITH US</a></li>
                    <li><a href="#">PRESS</a></li>
                    <li><a href="#">CONTACT</a></li>
<li><a href="#"><img src="elem/Btn-langue.png" alt="bouton-langue" class="menu-button bouton-langue" /></a></li>
<li><a href="#"><img src="elem/shopping-bag.png" alt="bouton-langue" class="menu-button bouton-langue" /></a></li>
<li><a href="#"><img src="elem/connexion.png" alt="bouton-langue" class="menu-button connexion" /></a></li>
<li><a href="#"><img src="elem/fb-insta.png" alt="bouton-langue" class="menu-button fb-insta" /></a></li>
            </ul>
    </li>
    </section>

Answer №1

If you're looking to avoid using custom jquery code, simply replace all instances of .class-menu:hover with li:hover .class-menu.

This modification will result in the class-menu changing whenever the li element is hovered over. This way, the menu remains visible even when hovering over other areas within the menu.

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

Concealing a Specific Element with Text using jQuery

Is there a way to conceal the section that includes the element labeled as "Product Tags" on a webpage? ...

Discovering a CSS value using jQueryUncovering the CSS value with jQuery

Currently, I have a script that allows me to change the color of an event in a calendar to red when clicked. eventClick: function(calEvent, jsEvent, view) { $(this).css('border-color', 'red'); } Now, I want to enhance this featur ...

Clicking on the Edit button does not result in any changes to the HTML on the page following a table

My current setup involves a button that is supposed to toggle between 'Add New User' and 'Update User' elements when clicked. However, it seems to work only when the table has not been filtered. Once I apply any kind of filtering on the ...

How do I easily show/hide a submenu in AngularJS with a toggle menu?

After browsing some Stacks, I've come to the realization that I need to create separate directives in order to hide or toggle a menu from its sub-menu items. I want the menu to be hidden when any of the sub-menu items are clicked. However, I can&apo ...

Retrieve the tweets from the next Twitter user in the Array using blogger.js

I am working on a project that involves a javascript array of Twitter usernames. Using blogger.js, I successfully load the first username along with their last 5 tweets. Now, I am looking to create HTML buttons or links for "previous" and "next" in order ...

Deactivating Cluetip tool tips and adjusting the height limit in JQuery

How can I momentarily turn off the hints? I have seen references to being able to do so on the website and in this forum, but I am having trouble locating the command to disable them. I just need to temporarily deactivate them and then enable them again. ...

Having trouble adjusting the height of <a> elements in the navbar

My navbar has an issue where the listed items do not fill the entire height of the navbar. I have tried adjusting padding and margin, but it doesn't seem to be affecting the layout. Any suggestions would be greatly appreciated. Thank you. #navbar { ...

Choosing Between EMs and Pixels for Font Sizes: A 2011 Perspective

In the past, EMs were favored over pixels for font size because they could scale with IE6 while pixels could not. Nowadays, modern browsers can handle pixel-sized font scaling correctly. Another advantage of EMs is that they cascade, unlike pixels. But if ...

Ways to activate a function upon validation of an email input type

Within my HTML form, there is an input type="email" field that requires a valid email pattern for acceptance. I am attempting to send an AJAX request to the server to confirm whether the entered email already exists in the database after it has been verif ...

Encountered an issue while attempting to retrieve the access token from Azure using JavaScript, as the response data could

Seeking an Access token for my registered application on Azure, I decided to write some code to interact with the REST API. Here is the code snippet: <html> <head> <title>Test</title> <script src="https://ajax.google ...

Creating a bespoke scrollbar using Material UI

What is the best way to implement a custom scrollbar in Material UI? I have spent a lot of time researching how to add a custom scrollbar and I finally found a solution that works. Thanks to everyone who helped me along the way. ...

Instructions for implementing personalized horizontal and vertical scrolling within Angular 9

I am currently working on an angular application where users can upload files, and I display the contents of the file on the user interface. These files may be quite long, so I would need vertical scrolling to navigate through them easily. Additionally, fo ...

optimal method for displaying HTML strings with components in Vue

My website is a Blog/News site featuring posts that contain HTML content stored in the database. In addition to posts, I also want to include elements like sliders which cannot be generated using v-html. I explored Vue's Render Functions to find a so ...

Sortable lists that are linked together, containing items that cannot be moved

I have been trying to implement two connected sortable lists with disabled items using this sortable list plugin, but for some reason, I am unable to get it to work. Is there anyone who can provide assistance with this issue? <section> <h1&g ...

Tips for aligning a div containing an image in the center of another div

Trying to perfectly center an image inside a div both vertically and horizontally using the display inline-block property. HTML <div class="center-wrapper"> <div class="image-holder"> <img src="picture.jpeg" alt="Centered Image"> ...

Take away the attention from the span element

I have been experimenting with the following jsfiddle and attempted various methods suggested in this Stack Overflow thread, but I am struggling to remove the focus from the "feedback" span after clicking on the cancel button in jQuery confirm dialog. Her ...

Is there a way to detect the completion of the fadeout animation before calling a function?

I am trying to create a toast message using jQuery. When the "show" class is appended to the div, I want the toast message to fade in and then fade out after a few seconds. Once the fade-out animation is complete, I need to remove the "show" class. This ...

Turn off hover effect for MUI DataGrid

I'm having trouble figuring out how to disable the hover effect on a row in the MUI Datagrid. I've searched through the API documentation but couldn't find a straightforward solution. Any suggestions on how to achieve this? <DataGrid ...

Is Angular4 preloaded with bootstrap library?

I started a new angular4 project and wrote the code in app.component.html <div class="container"> <div class="row"> <div class="col-md-1">.col-md-1</div> <div class="col-md-1">.col-md-1</div> <div class ...

The PHP file uploader form is limiting uploads to a maximum of 16 files

The XML files are compact and well below the maximum upload limit, with my max_file_upload value in php.ini set to 30. Up to 16 files can be uploaded in any combination. Interestingly, the form doesn't actually "POST," but it does redirect to the next ...