最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Equal Height not working in Safari (jQuery) - Stack Overflow

programmeradmin1浏览0评论
$.fn.equalHeight = function () {
    var height = 0,
        reset = $.browser.msie ? "1%" : "auto";
    return this.css("height", reset).each(function () {
        height = Math.max(height, this.offsetHeight);
    }).css("height", height).each(function () {
        var h = this.offsetHeight;
        if (h > height) {
            $(this).css("height", height - (h - height));
        }
    });
};

.. works great in Firefox and even the crappy IE6 but not Webkit (Safari, Chrome). How do I fix it?

Many thanks

$.fn.equalHeight = function () {
    var height = 0,
        reset = $.browser.msie ? "1%" : "auto";
    return this.css("height", reset).each(function () {
        height = Math.max(height, this.offsetHeight);
    }).css("height", height).each(function () {
        var h = this.offsetHeight;
        if (h > height) {
            $(this).css("height", height - (h - height));
        }
    });
};

.. works great in Firefox and even the crappy IE6 but not Webkit (Safari, Chrome). How do I fix it?

Many thanks

Share Improve this question asked Mar 2, 2010 at 15:28 eozzyeozzy 68.9k109 gold badges285 silver badges447 bronze badges 4
  • Have you looked at this: webkit/blog/66/the-fouc-problem – Pointy Commented Mar 2, 2010 at 15:43
  • Equal heights doesn't work in webkit, works in all other browsers. – eozzy Commented Mar 3, 2010 at 3:52
  • Same problem here...only Chrome and Safari as you said...the column heights are equal thought, but the content of one column overflow...It looks like it is getting the wrong height as the max height... – Paranoid Android Commented Mar 14, 2011 at 21:38
  • Here is a snapshot of mine with the blog feeds overflowing the column...are the blog feeds loaded AFTER the equalHeight() is executed? I call the script in the footer though, with a proper jQuery(document).ready() but it still does not work. awesomescreenshot./0a5987p87 – Paranoid Android Commented Mar 14, 2011 at 21:50
Add a ment  | 

1 Answer 1

Reset to default 7

Try to load your script with jQuery(window).load(), it solved my problem.

Read more here

发布评论

评论列表(0)

  1. 暂无评论