CSS ::before ::after pseudo-element of class not working -
CSS ::before ::after pseudo-element of class not working -
i trying add together ::before
, ::after
pseudo-element menu heading. pseudo-elements work fine regular link outside of menu. however, when trying apply them menu item, background
property set, ::before
, ::after
properties not.
here relevant css:
#cssmenu { background-color: #ffffcc; clear: both; display: inline; float: left; list-style: none; overflow: hidden; text-align: center; text-transform: uppercase; width: 100%; } #cssmenu li { display: inline-block; } #cssmenu li { display: inline-block; } #cssmenu li ul { /*margin-top: 0px; submenu location relative bottom of parent */ display: none; } #cssmenu li:hover ul { display: block; position: absolute; } #cssmenu li ul li { width: 200px; } #cssmenu li:hover > { /* shadow around parent when hover */ box-shadow: 5px 5px 25px #000; -moz-box-shadow: 5px 5px 25px #000; -webkit-box-shadow: 5px 5px 25px #000; } #cssmenu li { color: #000; font-weight: bold; text-decoration: none; padding: 0 12px; line-height: 24px; } #cssmenu li a:hover { background-color: #99cc99; /*padding: 12px; link background when hover on link */ } #cssmenu li ul { background: rgba(255,255,255,0.9); kid menu background w/ transparency padding: 10px 5px; box-shadow: 5px 5px 25px #bbb; -moz-box-shadow: 5px 5px 25px #bbb; -webkit-box-shadow: 5px 5px 25px #bbb; border-radius: 0px 15px 15px 15px; -moz-border-radius: 0px 15px 15px 15px; -webkit-border-radius: 0px 5px 5px 5px; } /* display sub-menu list */ #cssmenu li ul li { display: block; text-align: left; } #cssmenu li ul li a, #nav li ul li a:hover { background: transparent; color: #000; width: 180px; font-size: 0.95em; font-weight: normal; padding: 6px; } #cssmenu li ul li a:hover { /*text-decoration: underline;*/ box-shadow: none; -moz-box-shadow: none; -webkit-box-shadow: none; border-radius: 0; -moz-border-radius: 0; -webkit-border-radius: 0; } .menuheader { /* allow pseudo-elements not have layout due absolute positioning */ margin: 12px 15px; border: 0; background: url("../../../images/buttonslice24.png") 24px 0 repeat-x ; } .menuheader::before, .menuheader::after { content: ' '; position: absolute; top: 0; width: 12px; height: 24px; } .menuheader::before { left: -12px; background: url("../../../images/buttonleft24.png") 0 0; no-repeat; } .menuheader::after { right: -12px; background: url("../../../images/buttonright24.png") 100% 0; no-repeat; }
and relevant html:
<div id="cssmenu"> <ul> <li><a class="menuheader" href="../../../contact-us.aspx">contact</a></li> <li><a class="menuheader" href="../../../">home</a></li> <li><a class="menuheader">store</a> <ul> <li><a href="../../../shipping-policy.aspx">shipping & homecoming policy</a></li> </ul> </li> <li><a class="menuheader" href="../../../account.aspx">account</a></li> <li><a class="menuheader" href="../../../cart.aspx">view cart</a></li> </ul> </div>
jsfiddle
i have tried reference menuheader
class items #cssmenu ul li a
instead, , works (sort of). instead of ::before
, ::after
images showing next menu item itself, show next first item in drop-down menu.
i have read other questions on here regarding pseudo-elements, http://www.w3schools.com/css/css_pseudo_elements.asp , far can tell, ::before
, ::after
should able applied <a>
element. may simple issue, not seeing issue here.
if you're going absolutely position pseudo elements, need give parent position
value, same non-pseudo elements.
just add:
.menuheader { position : relative; }
here updated version of jsfiddle (the changes adding above code , making background of pseudo elements solid color demonstration): http://jsfiddle.net/99aq8/1/
css pseudo-element
Comments
Post a Comment