引导程序 clearfix 无法按预期工作
boostrap clearfix not working as expected
在小视口尺寸 (768-992px) 下,我在使用下面的代码时遇到了一些问题。其他视口按预期工作。
在小尺寸的情况下,我希望每行四列;但是,我得到三行 4、2 和 2 列。
删除线 <div class="clearfix visible-lg-md-block"></div>
解决了小视口大小的问题,但删除它会导致中视口和大视口显示不均匀。
为什么我在小尺寸时得到了三行,我该怎么做才能得到两行?
非常感谢!
<div class="container-fluid">
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:lavender;">
Column 1<br>
Resize the browser window to see the effect. Also try to remove the div clearfix line and see what happens.
</div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:lavenderblush;">Column 2</div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:lightcyan;">Column 3</div>
<div class="clearfix visible-xs-block"></div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:lightgray;">Column 4</div>
<div class="clearfix visible-sm-block"></div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:beige;">Column 5</div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:lightyellow;">Column 6</div>
<div class="clearfix visible-lg-md-block"></div>
<div class="clearfix visible-xs-block"></div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:plum;">Column 7</div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:thistle;">Column 8</div>
</div>
</div>
参考这个:有帮助,
http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp
.row class,内部有clearfix class.
的样式
希望对你有帮助,
谢谢!!!
您尝试过使用 class="clearfix visible-md-block visible-lg-block"
吗?
您当前的代码获得:
- -lg: 1,33 行
- -md: 1,33 行
- -sm: 2 行
- -xs: 2,66 行
您的结构预计会在 -xs 大小上产生 3 行!
您必须将所有 col-xs-4
更改为 col-xs-3
才能获得 2 行
/* Defining Bootstrap grid */
The Bootstrap grid system has four classes:
xs (for phones)
sm (for tablets)
md (for desktops)
lg (for larger desktops)
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-6"> Demo </div>
/* Above code will give you 2 columns for small devices */
Refer : http://getbootstrap.com/examples/grid/
在小视口尺寸 (768-992px) 下,我在使用下面的代码时遇到了一些问题。其他视口按预期工作。
在小尺寸的情况下,我希望每行四列;但是,我得到三行 4、2 和 2 列。
删除线 <div class="clearfix visible-lg-md-block"></div>
解决了小视口大小的问题,但删除它会导致中视口和大视口显示不均匀。
为什么我在小尺寸时得到了三行,我该怎么做才能得到两行?
非常感谢!
<div class="container-fluid">
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:lavender;">
Column 1<br>
Resize the browser window to see the effect. Also try to remove the div clearfix line and see what happens.
</div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:lavenderblush;">Column 2</div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:lightcyan;">Column 3</div>
<div class="clearfix visible-xs-block"></div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:lightgray;">Column 4</div>
<div class="clearfix visible-sm-block"></div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:beige;">Column 5</div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:lightyellow;">Column 6</div>
<div class="clearfix visible-lg-md-block"></div>
<div class="clearfix visible-xs-block"></div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:plum;">Column 7</div>
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="background-color:thistle;">Column 8</div>
</div>
</div>
参考这个:有帮助,
http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp
.row class,内部有clearfix class.
的样式希望对你有帮助, 谢谢!!!
您尝试过使用 class="clearfix visible-md-block visible-lg-block"
吗?
您当前的代码获得:
- -lg: 1,33 行
- -md: 1,33 行
- -sm: 2 行
- -xs: 2,66 行
您的结构预计会在 -xs 大小上产生 3 行!
您必须将所有 col-xs-4
更改为 col-xs-3
才能获得 2 行
/* Defining Bootstrap grid */
The Bootstrap grid system has four classes:
xs (for phones)
sm (for tablets)
md (for desktops)
lg (for larger desktops)
<div class="col-lg-2 col-md-2 col-sm-3 col-xs-6"> Demo </div>
/* Above code will give you 2 columns for small devices */
Refer : http://getbootstrap.com/examples/grid/