【发布时间】:2011-01-23 04:15:41
【问题描述】:
我使用这个脚本来平衡元素的高度:
(function ($) {
$.fn.autoheight = 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));
};
});
};
})(jQuery);
我只想为其添加一项额外功能 - 将class 'longest' 添加到均衡高度时发现的最长元素,我要在上述脚本中进行哪些更改?
非常感谢。
【问题讨论】:
-
它是关于均衡高度,所以“最长”更合适?
-
“最高”或“最高”或可能“最大”更合适。宽度 -> 最宽,高度 -> 最高/最高,长度 -> 最长。