简体   繁体   English

如何避免带有过渡元素的水平滚动条

[英]How to avoid horizontal scroll bar with transitioned elements

I have multiple elements in which I am using transform:translate to add a slide in transition effect. 我在多个元素中使用transform:translate在过渡效果中添加幻灯片。 This is working great. 这很好。 The issue I am having is since the elements are off the screen initially, scroll bars are appearing until the element transforms and slides over. 我遇到的问题是,因为元素最初不在屏幕上,所以出现滚动条,直到元素变形并滑过。

I am using waypoints for the scroll point and I have seen other scenarios (slidein from off the page) that the scroll bar does not appear. 我正在使用航点作为滚动点,并且看到了其他情况(页面外的幻灯片)未出现滚动条。

How can I ensure the scroll bar does not appear with these transitioned elements on my page? 如何确保滚动条不会与这些过渡元素一起出现在页面上?

The active class is added to phone-slide when the waypoint is reached. 到达航路点时, active类别将添加到phone-slide

#phone-slide {
    width: 65%;
    display: block;
    height: auto;
    position: absolute;
    right: -50%;
    margin: 10px 0;
    opacity: 0;
    transition: 1s;-webkit-transition: 1s;
}
#phone-slide.active {
    opacity: 1;
    transform: translateX(-50%);-webkit-transform: translateX(-50%);
    transition: 1s;-webkit-transition: 1s;
}

The best way would be to position phone-slide inside an absolute positioned div with hidden overflow. 最好的方法是将phone-slide放置在绝对位置的div中,并隐藏溢出。 This div can have width and height equal to the page dimensions and the content inside it will be truncated if it goes beyond with no scrollbars. 此div的宽度和高度可以等于页面尺寸,并且如果其中的内容超出范围且没有滚动条,则该内容将被截断。

See THIS solution by Jacob Ewing 请参见 雅各尤因解决方案

Another accepted answer 另一个可接受的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM