html - Adding small arrow under current page in WordPress with CSS -
i have menu has 1 gradient type default state, , 1 hover/active state. current page hover/active state, arrow under it. can't figure out best way arrow show up. tried border image, didn't right since button size different depending on length of menu item. here current css using create 2 different styles:
.main-nav li { float: left; font-size: 15px; color: #333; padding: 10px 15px; text-shadow: 1px 1px #ddd; border-right: 1px solid rgba(0, 0, 0, .3); border-left: 1px solid rgba(255, 255, 255, .5); background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0.0, #b3d09e), color-stop(0.75, #a0b88e) ); background-image: -o-linear-gradient(bottom, #b3d09e 0%, #a0b88e 75%); background-image: -moz-linear-gradient(bottom, #b3d09e 0%, #a0b88e 75%); background-image: -webkit-linear-gradient(bottom, #b3d09e 0%, #a0b88e 75%); background-image: -ms-linear-gradient(bottom, #b3d09e 0%, #a0b88e 75%); background-image: linear-gradient(to bottom, #b3d09e 0%, #a0b88e 75%); transition: 300ms; -moz-transition: 300ms; -o-transition: 300ms; -webkit-transition: 300ms; } .main-nav .current-menu-item a, .main-nav .current-page-ancestor a, .main-nav li a:hover { color: #fff; background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0, #043420), color-stop(1, #075a36) ); text-shadow: none; background-image: -o-linear-gradient(bottom, #043420 0%, #075a36 100%); background-image: -moz-linear-gradient(bottom, #043420 0%, #075a36 100%); background-image: -webkit-linear-gradient(bottom, #043420 0%, #075a36 100%); background-image: -ms-linear-gradient(bottom, #043420 0%, #075a36 100%); background-image: linear-gradient(to bottom, #043420 0%, #075a36 100%); }
i avoid using jquery if can. feel there should way using css instead of placing image in center of button jquery. place invisible div under each button arrow image centered , display on current page?
this given follow menu. didn't use quite correct terminology. 'active' part of image current page style:
you can use pseudo elements in css add content, ::after
. using border property different widths , colors triangle shape. thing can bit tricky if need gradient continue on arrow.
i put small demo. hover links in menu see arrow.
li:hover::after { content: ' '; position: absolute; border: solid 10px transparent; border-top: solid 0px transparent; border-width: 10px; left: 50%; margin-left: -10px; border-color: #222 transparent transparent transparent; }
Comments
Post a Comment