[英]Resizing window causes next div to show in responsive horizontal scrolling website
The website displays fine on all resolutions, the problem arises when the window is resized. 该网站在所有分辨率下均显示正常,调整窗口大小时会出现问题。
So what I have done is create 5 div containers and given each container 20% width within a body of 500% width. 因此,我要做的是创建5个div容器,并在500%宽度的主体内给每个容器20%的宽度。 Below is one of them
以下是其中之一
<div id="workslide" class="container">
//some a tags goes here
</div>
CSS 的CSS
.container {
bottom: 0;
float: left;
height: 100%;
margin: 0;
position: relative;
width: 20%;
}
Within each container is an img slide which is set in css background-size: contain;
每个容器中都有一个img幻灯片,该幻灯片设置为css
background-size: contain;
which scales correctly for all resolutions. 可以针对所有分辨率正确缩放。 When the window is resized from the left, for example, this happens.
例如,当从左侧调整窗口大小时,就会发生这种情况。 The previous div bleeds in :
先前的div在以下位置出血:
Any ideas would be appreciated ! 任何想法,将不胜感激 !
I implemented a fix for the problem after the pointer from Matt. 我在Matt的指导下实施了针对该问题的修复程序。 Works perfect now:
现在可以完美运行:
//added following lines of code within document ready:
$(window).resize(function() {
$(window).scrollLeft($(/*element you have scrolled to*/).offset().left);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.