html - Bootstrap:当只有 col-12 时不使用 col 的坏风格?
问题描述
只使用是不好的风格(甚至是危险的)
<div class="row">Text</div>
代替
<div class="row"><div class="col-md-12">Text</div></div>
当需要的列不超过一列时?
解决方案
是的。.row
通常有负边距来抵消最外面的.col
左/右填充。比较这两个实例有无.col
使用。
与.col
:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<div class="container"><div class="row bg-primary"><div class="col">This text is inside row > col</div></div></div>
没有.col
:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<div class="container"><div class="row bg-primary">This text is inside row</div></div>
推荐阅读
- python - Use an array as the index of another array in Python
- amazon-web-services - EC2 CLI docker 中可用的 AWS ECR 映像
- php - 弄清楚如何为过滤器循环合并数组
- ios - 应用程序崩溃然后重新加载 tableview 数据
- mongodb - Mongo 构建嵌套文档数组的最佳实践
- javascript - 导航菜单项冲突
- ios - NSLocalizedString 总是返回大写的文本
- optaplanner - 在其中一个从范围中获取后,如何将所有相关实体变量设置为相同的值?
- mysql - SQL - 随着时间的推移价格上涨
- python - 如何构建具有多个文件和内部依赖项的项目以上传到 PyPI