html - I want to target multiple divs inside a parent div -
html - I want to target multiple divs inside a parent div -
i have created hexagon 3 divs combined. want hover on hexagon , 3 divs alter colour.
<div class="hex" > <div class="left" ></div> <div class="middle" ></div> <div class="right" ></div> </div> .hex { float: left; margin-right: -26px; margin-bottom: -50px; } .hex .left { float: left; width: 0; border-right: 60px solid #6c6; border-top: 104px solid transparent; border-bottom: 104px solid transparent; } .hex .left:hover { border-right: 60px solid yellow; } .hex .middle { float: left; width: 124px; height: 208px; background: #6c6; } .hex .middle:hover { background-color: yellow; } .hex .right { float: left; width: 0; border-left: 60px solid #6c6; border-top: 104px solid transparent; border-bottom: 104px solid transparent; } .hex .right:hover { border-left:60px solid yellow; }
as can see, @ moment able target each element of hexagon not hexagon whole.
css can not associate , combine :hover
state of separated individual elements.
in case, can associate :hover
state whole .hex
element in each selector. after :hover
, can add together more subselectors:
.hex:hover .left
(instead of .hex .left:hover
)
the total code:
class="snippet-code-css lang-css prettyprint-override">.hex { float: left; margin-right: -26px; margin-bottom: -50px; } .hex .left { float: left; width: 0; border-right: 60px solid #6c6; border-top: 104px solid transparent; border-bottom: 104px solid transparent; } .hex:hover .left { border-right: 60px solid yellow; /* or simply: border-right-color: yellow; */ } .hex .middle { float: left; width: 124px; height: 208px; background: #6c6; } .hex:hover .middle { background-color: yellow; } .hex .right { float: left; width: 0; border-left: 60px solid #6c6; border-top: 104px solid transparent; border-bottom: 104px solid transparent; } .hex:hover .right { border-left: 60px solid yellow; /* or simply: border-left-color: yellow; */ }
class="snippet-code-html lang-html prettyprint-override"><div class="hex"> <div class="left"></div> <div class="middle"></div> <div class="right"></div> </div>
html css target
Comments
Post a Comment