Twitter bootstrap 3 动态旋转编码器点火器
我正在制作一个内容管理系统。我可以为我的网站上载新内容,但在将图像显示到旋转木马时遇到问题。我上传的所有图片都是垂直的 例如:我上传了3张图片,看起来像这样Twitter bootstrap 3 动态旋转编码器点火器,twitter-bootstrap-3,carousel,Twitter Bootstrap 3,Carousel,我正在制作一个内容管理系统。我可以为我的网站上载新内容,但在将图像显示到旋转木马时遇到问题。我上传的所有图片都是垂直的 例如:我上传了3张图片,看起来像这样 Image 1 Image 2 Image 3 预期产出: <- Image 1 -> <- Image 2 -> <- Image 3 -> 问题:如何将所有上传图像放入旋转木马 看法 内容\图像?>宽度=100%alt=菜单> 这意味着您的每个转盘项目都有活动类,只有一个项目应该处于活动状态,而这
Image 1
Image 2
Image 3
预期产出:
<- Image 1 -> <- Image 2 -> <- Image 3 ->
问题:如何将所有上传图像放入旋转木马
看法
内容\图像?>宽度=100%alt=菜单>
这意味着您的每个转盘项目都有活动类,只有一个项目应该处于活动状态,而这是将首先显示的项目。要像@Dont Panic所说的那样制作动态旋转木马,您只需为所有项目选择一个活动项目
<!-- Indicators -->
<?php $count = 0;
$indicators = '';
foreach ($content as $row):
$count++;
if ($count === 1)
{
$class = 'active';
}
else
{
$class = '';
}?>
<div class="item <?php echo $class; ?>">
<center><img src="<?= base_url().'assets/img/'.$row->content_image?>" width="100%" alt="Menu"></center>
</div>
$indicators .= '<li data-target="#myCarousel" data-slide-to="' . $count . '" class="' . $class . '"></li>';
<?php endforeach;?>
情景:
In my indicator it displayed 6 even though the active are only 4.
所以我改进了他的代码
<div class="carousel-inner" role="listbox">
<?php $count = 0;
$indicators = '';
foreach ($content as $row):
$count++;
if ($count === 1)
{
$class = 'active';
}
else
{
$class = '';
}?>
<?php if($row->status == 'Active'):
$indicators .= '<li data-target="#myCarousel" data-slide-to="' . $count . '" class="' . $class . '"></li>' ;?><br>
<div class="item <?php echo $class; ?>">
<center><img src="<?= base_url().'uploads/'.$row->content_image?>" width="100%" alt="Menu"></center>
</div>
<?php endif;?>
<?php endforeach;?>
<ol class="carousel-indicators">
<?= $indicators; ?>
</ol>
</div>
现在它只显示了4个图像和指示器。如果您在页面或视图上列出了图像,现在您希望图像弹出,并且在弹出窗口中您需要一个旋转木马,下面的代码可能会帮助您,就像我上传的图像一样
您的所有项目都处于活动状态,只有一个项目应处于活动状态。我打赌你的内联样式会把事情搞砸-试着去掉图像上的最大宽度和宽度。我也试着删除活动的,我的所有图像现在都消失了。你不应该完全删除活动的。我说应该只有一个。如果将它们全部删除,则没有图像处于活动状态,因此第一张幻灯片中不会显示任何图像!对不起,我的不好,现在我怎样才能下一个/上一个旋转木马?它现在仍然有效。我想你在上一次评论中输入了一个错误,所以我不确定你的意思。需要明确的是:1垂直对齐与正常水平旋转木马的原始问题是否已解决?下一个/上一个呢?
I have 6 images,
4 images are active
2 images are inactive/deactivate
In my indicator it displayed 6 even though the active are only 4.
<div class="carousel-inner" role="listbox">
<?php $count = 0;
$indicators = '';
foreach ($content as $row):
$count++;
if ($count === 1)
{
$class = 'active';
}
else
{
$class = '';
}?>
<?php if($row->status == 'Active'):
$indicators .= '<li data-target="#myCarousel" data-slide-to="' . $count . '" class="' . $class . '"></li>' ;?><br>
<div class="item <?php echo $class; ?>">
<center><img src="<?= base_url().'uploads/'.$row->content_image?>" width="100%" alt="Menu"></center>
</div>
<?php endif;?>
<?php endforeach;?>
<ol class="carousel-indicators">
<?= $indicators; ?>
</ol>
</div>
note: that you have also fetched the no. of images i.e count by using num_row();
note: in header you have added these cdn
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"><!--BS CSS CDN-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><!--CDN FOR JQUERY-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script><!--CDN FOR AJAX-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script><!--BOOTSTRAP CDN-->
#model(gallery_m)
//FUNCTION TO COUNT THE NO. OF ROWS/IMAGES IN A DATABASE
public function count()
{
$this->db->select('*');
$q=$this->db->get('images');
if($q)PART ELSE IT WILL JUMP TO THE ELSE PART
{
return $q->num_rows();ADMIN/GALLERY()
}
else
{
return false;
}
}
//FUNCTION TO GET IMAGES FROM DATABASE
public function gallery()
{
$this->db->select('*');
$q= $this->db->get('images');
if($q->num_rows()>0)
{
return $q->result();
}
else
{
return false;
}
}
#controller(Admin)
public function gallery()
{
$this->load->model('gallery_m');
$data['images']= $this->gallery_m->gallery();
$data['count']= $this->gallery_m->count();
if($data['images'])
{
$this->load->view('gallery', $data);
}
}
#view(gallery)
<!--begin modal window-->
<div class="modal fade" id="myModal">
<div class="modal-dialog modal-lg"><!--MODEL-LG IS USED FOR BIGGER MODEL-->
<div class="modal-content">
<div class="modal-header">
<div class="pull-left">Gallery</div><!--HEADER TITLE-->
<button type="button" class="close" data-dismiss="modal" title="Close"> <span class="glyphicon glyphicon-remove"></span></button><!--USING THE REMOVE MODEL ICON-->
</div>
<div class="modal-body">
<!--CAROUSEL CODE GOES HERE-->
<!--begin carousel-->
<div id="myGallery" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<?php for($i=1; $i <= $count; $i++):?><!--USING FORLOOP TO MAKE THE FIRST ITEM ACTIVE WHEN CONDITION $==1 IS SATISFIED-->
<?php if($i==1)
{
?>
<div class="carousel-item active"><img src="<?= $image->image ?>" alt="images" style="height: 800px; width:916px">
</div>
<?php
}
else
{
?>
<?php foreach($images as $image):?><!--USE OF SECOND FOREACH TO DISPLAY IMAGES THAT WE FERCHED FROM DATABASE-->
<div class="carousel-item"> <img src="<?= $image->image ?>" alt="images" style="height: 600px; width:916px">
</div>
<?php endforeach;?><!--END OF SECOND FOREACH LOOP-->
<?php
}
?>
<?php endfor;?><!--END OF FORLOOP-->
<!--end carousel-inner--></div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#myGallery" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#myGallery" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div><!--end carousel-->
</div> <!--end modal-body-->
<div class="modal-footer">
<div class="pull-left">
</div>
<button class="btn-sm close" type="button" data-dismiss="modal">Close</button>
</div><!--end modal-footer-->
</div><!--end modal-content-->
</div><!--end modal-dialoge-->
</div><!--end myModal-->
<!-- Delete Button-->
<button type="submit" class="btn btn-danger remove" id="<?= $image->id?>"> Delete</button>
<!--Update anchor-tag-->
<?=anchor("admin/edit/{$image->id}", 'Edit', ['class'=>'btn btn-primary']);?>
<?php endforeach;?>