Any one know how to apply a css propert to the a tag, but only when it’s in a certain div? I would like the .router_li div to have the hover effect, but any other links. I’m not sure what this is called.
I think it’s called a pseudo class, and I’m not doing it right.
I tried this:
a:router_li:hover{
background-color:yellow;
width: 200px;
height: 60px;
background-color: #2c5fac;
border: 1px;
border-color: #FFFFFF;
border-top-right-radius: 8px;
border-top-left-radius: 8px;
border-bottom-right-radius: 8px;
border-bottom-left-radius: 8px;
border-style:solid;
border-width:1px;
color: white;
}
IDs, classes and pseudo-classes are different things, and CSS has different notations for all three:
If you want to apply this particular
:hover(which is a pseudo-class) only whenais adivwith classrouter_li(as in<div class="router_li">), useThat’s a class, though; if it’s an ID (as in
<div id="router_li">), useIn both cases,
router_liis not a pseudo-class since it is defined in the markup and not in CSS, so the:router_liin your code is invalid. Also notice that the ID/class (whichever it is) comes before thea:hover– this is called a contextual selector (aonly when it’s in a certaindiv).