[英]Faded in div with jQuery causes content width to be larger than viewport on Mobile Safari
I'm fading in a div with jQuery on a button click. 我在按钮单击时使用jQuery消失在div中。 Before the div is faded in the website renders as desired.
在div消失之前,网站会根据需要进行渲染。
But when I click the button and the div gets faded in, the site increases in size somehow and I can horizontally. 但是,当我单击该按钮并且div逐渐变暗时,该站点的大小会以某种方式增加,并且我可以水平放置。 This does not happen if I dont hide and fade in the same div.
如果我不在同一div中隐藏和淡入淡出,则不会发生这种情况。
JS JS
$("#stopp").click(function()
{
$("#pil").removeClass("rotatePil");
getRotationDegrees(hjul);
$("html, body").animate({ scrollTop: $("#third").offset().top}, 1500);
//$("html, body").animate({ scrollTop: $(document).height() }, 1500);
$("#hvit-boks>h1").fadeOut(500);
$("#start,#stopp").fadeOut(500);
setTimeout(function()
{
$("#res").fadeIn(1000);
}, 500);
setTimeOut(function()
{
$("html, body").stop();
}, 1500);
});
HTML 的HTML
<h1>Snurr lykkehjulet!</h1>
<button id="start">SNURR!</button>
<button id="stopp">STOPP</button>
<div id="res">
<span id="big-res">Du fikk 145</span>
<p>
Et lykkehjul er tilfeldig. Det er imidlertid ikke tilfeldig hva kundene våre synes om skadeoppgjøret vårt.
Faktisk får vi 8,6 i gjennomsnittsscore på en skala fra 0-10 når de blir spurt om hvor fornøyde de er etter en
skade. Det skal vi være stolte av!
</p>
<button id="again">PRØV IGJEN</button>
</div> <!-- /RES -->
</div> <!-- /HVIT BOKS -->
CSS 的CSS
#hvit-boks
{
width: 90%;
padding: 40px 0 40px 0;
margin: 0 auto 0 auto;
text-align: center;
}
#hvit-boks h1
{
font-size: 30px;
}
#left
{
width: 100%;
padding: 0;
margin: 0;
}
#big-res
{
width: 50%;
padding: 0;
}
#res p
{
width: 80%;
padding: 0 0 30px 0;
}
I am not sure if my solution will work in your case or not. 我不确定我的解决方案是否适合您的情况。 but I would like you to try following solution.
但我希望您尝试以下解决方案。
can you please try and add following css to your code. 您可以尝试在代码中添加以下CSS吗?
#res
{
width: 100%;
overflow:hidden
}
please comment me back, if it works or not. 请给我回覆评论,以查看是否有效。 I will come up with better solution if possible.
如果可能的话,我会提出更好的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.