2

IT WAS THE DEFAULT MARGIN ON THE <UL>!! SORRY I've got a list of anywhere between 5 and 20 items and I want to make the whole list fill the height of the screen. So I'm finding the height of <html> and dividing it by the number of <li>s and setting this number as the height of each <li>. The problem is there is this roughly 20px white space at the bottom that comes up after the list. I think I need to find the height of the window or body or something instead. Here is some of my code:

var numRootOptions = $('.wrapper > ul > li').size();
var htmlHeight = $('html').height();
var newliHeight = htmlHeight / numRootOptions;
$('.wrapper > ul > li').css('height', newliHeight);
setInterval(function() {
    var htmlHeight = $('html').height();
    var numRootOptions = $('.wrapper > ul > li').size();
    var newLiHeight = htmlHeight / numRootOptions;
    var liHeight = $('.wrapper > ul > li').height();
    if (liHeight != newliHeight) {
        console.log('Different');
    }
}, 2000);
4

3 回答 3

3

try innerHeight() instead of just .height()

于 2013-01-25T18:09:10.407 回答
1

我会说你应该使用$(window).height()or$('html').innerHeight之前建议的。

于 2013-01-25T18:12:47.780 回答
1

默认边距<ul>是问题所在。对不起这个愚蠢的问题!谢谢大家。

于 2013-01-25T18:13:55.863 回答