gpt4 book ai didi

jquery - Bootstrap 轮播标记错误?

转载 作者:行者123 更新时间:2023-11-28 11:43:16 24 4
gpt4 key购买 nike

我在初始化 Bootstrap Carousel 插件、运行 WordPress 3.7、尝试使用循环动态加载元素时遇到问题,但不确定出了什么问题;据我了解,我正在使用 documentation 中的数据属性.代码如下。

<div id="featured-things" class="carousel slide" data-ride="carousel" >
<!-- Indicators -->
<ol class="carousel-indicators">
<?php foreach ($slider_things as $key => $thing): ?>
<li data-target="#featured-things" <?php
if($key==0){print "class='active'";}
?> data-slide-to="<?php print $key?>" ></li>
<?php endforeach ?>
</ol>

<?php foreach ($slider_things as $key => $thing): ?>
<div class="carousel-inner">
<div class="item <?php
if($key==0){print "active";}?>" >
<a href="<?php print $thing->url; ?>"><img src="<?=$thing->feature_image ?>" alt="<?php print $thing->title; ?>" /></a>
<div class="carousel-caption">
<p><?php print $thing->caption; ?></p>
</div>
</div>
</div>
<?php endforeach ?>
<a class="left carousel-control" href="#featured-things" data-slide="prev">
<span class="icon-prev"></span>
</a>
<a class="right carousel-control" href="#featured-things" data-slide="next">
<span class="icon-next"></span>
</a>
</div>

jQuery 在页眉中加载,bootstrap.min.js 在页脚中加载。我没有使用 JS 来初始化它,因为据我了解,您不需要这样做。

结果是我看到了幻灯片,但是没有前进。

我错过了什么?

最佳答案

全部排序。意识到我应该将循环嵌套在 .carousel-inner 元素中。

<div class="carousel-inner"> 
<?php foreach ($slider_things as $key => $thing): ?>
<div class="item <?php if($key==0){print "active";}?>" >
<a href="<?php print $thing->url; ?>">
<img src="<?=$thing->feature_image ?>" alt="<?php print $thing->title; ?>" />
</a>
<div class="carousel-caption">
<p><?php print $thing->caption; ?></p>
</div>
</div>
<?php endforeach ?>
</div>

完成

关于jquery - Bootstrap 轮播标记错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20589075/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com