javascript - iphone 浏览器上的以下代码有什么问题?

标签 javascript jquery html css background-image

我使用 jQueryCollapse 插件来显示问题和答案。 问题写在选项卡上,单击选项卡时会显示答案。 当选项卡处于事件状态时意味着当时显示答案时页面高度增加,因此我必须增加背景图像的高度。 为此,我编码如下:

<script type="text/javascript">
$(document).ready(function(){
    $('#main-content1').height(1450);
    $("#t1").click(function(){
        var height = 1450;
        $('#main-content1').height(height);
    });
    $("#t2").click(function(){
        var height = 1450;
        $('#main-content1').height(height);
    });
    $("#t3").click(function(){
        var height = 1275;
        $('#main-content1').height(height);
    });
    $("#t4").click(function(){
        var height = 1250;
        $('#main-content1').height(height);
    });
</script>

id main-content 的CSS代码如下:

#main-content1 {
    margin-left:auto;
    margin-right:auto;
    margin-top:35px;
    width:900px;

    border-top-left-radius:48px;
    border-top-right-radius:48px;
    border-bottom-left-radius:48px;
    border-bottom-right-radius:48px;
    padding-bottom:20px;
    height:1450px;
    background:url(res/back-img.png) repeat;
}

页脚代码如下:

#footer {
    border-top: 0px solid #003366;
    overflow:visible;
}

.foot {
    float:left; 
    list-style-type:none;
    margin-bottom:20px;
    background-image:url(res/footer_back.png);
    background-repeat:no-repeat;
    overflow:visible;
    margin-top:-50px;
    background-position:0px 120px;
    width:182px;
    height:180px;
}

img {
    border-color:transparent;   
}

#site-footer {
    width:728px;
    margin-left:auto;
    margin-right:auto;
}

当我点击选项卡时,它会显示答案,但不会按照 iphone 移动浏览器上的 jquery 代码增加其背景图像高度。但它在 windows pc 浏览器上运行良好。 内容在页脚后面。 我做了很多谷歌,但我不知道如何解决这个问题。 请任何人帮助我解决这个问题。 提前致谢..

最佳答案

还没有测试,但尝试使用 max-height 而不是 height/或 auto height。

CSS

#main-content1 {
    margin-left:auto;
    margin-right:auto;
    margin-top:35px;
    width:900px;

    border-top-left-radius:48px;
    border-top-right-radius:48px;
    border-bottom-left-radius:48px;
    border-bottom-right-radius:48px;
    padding-bottom:20px;
    max-height:1450px; /* height:auto; */
    background:url(res/back-img.png) repeat;
}

关于javascript - iphone 浏览器上的以下代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16934453/

相关文章:

javascript - 提及检测discord bot javascript的问题

html - 如何将 3d div 移动到 1st div 旁边?

javascript - 在 Javascript 中反序列化多态 JSON

javascript - 选择 ng-grid 内的所有复选框

javascript - Angularjs jquery 状态之间的绑定(bind)

javascript - 如何从外部函数访问 'cy.load()' 等?

javascript - 我怎样才能使这些 div 在页面响应下相互移动?

javascript - AR.JS 对移动设备和 Angular 落点击事件的最终答案

javascript - 当将鼠标悬停在其中一个 td 上时,如何更改多个 td 的类别?

javascript - 我想制作一个点击后自动旋转的按钮