0

我无法让所有版本的 Internet Explorer 呈现我的 jQuery 代码。它在 FF、Chrome、Safari 和 Opera 中运行良好。代码位于标签之前的 html 文件底部。我还尝试了标签之前顶部的代码,但没有任何运气。我不确定这是否是在可扩展网站上设置位置和大小的正确方法,但代码如下:

    $(document).ready(function(){
    resizeDiv();
});

window.onresize = function(event) {
    resizeDiv();
}

function resizeDiv() {
    mainheight = $(window).width() * .7275;

    //Adjusting height
    $('#main').css({'height': mainheight + 'px'});
    $('#content').css("height", $('#content').width() / 3.9608 + "px");

    //Adjusting width
    $('#aacsbbottomimage').css("width", $(window).width() / 9.9365 + "px");
    $('#checkimg1').css("width", $(window).width() / 12.52 + "px");
    $('#checkimg2').css("width", $(window).width() / 12.52 + "px");
    $('#checkimg3').css("width", $(window).width() / 12.52 + "px");

    //Adjusting top positions
    $('#content').css('top', mainheight * .485 + 'px');
    $('#header').css('top', mainheight * .05 + 'px');
    $('#contentheading').css('top', mainheight * .43 + 'px');
    $('#footer').css('top', mainheight * .9 + 'px');

    //Adjusting font sizes
    $('#whiteheader').css("font-size", mainheight / 16.2396 + "px");
    $('#blueheader').css("font-size", mainheight / 16.2396 + "px");
    $('#headerparagraph').css("font-size", mainheight / 56.25 + "px");
    $('#contentheading').css("font-size", mainheight / 47.3684 + "px");
    $('#submitbutton').css("font-size", mainheight / 69.2307 + "px");
    $('#one').css("font-size", mainheight / 55 + "px");
    $('#two').css("font-size", mainheight / 55 + "px");
    $('#three').css("font-size", mainheight / 55 + "px");
    $('#formtext').css("font-size", mainheight / 57 + "px");
    $('#footer').css("font-size", mainheight / 75 + "px");
    $('#section1').css("font-size", $(window).width() / 130.5 + "px");
    $('#section2').css("font-size", $(window).width() / 145.5 + "px");
}
4

1 回答 1

0

在 IE10 中,小提琴似乎还可以,并且可能比在 Opera 12.15 中更好,尽管我真的不知道要寻找什么。

小提琴和您描述的代码之间的主要区别在于脚本在文档中的位置。

尝试将其移动到文档<head>...</head>和短语中,如下所示:

$(function() {
    $(window).on('resize', function() {
        ...
        ...
        ...
    }).trigger('resize');
});

这将给它一个战斗的机会。

于 2013-06-15T03:22:47.027 回答