简体   繁体   English

使用jQuery在div中淡出会导致内容宽度大于Mobile Safari上的视口

[英]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.

相关问题 需要div扩展以包含甚至大于页面宽度的内容 - Require div to expand to contain content even larger than page width 使用JavaScript检测视口宽度是否大于Mobile Safari上的可见宽度 - Detect if the viewport width is bigger than the visible width on Mobile Safari using javascript 如何从滚动中阻止DIV大于视口? - How to stop DIV larger than viewport from scrolling? jQuery动画在移动视口中移动所有内容 - Jquery animation moving all content in mobile viewport 在Firefox中,parent div的宽度大于孩子的宽度 - parent div's width larger than children's width in Firefox 元视口仅适用于移动设备(屏幕宽度小于640) - meta viewport only for mobile (screen width less than 640) 当图像的高度大于JQuery的宽度时,图像宽度为100% - image width 100 % when the height larger than the width with JQuery 如果浏览器视口处于特定宽度或更大,则以始终显示“ .show”的条件切换“ .show”和“ .hide”。 (响应/移动菜单) - Toggle “.show” and “.hide” with a condition that always “.show” if browser viewport is at certain width or larger. (Responsive/Mobile Menu) 淡出DIV内容后刷新 - Refresh a DIV content after faded it out 如果视口宽度小于X,是否有办法防止jQuery .submit? - Is there a way to prevent jQuery from .submit if the viewport width is less than X?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM