简体   繁体   English

如何在JQuery和/或CSS中创建水平文本滑块?

[英]How do I create a horizontal text slider in JQuery and/or CSS?

I am trying to create a text slider to slide between 4 different sentences. 我正在尝试创建一个文本滑块,以在4个不同的句子之间滑动。 I can't get it to work, and as a matter of fact, I can't get the code to function at all. 我无法使其正常工作,事实上,我根本无法使代码发挥作用。 I need to start fresh, but I have no idea how to create one that will switch between sentences. 我需要重新开始,但是我不知道如何创建一个可以在句子之间切换的语言。

Any help on creating one with CSS3 or jQuery, as I don't really have a preference, is greatly appreciated. 非常感谢您对使用CSS3或jQuery创建一个版本的任何帮助,因为我并不十分喜欢。

Just setup for containers (using span's in this example): 只需设置容器(在此示例中使用span即可):

<div id="parent_container">
    <span>Sentence once</span>
    <span>Sentence two</span>
    <span>Sentence three</span>
    <span>Sentence four</span>
</div>

Now in your CSS, set them to position themselves side by side, preferably setting the span width to that of the parent_container. 现在,在CSS中,将它们设置为并排放置,最好将跨度宽度设置为parent_container的宽度。

In jQuery, you can now either, hide() and show() each individual <span> as necessary, or animate() the transition between the spans. 在jQuery中,您现在可以根据需要对每个单独的<span> hide()show() ,也可以对跨度之间的过渡进行animate() Per your question, it sounds like you want to animate() with a slide. 根据您的问题,这听起来像是要使用幻灯片进行animate()

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

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