容器是 Bootstrap 中最基本的布局元素,在使用默认网格系统时需要它们。 Bootstrap 有两种主要的布局,即流体布局和固定布局。
- Fluid-layout :这使用 bootstrap .container-fluid类进行布局。此布局使用比例值,例如内容块、图像或任何其他项目的测量单位。用于创建 100% 宽并覆盖所有屏幕宽度的元素。当您随意更改浏览器的宽度时,流体布局会不断调整大小,不会在两侧留下多余的空间,因此它被称为“流体布局”。
- Fixed-layout :这使用 bootstrap .container类进行布局。固定布局具有特定的像素宽度值,可在媒体查询的帮助下更改其宽度值。它提供了一个响应式固定宽度的容器。当指定像素值时,固定布局会在几个特定宽度的块中调整大小。
实施的分步指南:
步骤 1:在所有其他样式表之前将 Bootstrap 和 jQuery CDN 包含到标签中以加载我们的 CSS。
第 2 步:添加标记并向其添加您需要的CSS 属性。
第 3 步:创建一个新的 第 4 步:信息必须放置在 .container(固定布局)或 .container-fluid(流体布局)类中,以便正确对齐和填充。 示例 1:此示例显示固定布局。
Also known as a .container layout. Fixed
layout has specific pixel width values
that change its width value with the help
of media queries. It provides a responsive
fixed width container. Fixed layout resizes
in chunks at several certain widths so
that's why its called as “fixed width”
because pixels values are specified.
Also known as the .container-fluid
layout. This layout uses proportional
values such as measuring unit for a
block of content, images or any other
item. Used for creating an element that
is 100 % wider and covers all the screen
width. Fluid layout continuously resizes
as you change the width of your browser
by any amount, leaving no extra empty
space on the sides ever Hence it is named
as “fluid layout”.
A Computer Science portal for geeks. It
contains well written, well thought and
well explained computer science and
programming articles. If you’re preparing
out for a tech interview with a product-
based company or planning to do the same?
Are you looking for a DSA Course? Don’t
know how to begin with data structures and
algorithms? .. Then you are at the right
place.
A Computer Science portal for geeks. It
contains well written, well thought and
well explained computer science and
programming articles. If you’re preparing
out for a tech interview with a product-
based company or planning to do the same?
Are you looking for a DSA Course? Don’t
know how to begin with data structures and
algorithms? .. Then you are at the right
place.
输出: 示例 2:此示例显示了流体布局的工作方式。
Also known as the .container-fluid
layout. This layout uses proportional
values such as measuring unit for a
block of content, images or any other
item. Used for creating an element that
is 100 % wider and covers all the screen
width. Fluid layout continuously resizes
as you change the width of your browser
by any amount, leaving no extra empty
space on the sides ever Hence it is named
as “fluid layout”.
输出: 示例 3:此示例向我们展示了固定布局和流体布局之间的区别。针对固定和流体布局的不同屏幕尺寸实现了不同的输出。
A Computer Science portal for geeks. It
contains well written, well thought and
well explained computer science and
programming articles. If you’re preparing
out for a tech interview with a product-
based company or planning to do the same?
Are you looking for a DSA Course? Don’t
know how to begin with data structures and
algorithms? .. Then you are at the right
place.
A Computer Science portal for geeks. It
contains well written, well thought and
well explained computer science and
programming articles. If you’re preparing
out for a tech interview with a product-
based company or planning to do the same?
Are you looking for a DSA Course? Don’t
know how to begin with data structures and
algorithms? .. Then you are at the right
place.
输出: 注意:固定布局会以几个特定的宽度分块调整大小,而流体布局会随着您任意更改浏览器的宽度而不断调整大小。 HTML
Fixed Layout
HTML
Fluid Layout
HTML
Fluid Layout
Fixed Layout
HTML
Fluid Layout
HTML
Fluid Layout
Fixed Layout