I’m using CSSLess and JQuery and am trying to count the number of LI elements in an unordered list so I can divide that number for the width.
ul.navBar {
li {
float: left;
width: (100% / `$(".navBar li").length()`);
}
}
The output should appear as tabs side by side like a standard nav bar menu.
Is there a way to write this without JQuery?
You want to do this:
The
~tellslessthat you don’t want it to mess with the output.You could also use
percentage:This only works if you don’t have borders, padding, etc that would make your
lielements any wider. Also, you must load this at the bottom of yourbody, otherwise the jQuery will run before your DOM is ready:Demo: http://jsfiddle.net/jtbowden/ZJ2HV/