jquery / css:使文本内部div水平滚动像一个新闻记者没有插件 [英] jquery / css: make text inside div scroll horizontally like a news ticker no plugin

查看:90
本文介绍了jquery / css:使文本内部div水平滚动像一个新闻记者没有插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


推荐答案

这里有一个快速的解决方案:
http://jsfiddle.net/4mTMw/8/

Here's a quick solution to this: http://jsfiddle.net/4mTMw/8/

var marquee = $('div.marquee');
marquee.each(function() {
    var mar = $(this),indent = mar.width();
    mar.marquee = function() {
        indent--;
        mar.css('text-indent',indent);
        if (indent < -1 * mar.children('div.marquee-text').width()) {
            indent = mar.width();
        }
    };
    mar.data('interval',setInterval(mar.marquee,1000/60));
});​

使用文本缩进 css属性,你可以这样做。

Using the text-indent css property, you can do this rather simply.

这篇关于jquery / css:使文本内部div水平滚动像一个新闻记者没有插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆