मुझे पहले कभी यह समस्या नहीं थी, लेकिन मुझे समाधान नहीं मिल रहा है, इसलिए मुझे आशा है कि आप लोग मेरी मदद कर सकते हैं।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();
});
मूल रूप से इस समारोह करता है इस ऊंचाई के लिए उच्चतम div के लिए जाँच करें और सभी चयनित div के की ऊंचाई सेट है। यह ठीक काम करता है। लेकिन यह एक उत्तरदायी डिजाइन है, इसलिए जब उपयोगकर्ता अपने ब्राउज़र का आकार बदलता है तो सामग्री छोटी हो जाती है और div अधिक हो जाता है। तो मैंने एक आकार बदलने का कार्यक्रम जोड़ा। घटना को निकाल दिया जा रहा है लेकिन यह ऊंचाई बदल नहीं रहा है। किसी भी विचार का आकार क्यों आकार बदल नहीं रहा है?
त्वरित jsFiddle क्या होता है को दिखाने के लिए: http://jsfiddle.net/3mVkn/
ठीक
हम्म यह सिर्फ सादा बेवकूफ था। क्योंकि मैं ऊंचाई स्थापित कर रहा था() यह पहले से ही तय किया गया था इसलिए मुझे बस ऊंचाई को रीसेट करना था और यह काम करता था।
अपडेट किया गया कोड:
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();
});
हाय डेनिस, आपकी प्रतिक्रिया के लिए धन्यवाद। दुर्भाग्यवश यह समस्या को ठीक नहीं लग रहा था :( – Sjors
हां, आप सही हैं। कृपया संपादन की जांच करें, मैंने अब सही समाधान प्रदान किया है। –