旋转木马动态内容 [英] Carousel with dynamic content

查看:142
本文介绍了旋转木马动态内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到从这里Twitter的引导旋转木马。 http://twitter.github.com/bootstrap/javascript.html#carousel

I came across a carousel from Twitter bootstrap here. http://twitter.github.com/bootstrap/javascript.html#carousel

这看起来非常好。但是,所有的图像/在这个例子中内容是硬codeD。我该如何向服务器请求新的内容,并显示在旋转木马?

It looks really good. But all the images / content in the example are hard-coded. How can I request the server for new content and show it in the carousel?

推荐答案

答案将会对每种语言进行调整,但假设你的编程在PHP中,它可能看起来是这样的:

The answer would have to be adjusted for each language, but assuming you're programing in PHP, it may look something like this:

如果您有图像的数组:

$images = ['path/to/image.jpg', 'path/to/image2.jpg', 'path/to/image3.jpg']

,那么你会通过这些图像环路,并把每一个在相应的HTML标记,像这样:

Then you'd loop through those images, and place each one in the appropriate HTML markup, like so:

<?php foreach ($images as $image) { ?>
  <div class="item">
    <img src="<?php echo $image ?>" />
  </div>
<?php } ?>

这篇关于旋转木马动态内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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