firfox 因为float:left scrollHeight不起作用

为了让一组float:left属性的dom对象自动缩放,且同一行的的dom对象高度一致(类似3列结构),以内容最长的一列高度为标准。

    var resize_height = {
        init:function (class_name, callback) {
            var ary = []
            $(class_name).each(function (index, element) {
                var height = $(this)[0].scrollHeight
                ary.push(height)
            })
            var h1 = Math.max.apply(null, ary)
            callback(h1)
        }
    }
    resize_height.init(".height1", function (a) {
		
        $(".height1").css("height",a)
    })

    resize_height.init(".height2", function (a) {
        $(".height2").css("height",a)
    })

 但是却发现火狐下没有算出scrollheight的实际值(chrome可以),而是得到了$(".height1")的css的height值。想到可能是float:left属性的原因,去掉float:left果然就正确了。

解决办法,定义overflow:hidden属性。

posted @ 2013-03-06 17:05  break_happy  Views(458)  Comments(0Edit  收藏  举报