이전에는이 문제가 없었지만 해결책을 찾지 못하는 것 같아서 저를 도와 줄 수 있기를 바랍니다.크기 변경시 jQuery 높이()가 변경되지 않음
이 기능이 무엇 jQuery를
function setTheHeight() {
if($('#main.level1 .block.attention .block-content').length) {
//Get value of highest element
var maxHeight = Math.max.apply(Math, $('#main.level1 .block.attention .block-content').map (
function() {
return $(this).height();
}
));
console.log(maxHeight);
$('#main.level1 .block.attention .block-content').height(maxHeight);
}
}
setTheHeight();
$(window).resize(function() {
setTheHeight();
});
Basicly이 높이로 선택한 모든 사업부의의의 높이를 가장 높은 사업부를 확인하고 설정합니다. 이것은 잘 작동합니다. 하지만 반응 형 디자인이므로 사용자가 브라우저의 크기를 조정하면 콘텐츠가 작아지고 div가 높아집니다. 그래서 크기 조정 이벤트를 추가했습니다. 이벤트가 시작되었지만 높이가 변경되지 않았습니다. 크기를 조정해도 높이가 변하지 않는 이유는 무엇입니까? 무슨 보여
빠른 jsFiddle : http://jsfiddle.net/3mVkn/
FIX는
흠이 그냥 일반 바보. 높이를 설정했기 때문에 이미 고쳐 졌으므로 높이를 재설정하면 효과가있었습니다.
업데이트 코드 :
function setTheHeight() {
if($('#main.level1 .block.attention .block-content').length) {
//Reset height
$('#main.level1 .block.attention .block-content').height('auto');
//Get value of highest element
var maxHeight = Math.max.apply(Math, $('#main.level1 .block.attention .block-content').map (
function() {
return $(this).height();
}
));
console.log(maxHeight);
$('#main.level1 .block.attention .block-content').height(maxHeight);
}
}
setTheHeight();
$(window).resize(function() {
setTheHeight();
});
안녕하세요 Dennis, 답변 해 주셔서 감사합니다. 불행히도 이것은 probleem을 고치지 않는 것 같습니다 : ( – Sjors
네, 맞습니다. 편집을 확인하십시오, 지금 정확한 해결책을 제공했습니다. –