html - CSS - nth-child conditions appearing on wrong elements -
The target is a rounded side with hover effects in the CSS. I am using nth-child to control border radius for top and bottom i as you will see on bella, when you surround the elements between 1 and 4th child, you nth-child (1 ) Get the radius setting. Why?
I am using this markup:
HTML
& lt; Ul id = "side-nav" & gt; & Lt; A href = "# / customers" & gt; & Lt; Li class = "side-nav-item client" id = "link_clients" & gt; Customers & lt; / Li & gt; & Lt; / A & gt; & Lt; A href = "# / my-routine" & gt; LE class = "side-nav-item replays" id = "link_ROTIN_templates" & gt; Routines & lt; / Li & gt; & Lt; / A & gt; & Lt; A href = "# / practice" & gt; & Lt; Li class = "side-nav-item exlib" id = "link_exercise_library" & gt; Exercise Library & lt; / Li & gt; & Lt; / A & gt; & Lt; A href = "& lt ;? php echo BASE_URL ;; & gt; ud / logout /" & gt; & Lt; Li class = "side-nav-item logout" id = "link_log_out" & gt; Logout & lt; / Li & gt; & Lt; / A & gt; & Lt; / Ul & gt;
css
#party-nav (range: 1px solid #d5d5d5; boundary-radius: 10px; padding: 0px Important; List-style-type: none;}. Side-nav-item {padding: 10px; Border bottom: 1 px solid # D5D5D5; boundary-radius: 0; margin: 0 px! Important Font-size: 16px; fonts thickness: bold;}. Side-nav-item a {color: # 808080;}. Side-nav-item: hover {background: # D5D5D5;}. Side-nav-item Active {background: # 01bbea;}. Side-nav-item.active {color: #fff ;;} Side-nav-item: nth-child (4) {border-bottom: 0 px solid black; range - Bottom-left-radius: 10px; border-bottom right-radius: 10px;}. Side-nav-item: nth-child (1) {border-top left-radius: 10px; border-top right-radius: 10px ; Border-bottom-left-radius: 0 pixels; Border-bottom right-radius: 0 pixels; Border bottom: 1 px solid # D5D5D5;}
First of all, it's wrong to have anchors in the form of hair nodes in a list. You can see the structure ul> gt; Li & gt; Should look like a
.
On the other hand, nth-child ()
works for elements, not for class selectors. And even because it does not happen, its element with the .side-nav-item
class is always the first element of its father, which is always anchor. So if nth-child ()
will work for classes (which is not the case) then your code will not work anyway.
So if you change your structure to:
What is the valid HTML, you can do this which you are looking for like this:
li: nth-child (1) a {/ * Your stylings * /}
Comments
Post a Comment