Boostrap集装箱净化和边界

发布于 2025-01-23 20:29:34 字数 1395 浏览 0 评论 0原文

我正在学习Bootstrap。以下是要在不同容器中显示按钮的代码:

<div class="container" style="border:1px solid #cecece;">
<h1>Bootstrap 4 simple container (.container class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p> 
</div>

<div class="container-fluid" style="border:1px solid #cecece;">
<h1>Bootstrap 4 fluid container (.container-fluid class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p>

<div class="container-md" style="border:1px solid #cecece;">
<h1>Bootstrap 4 container-md (.container-md class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p>
</div> 

结果是:

”在此处输入图像描述”

问题:

  1. 没有指定的对齐方式,但是3种类型的容器对齐(容器和容器 - MD与中心对齐,而容器 - 弗利德在左侧对齐)。是否有不同类型的容器的默认对齐?

  2. 为什么容器 - 弗利德缺少底部边框?

I'm learning bootstrap. Following is the code to display buttons in different containers:

<div class="container" style="border:1px solid #cecece;">
<h1>Bootstrap 4 simple container (.container class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p> 
</div>

<div class="container-fluid" style="border:1px solid #cecece;">
<h1>Bootstrap 4 fluid container (.container-fluid class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p>

<div class="container-md" style="border:1px solid #cecece;">
<h1>Bootstrap 4 container-md (.container-md class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p>
</div> 

The result is:

enter image description here

Question:

  1. There are no alignments specified in the code, but the 3 types of container align differently (container and container-md align to the center, while container-fliud aligns to the left). are there default alignment for different type of containers?

  2. Why is the bottom border missing for container-fliud?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡紫姑娘! 2025-01-30 20:29:34

您的第二个容器没有DIV关闭标签。下面的代码应修复它。

<div class="container" style="border:1px solid #cecece;">
<h1>Bootstrap 4 simple container (.container class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p> 
</div>

<div class="container-fluid" style="border:1px solid #cecece;">
<h1>Bootstrap 4 fluid container (.container-fluid class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p>
</div>

<div class="container-md" style="border:1px solid #cecece;">
<h1>Bootstrap 4 container-md (.container-md class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p>
</div> 

You don't have a div closing tag for your second container. The code below should fix it.

<div class="container" style="border:1px solid #cecece;">
<h1>Bootstrap 4 simple container (.container class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p> 
</div>

<div class="container-fluid" style="border:1px solid #cecece;">
<h1>Bootstrap 4 fluid container (.container-fluid class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p>
</div>

<div class="container-md" style="border:1px solid #cecece;">
<h1>Bootstrap 4 container-md (.container-md class)</h1>
<p>
<button type="button" class="btn btn-info">example button 1</button>
<button type="button" class="btn btn-danger">example button 2</button>
</p>
</div> 
萌梦深 2025-01-30 20:29:34
  1. 您可以阅读有关对齐的更多信息在这里
    请参阅此片段,
<div class="container-sm">100% wide until small breakpoint</div>
<div class="container-md">100% wide until medium breakpoint</div>
<div class="container-lg">100% wide until large breakpoint</div>
<div class="container-xl">100% wide until extra large breakpoint</div>
  1. 您尚未关闭container-fluid div
<div class="container-fluid" style="border:1px solid #cecece;">
  <h1>Bootstrap 4 fluid container (.container-fluid class)</h1>
  <p>
    <button type="button" class="btn btn-info">example button 1</button>
    <button type="button" class="btn btn-danger">example button 2</button>
  </p>
</div>
  1. you can read more about alignment here
    refer this snippet
<div class="container-sm">100% wide until small breakpoint</div>
<div class="container-md">100% wide until medium breakpoint</div>
<div class="container-lg">100% wide until large breakpoint</div>
<div class="container-xl">100% wide until extra large breakpoint</div>
  1. You haven't closed the container-fluid div
<div class="container-fluid" style="border:1px solid #cecece;">
  <h1>Bootstrap 4 fluid container (.container-fluid class)</h1>
  <p>
    <button type="button" class="btn btn-info">example button 1</button>
    <button type="button" class="btn btn-danger">example button 2</button>
  </p>
</div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文