html - 使用引导程序的项目不会出现在新行上
问题描述
我试图让我的 div 占据整条线,但是其他元素仍然保持在同一条线上
例如,假设我有以下内容:
这需要在一行这需要在第一个 div 下方我正在使用 Bootstrap V4 进行布局,我没有包含所有代码。
<div class="container-fluid">
<div class="row title">
<h1>Asset Dashboard</h1>
<asp:Label ID="errorLabel" runat="server"></asp:Label>
</div>
<div class="row mainDashboard">
<div class="col-6 box1">
<h2>Current Assets</h2>
</div>
<div class="col-6 box2">
<h2>Stock Numbers</h2>
</div>
<div class="col-6 box3">
<h2>Placeholder</h2>
</div>
<div class="col-6 box4">
<h2>Placeholder</h2>
</div>
</div>
</div>
我附上了一张它目前的样子。当前布局
解决方案
默认情况下,您可以将一行拆分为 12 列。
当您说col-6时,您使用 6/12。这样做四次意味着您使用 24/12 可用列,因此这些列需要分布在两行中。
我附上了一个片段,其中我将可用空间除以 4 以适合一行中的所有 4 列。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</head>
<body>
<div class="container-fluid">
<div class="row title">
<h1>Asset Dashboard</h1>
<asp:Label ID="errorLabel" runat="server"></asp:Label>
</div>
<div class="row mainDashboard">
<div class="col-3 box1">
<h2>Current Assets</h2>
</div>
<div class="col-3 box2">
<h2>Stock Numbers</h2>
</div>
<div class="col-3 box3">
<h2>Placeholder</h2>
</div>
<div class="col-3 box4">
<h2>Placeholder</h2>
</div>
</div>
</div>
</body>
</html>
推荐阅读
- kubernetes - 如何验证配置为 https 的 Liveness 探针的证书?
- flutter - 减少每个模型类的类似 HTTP 获取方法的重复
- php - 避免将未登录用户添加到购物车 - 激活 AJAX 时
- android - 如何在Android中剪切(删除或隐藏或缩小)Material dateRangePicker(Dialog)的header_title?
- html - XPath 查询:如何找到所有有 2作为前 2 个元素?
- c++ - C ++模板类型循环和指向模板实例的非模板指针
- drupal - 初始化 Solr 核心时出错:加载类“solr.ICUCollationField”时出错
- javascript - 部署 reactjs 上传到 vps
- javascript - 在 React Typescript 中为历史对象创建和使用接口?
- c# - 使用 cs2php 将 Csharp 转换为 PHP