jQuery在初始加载网页时调整图像大小

时间:2013-03-27 18:31:29

标签: jquery resize margins

好的,在MAC OSX上查看Google Chrome中的此页面:http://opportunityfinance.net/Test/2013conf/index.html

向下滚动以查看以下内容:

Initial Loading issue in Chrome

如果您调整浏览器窗口的大小,它将正确对齐,如下图所示:

What it Should Look Like and how it looks when resizing the browser window

所以,我的问题是如何在初次加载页面时在第二张图片中显示?谷歌浏览器最初使用以下代码将<div class="gold">的高度设置为0px:

jQuery(document).ready(function($){

    var gold = $(".gold");

    $(window).bind("resize", function(){
        gold.css({'height': gold.children(":first").children("img").height()});             
    }).trigger("resize");
});

以下是我正在使用的HTML:

<div class="gold" style="width: 100%; position: relative; margin-top: 1em; margin-bottom: 1em;">
    <div style="position: absolute; bottom: 0px; right: 0px; width: 32%;">
        <img src="images/wellsfargo.png" alt="Wells Fargo" style="border: none; max-width: 100%;">
    </div>
    <div style="float: left; width: 32%; bottom: 0px; left: 0px; position: absolute;">
        <img src="images/citi.png" alt="Citi" style="max-width: 100%; border: none;">
    </div>
    <div style="margin: 0 auto; width: 34%; position: absolute; bottom: 0px; left: 0px; right: 0px;">
        <img src="images/gs10ksb.png" alt="Goldman Sachs 10000 Small Businesses" style="border: none; max-width: 100%;">
    </div>
</div>

0 个答案:

没有答案