Hidden elements appear in mobile browsers when scroll

196 views Asked by At

the example below is the method I'm using for my portfolio website.

It's in 'where I live', 'how it began, and 'how I work' in about section and each slider has images and google map. I input the codes as they are in the example in my website except I deleted "overflow: hidden" because it caused black squares appearing and flickering on the screen in Chrome. The sliders are working fine with browsers in desktop computers.

The problem occurs when I use mobile browsers such as safari and chrome in Iphone and chrome in android.

Google map in the "slider" appears on top of the screen even though I didn't open it and the image in "slider3" gets stuck on the screen when I scroll the page after I close it. In mobile Safari's case, it looks okay in the beginning but once I open and close the sliders, they are stuck on top or bottom of the screen when I scroll the page.

I don't get the same problem with "slider2" maybe it's because it's on the side.

Does anyone know why the problem occurs with mobile browsers?

Thanks in advance.

jsfiddle

html

<div style="height:100%">
<span id="button">open slider 1</span>
<span id="button2">open slider 2</span>
<span id="button3">open slider 3</span>

    <div id="slider"> <span id="button4">close</span>
    </div>
    <div id="slider2"> <span id="button5">close</span> 
    </div>
    <div id="slider3"> <span id="button6">close</span> 
    </div>
</div>

css

html {
    height: 100%;
}
body {
    position: relative;
    height: 100%;
    width: 100%;
    overflow: hidden;
    margin:0;
}
.page.in {
    left: 0;
    z-index: 1;
}

#slider {
    position: absolute;
    width: 100%;
    height: 50%;
    bottom: 100%;
    background: yellow;
    transition: bottom 1s;
}
#slider.in {
    bottom:50%;
}
#slider2 {
    position: absolute;
    width: 50%;
    height: 100%;
    left:100%;
    top:0;
    background: red;
    transition: left 1s;
}
#slider2.in {
    left:50%;
}
#slider3 {
    position: absolute;
    width: 100%;
    height: 100%;
    top:100%;
    background: blue;
    transition: top 1s;
}
#slider3.in {
    top:0;
}

javascript

$('#button').click(function(){
    $('#slider').addClass('in');
});

$('#button2').click(function(){
    $('#slider2').addClass('in');
});

$('#button3').click(function(){
    $('#slider3').addClass('in');
});

$('#button4').click(function(){
    $('#slider').removeClass('in');
});

$('#button5').click(function(){
    $('#slider2').removeClass('in');
});

$('#button6').click(function(){
    $('#slider3').removeClass('in');
});
0

There are 0 answers