你好,我想制作一个滚动文本的栏,就像新闻中的这个一样。
我的文本对于其最大宽度而言太长,并且其溢出属性设置为
overflow-x: auto;
因此被剪切。但我正在寻找这样一个栏,它会自动滚动我的文本(向右),当他完成时,向另一个方向滚动回来(向左)。这是我的 css 文本:
#text {
display: block;
color: white;
position: absolute;
width: 50%;
left: 0%;
text-align: center;
font-size: 8vw;
margin-top: 8.5%;
font-variant: small-caps;
text-shadow: 0 0 20px #000;
text-align: center;
z-index: 2;
overflow-x: auto;
white-space: nowrap;
line-height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?实际上答案可以是 css、js 或 jquery。没关系。
我有一个随机生成的文本到div.并且此文本具有不同的宽度,具体取决于当前生成的内容.而且我希望这个文本只有在太大的时候才会出现.HTML:
<div id="random_word"> <!--here appears something--> </div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#random_word {
color: white;
position: absolute;
width: 50%;
left: 0%;
text-align: center;
font-size: 8vw;
margin-top: 22%;
font-variant: small-caps
text-shadow: 0 0 20px #000;
text-align: center;
z-index: 2;
overflow: hidden;
white-space: nowrap;
line-height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
我在互联网上找到了这个css属性:overflow-x:-webkit-marquee;
但我不知道如何使用它.有人可以帮忙吗?