[英]css animation white-space: nowrap;
I'm working on doing a css animation that would make text start at the right side of the screen, go to the left, the wrap back around and repeat. 我正在做一个CSS动画,它将使文本从屏幕的右侧开始,向左移动,回绕并重复。
I have some pretty large letters so I'm doing 我有一些相当大的字母,所以我在做
white-space: nowrap;
so the text does not go down to another line. 因此文本不会下移到另一行。
I got the animation scrolling fine with 我的动画可以很好地滚动
0% {
transform: translateX(5%)
}
100% {
transform: translateX(-100%)
}
and I put 然后我把
animation: animation-name 5s infinite;
animation-timing-function: linear;
in the class 在课堂里
Only problem I have is that the with the big letters and the white-space: nowrap is causing the page width to increase in size because the letters are pushing the page width. 我唯一的问题是大字母和空格的:nowrap导致页面宽度的大小增加,因为字母推动了页面宽度。 Is there a way around this so that the animation will still scroll but not push the page width?
有没有办法解决这个问题,使动画仍然滚动但不增加页面宽度?
example picture above. 上面的示例图片。
Just put overflow-x: hidden
in the class's parent. 只需将
overflow-x: hidden
在类的父级中即可。
body { overflow-x: hidden; } div { font-size: 150px; white-space: nowrap; animation: animation-name 5s infinite; animation-timing-function: linear; } @keyframes animation-name { 0% { transform: translateX(5%) } 100% { transform: translateX(-100%) } }
<div> Some pretty large letters </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.