php - Menu bar flicker when goes to different page -
can suggest might problem on flickering menu bar?
please suggest make flickering of menu bar stop.
thanks much!
#mainmenu{ margin-bottom: 2.5em; } .menubar{ position: fixed; top:0; left:0; max-height:10em; width:100%; list-style: none; background-color:#333333; text-align: left; margin:0; padding: 0; z-index: 1; border-bottom: 1px solid #ccc; } .menubar .first { margin-left: 1em; } .menubar li{ position: relative; display: inline-block; width:15em; text-align: center; font-family: 'oswald', sans-serif; font-size: 1em; border-bottom: none; cursor: pointer; } .menubar li:hover{ background-color:#6666ff; } .menubar a{ display: block; padding: 0.5em 0.5em 0.5em 0.5em; text-decoration: none; color:#ffffff; } /* submenus */ .menubar .first .submenubar { padding: 0; position: absolute; top:2em; left:0; width:auto; display: none; -webkit-box-shadow: 0px 13px 25px rgba(0,0,0, 0.2); -moz-box-shadow: 0px 13px 25px rgba(0,0,0, 0.2); box-shadow: 0px 13px 25px rgba(0,0,0, 0.2); } .menubar li .submenubar li { text-align: left; list-style-type: none; background-color:brown; display: block; color:#fff; } .menubar > li > .submenubar > li:hover { background-color:black; } .menubar li:hover .submenubar{ display: block; }
see jsfiddle complete code.
i suspect 1 of 2 things happening.
- is whole header "flickering" when go new page? if so, that's because building html page php on server , rendering page again. flash. sucks.
- the sub-menu appears "flicker" because it's broken , when try , hove on it, disappears.
if it's 1, can use caching try , lessen chances of happening, or can learn how use ajax, or js framework build single page apps, that's lot of work.
if it's 2, code i'll include below, , this fiddle - set more solid code work with.
my real advice, never use drop-down menus. terrible interface pattern.
html
<nav class='container navigation'> <div class='inner-w'> <ul class='menu'> <li> <a href='#'>top-level menu item 1</a> <ul class='sub-menu'> <li><a href='#'>sub-menu item 1</a></li> <li><a href='#'>sub-menu item 2</a></li> <li><a href='#'>sub-menu item 3</a></li> <li><a href='#'>sub-menu item 4</a></li> </ul> </li> <li><a href='#'>top-level menu item 2</a></li> <li> <a href='#'>top-level menu item 3</a> <ul class='sub-menu'> <li><a href='#'>sub-menu item 1</a></li> <li><a href='#'>sub-menu item 2</a></li> </ul> </li> <li><a href='#'>top-level menu item 4</a></li> </ul> </div> </nav>
css
/* global-structure */ .container { width: 100%; float: left; } .container .inner-w { margin-right: auto; margin-left: auto; max-width: 900px; /* arbitrary */ /* should have clear-fix */ } /* menu styles */ .menu, .menu ul { list-style: none; margin: 0; padding: 0; } .menu li { float: left; } .menu > li { /* top-level li */ position: relative; /* sub-menu can positioned */ border-right: 1px solid rgba(0,0,0,.3) } .menu > li:last-child { border-right: 0; } .menu { display: block; padding: .8rem .5rem; background: #eee; min-width: 160px; color: inherit; text-decoration: none; } .sub-menu { position: absolute; top: 100%; left: 0; height: 0; width: 0; /* hide visually */ overflow: hidden; z-index: 5; /* arbitrary, keep them small though... */ } .sub-menu li { clear: left; border-bottom: 1px solid rgba(0,0,0,.3) } .sub-menu li:last-child { border-bottom: 0; } .sub-menu { background: #ccc; } .sub-menu a:hover { background: #aaa; } .menu > li:hover .sub-menu { height: auto; width: auto; }
if absolutely forced write drop-down menu, have this: http://codepen.io/sheriffderek/pen/qdbryb/?editors=010
Comments
Post a Comment