javascript - javascript marquee 中的间距元素,使用 php 循环元素

标签 javascript jquery html

我使用的是 javascript marquee,它实际上工作正常,除了:

我正在使用 php 循环(工作完美)来获取在字幕中滚动的内容的每个元素。

内容正确,持续时间也不错,但我的元素彼此相邻,并且我试图在它们之间留出足够的空间。

现在它看起来像element 1element2,但我正在寻找更多

element 1                                              element 2

PHP/HTML

<div class="col-lg-12">
    <?php foreach($tickerContent as $tContent):?>
    <div class="marquee"><h2><?php echo $tContent['content']?></h2> 

Javascript:

<script type="text/javascript">
$('.marquee').marquee({
    duration: 30000,
    gap:40,
});
</script>

最佳答案

根据https://github.com/aamirafridi/jQuery.Marquee处的文档,您必须将重复设置为true

gap Gap in pixels between the tickers. Will work only when the duplicated option is set to true. Default: 20. Note: 20 means 20px so no need to use '20px' as the value.

关于javascript - javascript marquee 中的间距元素,使用 php 循环元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52298080/

相关文章:

javascript - 为什么 addEventListener 不适用于该项目?

javascript - Indesign 插件的外部配置文件

jquery - 将 jQuery 插件转换为 WordPress 插件

html - 对齐两行 flex 容器中的列

javascript - 如何使用ajax将值传递到另一个php页面

html - 带有 <ul> 的类不起作用

php - 如何在 PHP 类函数中使用 javascript?

javascript - 如何在 ES6 中将长导入语句分成多行?

javascript - 连续切换 3 个 div 的 "addClass"

javascript - 特定 anchor 标签的平滑滚动不适用于所有 anchor 标签