Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

CSS Change arrow color when ul submenu is hovered

mjdeutz

Coder
Hi and thanks in advance,

In CSS I have created a right facing arrow used to denote a range of years which is displayed in a number of submenus in an ul horizontal menu

eg: the text in the submenus is something like:

'2020 > 2021'
'2018 > 2019'
'2016 > 2017'

(where the '>' is a placeholder for my actual arrows)

Currently, when the li is hovered, the text changes color from black to white and I want my arrow to also change to white.

I create the right facing arrow like this ...


[CODE lang="css" title="Arrow code"]
.arrow {
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-bottom: 4px solid black;
display: inline-block;
padding-bottom: 5px; /* align and center the arrow with the text */
}

/* Transform the arrow to the right orientation */
.right {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
}

/* This changes the text in the submenu to white and the background to green when hovered over */
.dropDownMenu ul li a:hover {
background-color: #164149; /* Dark Green */
color: White;
}

/* Here is the pertinent HTML to display the arrow in the menu text */
<ul>
<li><a href="#"><img src="http://sharepoint/GSites/Dnt/OP/OP_Res/files.png" width="20" align="middle" border="none"><span class="nav-text">&nbsp;&nbsp;2021&nbsp;&nbsp;&nbsp;<i class="arrow right"></i>&nbsp;2023</span></a>[/CODE]
 
I think you should just be able to make a new CSS rule for the arrow:

CSS:
.dropDownMenu ul li a:hover .arrow {
    background-color: #164149; /* Dark Green */
    color: White;
}
 

Buy us a coffee!

Back
Top Bottom