Html Bootstrap 嵌套网格系统最佳实践
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23120451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap Nested Grid Systems Best Practices
提问by Ben Pearce
I'm trying to create a site using bootstrap and no external css. It seems I can achieve many of my formatting goals using nested grid systems.
我正在尝试使用引导程序创建一个站点,而没有外部 css。使用嵌套网格系统似乎可以实现我的许多格式化目标。
e.x.
前任
<div class="container-fluid bs-docs-grid">
<div class="row show-grid">
<div class="col-md-6">
<div class="row show-grid">
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
</div>
</div>
<div class="col-md-6">
</div>
</div>
</div>
Is this a reasonable practice?
这是一种合理的做法吗?
采纳答案by David Taiaroa
Your code for the nesting is exactly what Bootstrap recommends: http://getbootstrap.com/css/#grid-nesting
and
https://getbootstrap.com/docs/4.4/layout/grid/#nesting(for Bootstrap 4)
您的嵌套代码正是 Bootstrap 推荐的:http: //getbootstrap.com/css/#grid-nesting
和
https://getbootstrap.com/docs/4.4/layout/grid/#nesting(对于 Bootstrap 4)
Unless you have a specific need for the show-grid and bs-docs-grid classes, there's no need to include them. They aren't part of the base bootstrap CSS.
除非您对 show-grid 和 bs-docs-grid 类有特定需求,否则无需包含它们。它们不是基本引导 CSS 的一部分。
If you can achieve the layout you need using nested grids, I would certainly use them. They will save you time and reduce potential browser compatibility issues.
如果您可以使用嵌套网格实现所需的布局,我肯定会使用它们。它们将节省您的时间并减少潜在的浏览器兼容性问题。
Good luck!
祝你好运!