Ways to resolve the issue of two arrows spinning simultaneously when only one sidebar is activated

I am in the process of designing a website and I have encountered an issue with setting up the sidebar. Specifically, I want to add a submenu to the sidebar, but when I click on one sidebar item, both arrows move together. I have tried adjusting the code, but I am unsure what else needs to be added. Can someone please guide me on where to include the submenu script in HTML?

https://i.sstatic.net/8lt5Q.png

-- Both arrows move simultaneously when one is clicked

.main_box .sidebar_menu {
  position: fixed;
  height: 100vh;
  width: 280px;
  left: -280px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0px 0px 6px rgba(255, 255, 255, 0.5);
  overflow: hidden;
  transition: all 0.3s linear;
}

.sidebar_menu .menu {
  position: absolute;
  top: 80px;
  width: 100%;
}

.sidebar_menu .menu li {
  margin-top: 6px;
  padding: 14px 20px;
  position: relative;
}

.sidebar_menu .menu i {
  color: #fff;
  font-size: 20px;
  padding-right: 8px;
}

.sidebar_menu .menu li span {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  transition: transform 0.4s;
  font-size: 22px;
  color: #fff;
}

.sidebar_menu .menu:hover li span {
  transform: translateY(-50%) rotate(-180deg);
}

.sidebar_menu .menu a {
  color: #fff;
  font-size: 20px;
  text-decoration: none;
}

.sidebar_menu .menu li:hover {
  border-left: 1px solid #fff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}
<div class="menu">
  <ul>
    <li>
      <i class="fas fa-qrcode"> Friends<span class="fas fa-caret-down"></span></i>
    </li>
    <li>
      <i class="fas fa-stream"> Updates<span class="fas fa-caret-down"></span></i>
    </li>
  </ul>
</div>

Answer №1

Modify the css style rule

.sidebar_menu .menu:hover li span {
  transform: translateY(-50%) rotate(-180deg);
}

with

.sidebar_menu .menu li:hover span {
  transform: translateY(-50%) rotate(-180deg);
}

The updated version instructs only the hovered LI within a DOM element with the class of "menu" to transform the SPAN(s) inside them; in contrast to the original code which transforms all LI elements inside.

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

Function cannot be triggered by pressing the ENTER key

I'm struggling to pass values to my function and make it run when I press the ENTER KEY in PHP The function I'm dealing with is called update() Below is the PHP code snippet: echo '<input type="text" size="23" id= n'.$row["Cont ...

The height of the webpage is extended when viewed on mobile Safari

After creating a website that functions smoothly on all platforms, I encountered a problem with mobile Safari. On this browser, the page height is inexplicably stretched and the page becomes unresponsive after the first click. html,body { height:100%; ...

Automatic Scrolling within Frameset

Currently, I am using a Frameset in my UI page and I am looking to implement auto-scrolling functionality for both vertical and horizontal directions. I specifically need the ability to scroll either horizontally, vertically, or both whenever necessary. B ...

Exploring HTML5 canvas hit detection using isPointInPath() method

When it comes to hit testing with HTML5 canvas, here's an idea I've been considering: 1) Store the coordinates of a shape (e.g. a rectangle) - x, y, width, height 2) When the mouse is moved or clicked, redraw the rectangle on the screen canvas w ...

PHP Implementing real-time dynamic categories

I am working on a project where there are multiple items listed with unique IDs. Each item has corresponding data with the same ID. I want to use JQuery, JScript, and PHP to display options based on the ID of the selected item in real-time. Below is a snip ...

Exploring the integration of sprites within a navigation element

I'm in the process of creating an HTML navigation bar that utilizes sprites for social media icons. Currently, I have successfully implemented my navigation bar with individual social media icons in HTML as shown below: <nav> <a href= ...

Stuck autoplay feature when clicking

There is an issue with the play function in the built-in browser audio player. Initially, it starts automatically with the following code... function play(){ var audio = document.getElementById("myaudio"); audio.play(); } However, when modifying the code ...

CSS almost there!

Below is the HTML code I am using: <div class="ObjectList" id="ObjectList"> <p class="ObjectListTitle" id="Element">TEST</p> </div> The CSS is applying properly to the ObjectList class but is not working for the ObjectListTitl ...

Transform incorrect <span href="#"> elements into proper <a href="#"> tags

This particular code is causing errors when validated by the W3 Validator, despite functioning correctly upon clicking. <span href="#" class="click">+</span> However, if I modify it to the code below, it passes the W3 validation test. But now ...

Execute a JavaScript function on a Node server following a click event in an HTML document

Hello everyone, I am currently working on a project using node.js in a Windows environment. With the help of the express module, I am trying to create a static page that includes a Submit form. When someone clicks the "Submit" button, I intend to execute a ...

Change the element's color to match the default anchor link

Can CSS be utilized to match an element's color with the default <a> color? If affirmative, what is the method? ...

Incorporating a message for when no results are found in the jQuery

I currently have a jQuery search script that utilizes the Bing API. The issue I am facing is that when a user performs a search query and no results are found, the page remains blank. How can I insert a message such as "No results found." to prevent the p ...

Internet Explorer seems to be having trouble detecting changes made to a jQuery checkbox

Here is an example of HTML code: <input type="checkbox" id="openInNewWindowCheckBox" value ="some_value" /> Accompanied by a jQuery script: $("#openInNewWindowCheckBox").change(function(){ if($(this).is(':checked')) ...

How can I prevent opening duplicate tabs of the same website simultaneously?

Is there a way to prevent users from accessing the same website page from multiple tabs? Could this be accomplished using JavaScript? ...

Responsive HTML5 audio player adjusts size when viewed on mobile devices

I am facing a challenge with an HTML5 Audio player. It looks fine on desktop but behaves strangely on mobile devices. While the width remains intact, it repositions itself and floats over the element it is contained within. How can I prevent this repositio ...

initiate dynamic elements triggering in jQuery

function fetchTeacherAnnouncementDetails(){ var tCounter = 1; $.ajax({ url:'<%=contextPath%>/show/announcementsForTeacher', headers: { 'Authorization':'${sessionScope.token}' ...

Dynamic grid alignment: lock to edge of screen

Currently, I am in the process of creating an animated grid that adjusts its size when hovered over. To view the code pen project, please ensure you are in desktop mode rather than mobile: https://codepen.io/marco_lu/pen/abBmwEJ The JavaScript code utili ...

What steps can be taken to ensure that events are triggered on the correct DIV element?

I am considering two different HTML structures for my project: <div id="threeJSContainer"> </div> <div id="UIControls"> <div ng-include src="'scripts/angular/UI.html'"></div> </div> When using the first c ...

Using HTML and CSS, we can achieve a fixed position using the `position: sticky`

On my website, I have elements that utilize transformations. One issue I've encountered is that these transformations end up resizing the viewport. Normally, I would address this by setting overflow-x: hidden for both html and body, but doing so disru ...

Update the section tag upon submission using jQuery on a jQuery Mobile HTML page

I have integrated a jquerymobile template into Dreamweaver 6.0 to create a mobile app interface. The home screen features four buttons - specifically, View, Create, Update, Delete. Upon clicking the Create button, a new screen is opened (each screen corres ...