简体   繁体   English

创建多列列表组

[英]Creating multicolumn list-group

I wanted to create multicolumn list-group to have different number of columns in different resolutions using Bootstrap (newest version 3.2.0). 我想创建多列列表组,使用Bootstrap(最新版本3.2.0)在不同分辨率下具有不同数量的列。

I used the following code to achieve this: 我使用以下代码来实现此目的:

<div class="list-group col-lg-12">
<div class="col-xs-12">
    <div class="list-group-item list-group-item-info">
    <h2 class="list-group-item-heading">My title</h2>
    </div>
</div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" >
  <a href="" class="list-group-item"><span class="badge alert-info ">0</span> item1</a>
  </div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" >
<a href="" class="list-group-item"><span class="badge alert-info ">0</span> item1</a>
  </div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" >
<a href="" class="list-group-item"><span class="badge alert-info ">0</span> item1</a>
  </div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" >
<a href="" class="list-group-item"><span class="badge alert-info ">0</span> item1</a>
  </div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" >
<a href="" class="list-group-item"><span class="badge alert-info ">0</span> item1</a>
  </div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" >
<a href="" class="list-group-item"><span class="badge alert-info ">0</span> item1</a>
  </div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" >
<a href="" class="list-group-item"><span class="badge alert-info ">0</span> item1</a>
  </div>       
</div>

and it works exactly as I wanted - Bootply demo 它完全按照我想要的方式工作 - Bootply演示

However using such solution caused one problem. 然而,使用这种解决方案导致一个问 When I want to display anything later, for example: 当我想稍后显示任何内容时,例如:

<p class="clearfix alert alert-warning text-center">
 a piece of code
</p>

it seems there is a problem with clearing floats what can be seen here: Bootply demo 看来清除浮动有问题可以在这里看到: Bootply演示

Question - can it be easily fixed or maybe I cannot put extra divs when using list-group ? 问题 - 是否可以轻松修复或者使用list-group时我不能添加额外的div? I tried to use clearfix but without any success. 我试图使用clearfix但没有任何成功。 If it cannot be fixed is there any other solution to achieve the same result using Boostrap? 如果无法修复是否有任何其他解决方案可以使用Boostrap实现相同的结果? I was looking in other components but haven't found anything other and obviously I don't want to use tables for that. 我正在寻找其他组件,但没有找到任何其他组件,显然我不想使用表格。

wrap <div class="list-group col-lg-12"> with <div class="row"> and the clearfix works then. <div class="row">包装<div class="list-group col-lg-12"> ,然后clearfix工作。 All your col-md style tags should be in a div class row or alike (controls-row could also be used). 所有col-md样式标记都应该在div类行或类似行中(也可以使用controls-row)。 Rows should also be inside a container. 行也应该在容器内。 Example here: http://www.bootply.com/azBEpNdMZq More info here: http://getbootstrap.com/css/#grid 示例: http//www.bootply.com/azBEpNdMZq此处有更多信息: http//getbootstrap.com/css/#grid

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM