javascript - Cross Browser Fill Navigation Menu -
what's best way fill out navigation cross browser. seems every browser has it's different definition of padding
when comes navigation, how websites fill out navigation completely, when comes navigation animations?
for example, if have container holding navigation set @ 1000px
- how can dynamically fill 1000px while providing space between list items effectively? i've created fiddle express problem. found here.
my code looks this:
<div id="container"> <ul> <li class="first"><a href="javascript:void(0);">home</a></li> <li><a href="javascript:void(0);">about us</a></li> <li><a href="javascript:void(0);">testimonials</a></li> <li><a href="javascript:void(0);">products</a></li> <li><a href="javascript:void(0);">blog</a></li> <li><a href="javascript:void(0);">something</a></li> <li class="last"><a href="javascript:void(0);">contact</a></li> </ul> <div style="clear:both"></div> </div>
and css this:
* {margin: 0; padding: 0; border: 0;} #container {margin: 0 auto; width: 1000px; background-color: #eee;} #container ul {position: relative;} #container li {float: left; list-style: none;} #container li {display: block; padding: 10px 44px; color: #000; border-left: 1px solid #000; border-right: 1px solid #000; text-decoration: none;} #container li.first {border-left: 0;} #container li.last {border-right: 0;}
so i'm using padding, looks different chrome firefox or firefox ie how make universal?
you can use dispaly:table-cell'
buttons in navigation menu. set table-layout:fixed;
.
here quick example: fiddle demo
#container { width:800px; } #container ul { display:table; width:100%; table-layout:fixed; border-collapse:collapse; } #container ul li { display:table-cell; border:1px solid black; padding:10px; }
browser compatibility:
its supported (i think enough) take look: caniuse.com/css-table
important notes
- that's (css display table rules) css2 - supported.
- the
table-layout
property sets table layout algorithm used table. you can set rows setting display too:
display:table-row
, many more:available css2 table model:
- table { display: table }
- tr { display: table-row }
- thead { display: table-header-group }
- tbody { display: table-row-group }
- tfoot { display: table-footer-group }
- col { display: table-column }
- colgroup { display: table-column-group }
- td, th { display: table-cell }
- caption { display: table-caption }
more information: w3c - css table model
Comments
Post a Comment