CSS ul li if remove 1 make others bigger -
the height of ul
500px. how can make li
height dynamic number of li
there are? example, if have 5 li
, height 20%, if 4 li
, changes 25%.
here tried, if remove 1 element "developer mode", height doesn't change.
ul{ list-style:none; height:500px; width:100%; overflow:hidden; } li{ width:100px; height:25%; background:red; border:1px solid black; }
a little jquery need, , supported majority of browsers , mobile devices
$(document).ready(function () { var x = $('li').siblings().length; var y = 100/x; $('li').css('height', y + '%'); });
Comments
Post a Comment