我正在尝试安装Twitter Bootstrap转盘与多个项目,同时保持响应.
我有一个jsfiddle来测试设置http://jsfiddle.net/Va8Un/
我想要发生的是显示4个图像,每个图片都带有标题,以便在轮播窗格中保存项目标题等等,并且应该调整大小以适应屏幕,以始终保持在同一行.现在完全忽略了将图像尺寸调整到屏幕的任何尝试,我想设置img max-width:100%;会做伎俩,但似乎并没有影响.此外,第四张图像被推送到第二行,因为图像没有调整大小:
有什么办法可以用纯CSS来解决这个问题,还是应该寻找Twitter Bootstrap之外的选项?
您可以在这里查看结果:http://jsfiddle.net/Va8Un/embedded/result/
这是HTML:
<div class="container"> <div class="carousel slide" id="myCarousel"> <div class="carousel-inner"> <div class="item active"> <ul class="thumbnails span12"> <li> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> </ul> </div> <div class="item"> ... </div> <div class="item"> ... </div> </div> <a data-slide="prev" href="#myCarousel" class="left carousel-control">‹</a> <a data-slide="next" href="#myCarousel" class="right carousel-control">›</a> </div> </diV>
解决方法
您可以单独使用引导流体网格来执行此操作,只需指定.container-fluid容器以及.row-fluid行,并将您的列表项中的每一个都包含一个.span *类,在这种情况下为3(3 * 4 = 12).
.container { margin-top: 10px; } img { max-width:100%; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.1.0/bootstrap.min.js"></script> <link href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css" rel="stylesheet" /> <div class="container-fluid"> <div class="row-fluid"> <div class="carousel slide" id="myCarousel"> <div class="carousel-inner"> <div class="item active"> <ul class="thumbnails"> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> </ul> </div> <div class="item"> <ul class="thumbnails"> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> </ul> </div> <div class="item"> <ul class="thumbnails"> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> <li class="span3"> <div class="caption"> <h5>Caption</h5> </div> <div class="thumbnail"> <img src="http://placehold.it/260x180" alt=""> </div> </li> </ul> </div> </div> <a data-slide="prev" href="#myCarousel" class="left carousel-control">‹</a> <a data-slide="next" href="#myCarousel" class="right carousel-control">›</a> </div> </div> </div>
演示:http://jsfiddle.net/Va8Un/10/
编辑:这是演示与修正
http://jsfiddle.net/Va8Un/550/