我使用 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/