bootstrap layout.css,布局 | Layout

布局 | Layout

布局您的 Bootstrap 项目的组件和选项,包括包装容器、强大的网格系统、灵活的媒体对象和响应性实用工具类。

Containers

容器是 Bootstrap 中最基本的布局元素,在使用我们的默认网格系统时是必需的。选择响应式固定宽度的容器(意味着它max-width在每个断点处的变化)或流体宽度(意味着它100%始终是宽的)。

虽然容器可以嵌套,但大多数布局不需要嵌套容器。

打开 getbootstrap.com 上的示例

使用.container-fluid对于一个全宽度容器,跨越视口的整个宽度。

打开 getbootstrap.com 上的示例

...

响应断点

由于 Bootstrap 是首先开发为可移动的,所以我们使用了以下几个媒体查询为我们的布局和接口创建合理的断点。这些断点主要基于最小视口宽度,允许我们随着视口的变化而扩展元素。

引导程序主要在源文件中使用以下媒体查询范围(或断点),用于布局、网格系统和组件。

// Extra small devices (portrait phones, less than 576px)

// No media query since this is the default in Bootstrap

// Small devices (landscape phones, 576px and up)

@media (min-width: 576px) { ... }

// Medium devices (tablets, 768px and up)

@media (min-width: 768px) { ... }

// Large devices (desktops, 992px and up)

@media (min-width: 992px) { ... }

// Extra large devices (large desktops, 1200px and up)

@media (min-width: 1200px) { ... }

由于我们用 Sass 编写了源 CSS,所以我们的所有媒体查询都可以通过 Sass Mixins 获得:

@include media-breakpoint-up(xs) { ... }

@include media-breakpoint-up(sm) { ... }

@include media-breakpoint-up(md) { ... }

@include media-breakpoint-up(lg) { ... }

@include media-breakpoint-up(xl) { ... }

// Example usage:

@include media-breakpoint-up(sm) {

.some-class {

display: block;

}

}

我们偶尔会使用其他方向的媒体查询(给定的屏幕尺寸或更小):

// Extra small devices (portrait phones, less than 576px)

@media (max-width: 575px) { ... }

// Small devices (landscape phones, less than 768px)

@media (max-width: 767px) { ... }

// Medium devices (tablets, less than 992px)

@media (max-width: 991px) { ... }

// Large devices (desktops, less than 1200px)

@media (max-width: 1199px) { ... }

// Extra large devices (large desktops)

// No media query since the extra-large breakpoint has no upper bound on its width

同样,这些媒体查询也可以通过 Sass Mixins 获得:

@include media-breakpoint-down(xs) { ... }

@include media-breakpoint-down(sm) { ... }

@include media-breakpoint-down(md) { ... }

@include media-breakpoint-down(lg) { ... }

还有媒体查询和混合,用于使用最小断点宽度和最大断点宽度针对单个屏幕大小。

// Extra small devices (portrait phones, less than 576px)

@media (max-width: 575px) { ... }

// Small devices (landscape phones, 576px and up)

@media (min-width: 576px) and (max-width: 767px) { ... }

// Medium devices (tablets, 768px and up)

@media (min-width: 768px) and (max-width: 991px) { ... }

// Large devices (desktops, 992px and up)

@media (min-width: 992px) and (max-width: 1199px) { ... }

// Extra large devices (large desktops, 1200px and up)

@media (min-width: 1200px) { ... }

这些媒体查询也可通过 Sass Mixins 获得:

@include media-breakpoint-only(xs) { ... }

@include media-breakpoint-only(sm) { ... }

@include media-breakpoint-only(md) { ... }

@include media-breakpoint-only(lg) { ... }

@include media-breakpoint-only(xl) { ... }

同样,媒体查询可能跨越多个断点宽度:

// Example

// Apply styles starting from medium devices and up to extra large devices

@media (min-width: 768px) and (max-width: 1199px) { ... }

针对相同屏幕大小范围的 Sass 混频器是:

@include media-breakpoint-between(md, xl) { ... }

Z-指数

几个引导程序组件使用z-indexCSS 属性,该属性通过提供第三个轴来安排内容来帮助控制布局。我们利用 Bootstrap 中的默认 z-索引尺度来设计适当的图层导航,工具提示和弹出窗口,模态等。

我们不鼓励对这些值进行定制;如果您更改了这些值,则可能需要全部更改。

$zindex-dropdown: 1000 !default;

$zindex-sticky: 1020 !default;

$zindex-fixed: 1030 !default;

$zindex-modal-backdrop: 1040 !default;

$zindex-modal: 1050 !default;

$zindex-popover: 1060 !default;

$zindex-tooltip: 1070 !default;

背景元素(如允许点击z-index忽略的背景)倾向于位于较低的,而导航和弹出使用较高的z-indexs以确保它们覆盖周围的内容。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值