即時通訊嘗試創建一個基於投資組合的網站,其中包含一系列浮動動態圖片,到目前爲止我已經通過jQuery和css for Chrome和Firefox(最新發布anno。2012)關於jQuery/Css的IE瀏覽器7-8-9問題的建議
我的問題是(一如既往)IE 7-8-9,我不能包圍我的頭可能會打破它在這個平臺上,我最好的猜測是這是一個jQuery交叉問題?
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%");
}
});
}
您有額外的分號'var maxWidth = $(「。box」)。width();;''和var var maxHeight = $(「。box」)。height();;' – lifetimes
@ user125697:這並不重要,它只會導致一個「空洞的聲明」,它什麼也不做。 – CBroe
@CBroe我知道,我只是想把它清理乾淨:P – lifetimes