开发者

I can't get rid of this scrollbar

I have website with a form sliding from the right when you click on a blue button:

As you can probably see, the horizontal scrollbar allows visitors to see the sliding form before and after it becomes active. That's the problem, I hope someone can help me solve it.

This is the jQuery code I'm using:

<script type="text/javascript">
            $(document).ready(function()
            {
                function positioningForm()
                {
                    $('#insider').css({"right": "-535px"}).show();
                }
                function slideFromRight()
                {
                    $('#insider').animate(
                    {right: "0px"},
                    {dur开发者_StackOverflow中文版ation: 'slow',easing: 'easeOutElastic'});
                }
                function slideToBeginning() {
                    $('#insider').animate(
                    {right: "-535px"},
                    {duration: 'slow',easing: 'easeOutElastic'});
                }

                // Positioning the insider at the time of page loading
                positioningForm();

                var state = 0;
                $('.right_btn').click(function() {
                    if(state == 0) {
                        //do the magic :)
                        slideFromRight();
                        state = 1;
                    } else if( state == 1) {
                        //unroll the magic :)
                        slideToBeginning();
                        state=0;
                    }
                });
            });
        </script>


add this to css:

body{overflow-x:hidden;}

if you don't have an organized block of css, just add style="overflow-x:hidden" to your body tag like so:

<body style="overflow-x:hidden;">

solved. ;)


The scroll appears because you are not hiding, but moving the element to the right. It is all about css. Possible solutions are overflow-x:hiddenMDN MSDN or adding adding a container with display:noneMDN MSDN to the non-button part.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜