我尝试使用Bootstrap创建一个具有以下属性的Grid of Tiles:
它应该是这样的:
body{
background: #a5b5c5;
background:lightblue !important;
}
.box{
height: 180px;
width: 180px;
background: #fff;
border-radius: 4px;
}
.col-lg-2, .col-md-3, .col-xs-6{
margin-top: 12px !important;
}

<div class="container">
<div class="row">
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
</div>
</div>
&#13;
我应该怎样做才能达到维持我的财产的响应能力?
谢谢!
答案 0 :(得分:2)
您没有提及具体的box
尺寸,只是它们应保持方。在这种情况下,使用margin-top:30px
与Bootstrap装订线宽度相对应,并使用padding-bottom: 100%;
上的box
。
.box {
background: #fff;
border-radius: 4px;
padding-bottom: 100%;
}
.col-lg-2, .col-md-3, .col-xs-6{
margin-top: 30px !important;
}
Bootstrap 3 demo
Bootstrap 4 demo
注意:在px
上设置.box
尺寸(即:width:180px;height:180px
)将阻止框响应地调整大小
您可以通过更改边距和填充来增加装订线。例如,保证金是填充的两倍......
.col-lg-2, .col-md-3, .col-xs-6{
padding-left: 30px;
padding-right: 30px;
margin-top: 60px;
}
答案 1 :(得分:0)
尝试以下代码
<div class="container">
<div class="row">
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
</div>
<div class="row">
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
<div class="col-xs-3 col-sm-4 col-md-2">
<div class="box"></div>
</div>
</div>
</div>
body{
background: lightblue;
}
.container{
margin-top: 20px;
}
.box{
height: 100px;
background: #fff;
border-radius: 5px;
margin-bottom: 10px;
max-width: 100px;
}