2013-04-03 19 views
0

即時通訊嘗試創建一個基於投資組合的網站,其中包含一系列浮動動態圖片,到目前爲止我已經通過jQuery和css for Chrome和Firefox(最新發布anno。2012)關於jQuery/Css的IE瀏覽器7-8-9問題的建議

我的問題是(一如既往)IE 7-8-9,我不能包圍我的頭可能會打破它在這個平臺上,我最好的猜測是這是一個jQuery交叉問題?

check this jsFiddel

or check my online exampel here

什麼即時尋找是在哪裏我可以去錯誤的,因爲我現在有白髮試圖弄明白我自己,任何建議,想法,文章等一些建議歡迎

感謝不止提前 的Mads

jQuery代碼:

$(window).load(function() { 
    plottingData(); 
    resizeImage(); 
}); 

$(window).resize(function() { 
    plottingData(); 
    resizeImage(); 
}); 

function plottingData() { 
    var image = $('.box img'); 
    var divW = $(".box").width(); 
    var divH = $(".box").height(); 
    var imgW = image.width(); 
    var imgH = image.height(); 
    $('.outputText').html('DIV CONTAINER W: ' + divW + ' H: ' + divH + ' :: imgW: ' + imgW + ' : imgH: ' + imgH); 
} 


function resizeImage() { 
    $("img").each(function() { 
     var maxWidth = $(".box").width();; // Max width for the image 
     var maxHeight = $(".box").height();; // Max height for the image 
     var maxratio = maxHeight/maxWidth; 
     var width = $(this).width(); // Current image width 
     var height = $(this).height(); // Current image height 
     var curentratio = height/width; 
     // Check if the current width is larger than the max 

     if (curentratio > maxratio) { 
      ratio = maxWidth/width; // get ratio for scaling image 
      /* 
      $(this).css("width", maxWidth); // Set new width 
      $(this).css("height", height *ratio); // Scale height based on ratio 
      */ 
      $(this).css("width", "100%"); 
      $(this).css("height", "auto"); 
     } else { 
      /* 
      ratio = maxHeight/height; // get ratio for scaling image 
      $(this).css("height", maxHeight); // Set new height 
      $(this).css("width", width * ratio); // Scale width based on ratio 
      */ 
      $(this).css("width", "auto"); 
      $(this).css("height", "100%"); 
     } 

    }); 
} 
+0

您有額外的分號'var maxWidth = $(「。box」)。width();;''和var var maxHeight = $(「。box」)。height();;' – lifetimes

+0

@ user125697:這並不重要,它只會導致一個「空洞的聲明」,它什麼也不做。 – CBroe

+0

@CBroe我知道,我只是想把它清理乾淨:P – lifetimes

回答

0

試一下:

... 
var box = $(this).parent(".box"); 
var maxWidth = box.width(); 
var maxHeight = box.height(); 
... 

相同的寬度plottingData你將不得不遍歷那裏。 你能告訴我你得到的所有盒子和圖像的高度嗎? 你真幸運,看起來它們的尺寸完全相同。爲每個框和圖像應用規則。

+0

當然,jQuery不是問題,但在IE 7和8,9中對CSS的支持表現得很好,@media不是支持者以及不透明和邊框盒子......其他很多很多東西。我決定,因爲它是我自己的投資組合,我不會支持IE6-7-8只能從IE9 +和最新的Chrome瀏覽器,Firefox和Safari瀏覽器;)..現在是足以說明來自IE的足夠時間...是的它suxx。 – mads