html - I am having alingment issue in navigation bar css -
in first image taken ie, having full width every content, if u see in second image last menu content, not taking full width. how solve in both browser
html:
<div class="menu-section clearfix"> <div class="menu-element clearfix"> <ul> <li class="active"><a href="#">home</a></li> <li><a href="#">about us</a></li> <li><a href="#">administration</a></li> <li><a href="#">academics</a></li> <li><a href="#">research</a></li> <li><a href="#">activities</a></li> <li><a href="#">examination</a></li> <li><a href="#">facilites</a></li> <li><a href="#">contact us</a></li> </ul> </div> </div>
css:
.menu-section { background-color:#900000; height: 56px; } .menu-element { background-color: #400; height: 50px; } .menu-element li { float:left; } .menu-element li:hover { background-color:#900000; } .menu-element li.active { background-color:#900000; } .menu-element li { color:#fff; text-transform:uppercase; display: block; padding: 18px 21px; text-decoration:none; font-weight: bold; }
you need add style ul
well:
.menu-element > ul { list-style: none; margin: 0; padding: 0; }
maintaining consistency across browsers bit difficult, ensure same rendering 2 methods.
- specify valid
doctype
onhtml
ensure standards mode, and - specify
box-sizing
typicallyborder-box
in stylesheet.
-
* { box-sizing: border-box; }
if want justify menu options across width, have make few adjustments , hack.
apply fixed width wrapping div
, text-align:justify
on ul
, display:inline-block
on li
required.
note 1: display: inline-block
required, generates html white-spaces. in order rid of white-spaces, html comments can used in markup of list items.
note 2: :after
pseudo element in hack seems trick. however, create unintended space below ul. space seems there because elements flushed across. if not justified, space not appear.
.menu-element { width: 100%; /* fixed width required on wrapping container */ } .menu-element > ul { list-style-type: none; /* getting rid of bullets */ margin: 0px; padding: 0px; /* getting rid of default indents */ text-align: justify; /* important justify contents */ } .menu-element li { display: inline-block; /* required. float won't work. */ text-align: left; /* align list items */ white-space: no-wrap; /* prevent wrapping of list items if required */ } .menu-element > ul:after { /* hack without list items won't justified */ content:''; display: inline-block; width: 100%; height: 0; }
demo: http://jsfiddle.net/abhitalks/mv7qnfle/4/
full screen demo: http://jsfiddle.net/abhitalks/mv7qnfle/4/embedded/result/
.
Comments
Post a Comment