다음 스크립트는 특정 컨테이너의 div 및 창 크기를 동일하게 유지합니다. http://stephenakins.blogspot.gr/2011/01/uniform-div-heights-for-liquid-css-p.html스크립트가 jQuery 1.9.0과 작동하지 않음
로드시 작동하지만 jQuery 1.9.0에서는 윈도우 크기 조정 기능이 작동하지 않습니다. jQuery 버전을 1.5.0으로 변경하면 크기가 조정됩니다. jQuery 마이그레이션 플러그인을 사용했지만 경고 또는 오류가 발생하지 않습니다. 1.9.0 구문과의 비 호환성이 있습니까? 어떤 아이디어?
// these are (ruh-roh) globals. You could wrap in an
// immediately-Invoked Function Expression (IIFE) if you wanted to...
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array();
function setConformingHeight(el, newHeight) {
// set the height to something new, but remember the original height in case things change
el.data("originalHeight", (el.data("originalHeight") == undefined) ? (el.height()) : (el.data("originalHeight")));
el.height(newHeight);
}
function getOriginalHeight(el) {
// if the height has changed, send the originalHeight
return (el.data("originalHeight") == undefined) ? (el.height()) : (el.data("originalHeight"));
}
function columnConform() {
// find the tallest DIV in the row, and set the heights of all of the DIVs to match it.
$('.equalize > .col').each(function() {
// "caching"
var $el = $(this);
var topPosition = $el.position().top;
if (currentRowStart != topPosition) {
// we just came to a new row. Set all the heights on the completed row
for(currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) setConformingHeight(rowDivs[currentDiv], currentTallest);
// set the variables for the new row
rowDivs.length = 0; // empty the array
currentRowStart = topPosition;
currentTallest = getOriginalHeight($el);
rowDivs.push($el);
} else {
// another div on the current row. Add it to the list and check if it's taller
rowDivs.push($el);
currentTallest = (currentTallest < getOriginalHeight($el)) ? (getOriginalHeight($el)) : (currentTallest);
}
// do the last row
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) setConformingHeight(rowDivs[currentDiv], currentTallest);
});
}
// Dom Ready
// You might also want to wait until window.onload if images are the things that
// are unequalizing the blocks
$(function() {
columnConform();
});
// Window resize functions
$(window).resize(function() {
columnConform();
});
콘솔에 오류가 표시됩니까? –
jsfiddle을 만들었지 만 jQuery 1.9.1에서 크기 조정에 문제가 없지만 콘솔에서 오류가 표시되지 않는 동안 내 코드에서는 작동하지 않습니다. http://jsfiddle.net/drivebass/fax0v36a/1/ – drivebass