简体   繁体   English

从左到右 TEXT SLIDER

[英]Left to Right TEXT SLIDER

enter image description here Hey guys, do you know why this is happening?在此处输入图片描述嘿伙计们,你知道为什么会这样吗? I have set the max width to the screen size.我已将最大宽度设置为屏幕尺寸。 I also tried to take the slider into a new div, but it still keeps going like it want to go.我还尝试将 slider 放入一个新的 div 中,但它仍然像它想要的 go 一样继续运行。 Im trying to do a infinite slider that goes from left to right, and viceversa.我试图做一个从左到右的无限 slider,反之亦然。 But I am stucked with this problem, the slider goes over the width of the page and it creates more and more size to the right.但是我遇到了这个问题,slider 超出了页面的宽度,并且它在右侧创建了越来越多的大小。 Do you know if there is any way to do this in a proper way, or if i can somehow remove the text by the way it goes away from the screen?您知道是否有任何方法可以以适当的方式执行此操作,或者我是否可以通过文本离开屏幕的方式以某种方式删除文本? Thxx谢谢

 .slide { margin-top: 25vw; margin-bottom: 12rem; animation: 10s slide; animation-iteration-count: infinite; animation-direction: alternate; color: transparent; -webkit-text-stroke: 2px #f1efd4; font-size: 8vw; white-space: nowrap; letter-spacing: 0.1em; word-spacing: 0.3em; } @keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(0); } }
 <h3 class="slide" style="animation-direction: alternate-reverse; -webkit-text-stroke: 2px #424239;"> &nbsp;&nbsp;Sobre mi Sobre mi Sobre mi &nbsp;&nbsp;</h3>

Just use overflow-y: hidden If that's what you are trying to achieve.只需使用overflow-y: hidden如果这就是您要实现的目标。

 .slide { margin-top: 25vw; margin-bottom: 12rem; animation: 10s slide; animation-iteration-count: infinite; animation-direction: alternate; color: transparent; -webkit-text-stroke: 2px #f1efd4; font-size: 8vw; white-space: nowrap; letter-spacing: 0.1em; word-spacing: 0.3em; overflow-x: hidden; } @keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(0); } }
 <h3 class="slide" style="animation-direction: alternate-reverse; -webkit-text-stroke: 2px #424239;"> &nbsp;&nbsp;Sobre mi Sobre mi Sobre mi &nbsp;&nbsp;</h3>

To achieve this, you have to hide the overflow.为此,您必须隐藏溢出。

 .slide { margin-top: 25vw; margin-bottom: 12rem; animation: 10s slide; animation-iteration-count: infinite; animation-direction: alternate; color: transparent; -webkit-text-stroke: 2px #f1efd4; font-size: 8vw; white-space: nowrap; letter-spacing: 0.1em; word-spacing: 0.3em; } body {overflow-x: hidden; /* overflow-y: hidden; uncomment if you dont want the other scrollbar */} @keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(0); } }
 <h3 class="slide" style="animation-direction: alternate-reverse; -webkit-text-stroke: 2px #424239;"> &nbsp;&nbsp;Sobre mi Sobre mi Sobre mi &nbsp;&nbsp;</h3>

Hiding the overflow in the body instead of the text will prevent it from being cut off, which is why I didn't do it on the text.将溢出隐藏在正文而不是文本将防止它被切断,这就是为什么我没有在文本上这样做。 You can also uncomment the / overflow-y: hidden;你也可以取消注释 / overflow -y: hidden; / part if you would like there to be no scrollbars. / 部分,如果您希望没有滚动条。

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

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