Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - Hover and change triangle color

Tags:

css

css-shapes

I have a dropdown list menu with small triangle pointer, when I hover the first item I want the small triangle also change to black color.

This is my JS Fiddle, Thanks.

CSS

.username .messages {
    position:absolute;
    margin:22px 0px 0px -70px;
    width:200px;
    max-height:auto;
    color:black;
    -webkit-box-shadow: 0 8px 6px -6px black;
    -moz-box-shadow: 0 8px 6px -6px black;
    box-shadow: 0 8px 6px -6px black;
}
.username .messages:before {
    content:'.';
    display:block;
    position:absolute;
    margin-left:-10px;
    left:50%;
    top:-18px;
    width:0;
    height:0;
    border:10px solid black;
    color:black;
    border-color:transparent transparent #fff;
}
like image 913
TheSmile Avatar asked Apr 11 '26 23:04

TheSmile


1 Answers

Place the arrow as the before pseudoelement of the first link

Example fiddle: http://jsfiddle.net/ebcho06a/5/

.messages a:first-child:before {
    content:'';
    display:block;
    position:absolute;
    margin-left:-10px;
    left:50%;
    top:-20px;
    width:0;
    height:0;
    border:10px solid black;
    color:black;
    border-color:transparent transparent #fff;
}

.messages a:first-child:hover:before {
    border-color:transparent transparent #000;
}

Effect on mouseover

enter image description here

like image 52
Fabrizio Calderan Avatar answered Apr 13 '26 13:04

Fabrizio Calderan