doudan1123 2018-10-12 06:11
浏览 72
已采纳

codeIgniter中的错误滑块轮播引导程序

My website already connect with database, but somehow bootstrap carousel that I use for slider not working... What I expected the image will be like this: < image > < image > < image > But what I get is:

<image>  
<image> 
<image> 

I don't know what's wrong with my code... Can somebody help me?

 <!--- Slider -->    
        <div id="myCarousel" class="carousel slide" data-ride="carousel">
            <div class="carousel-inner">
                <?php foreach ($slider as $slider): ?>
                <div class="item active">
                    <img src="<?php echo base_url('upload/slider/'.$slider->image)?>">
                    <div class="carousel-caption">
                        <h3><?php echo $slider->name?></h3>
                    </div>
                </div>
                <?php endforeach; ?> 
            </div>
            <a class="left carousel-control" href="#myCarousel" data-slide="prev">
                <span class="glyphicon glyphicon-chevron-left"></span>
                <span class="sr-only"> previous</span>
            </a>
            <a class="right carousel-control" href="=#myCarousel" data-slide="next">
                <span class="glyphicon glyphicon-chevron-right"></span>
                <span class="sr-only"> next </span> 
            </a>
        </div>
  • 写回答

1条回答 默认 最新

  • duanbinren8906 2018-10-12 06:22
    关注

    I use this and work fine.

    <div id="myCarousel" class="carousel slide" data-ride="carousel" >
        <ol class="carousel-indicators">
            <?php for($j=0; $j<count($slider); $j++) {?>
                <li data-target="#myCarousel" data-slide-to="<?php echo $j; ?>" class=""></li>
            <?php }; ?>
        </ol>
    
        <div class="carousel-inner" role="listbox" >
            <?php $i=1;
            foreach ($slider as $slider) { ?>
    
                <div class="item <?php echo ($i==1) ? "active" : "" ?>">
    
                    <img src="<?php echo base_url('upload/slider/'.$slider->image) ?>" alt="" class="img-responsive" style="width:100%" title="">
    
                    <div class="carousel-caption">
                        <h3><?php echo $slider->name?></h3>
                    </div>
    
                </div>
            <?php $i++; } ?>
        </div>
    
         <a class="left carousel-control" href="#myCarousel" data-slide="prev">
           <span class="glyphicon glyphicon-chevron-left"></span>
           <span class="sr-only"> previous</span>
         </a>
    
        <a class="right carousel-control" href="=#myCarousel" data-slide="next">
           <span class="glyphicon glyphicon-chevron-right"></span>
           <span class="sr-only"> next </span> 
        </a>
    
        <div class="carousel-line"></div>
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历