twitter-bootstrap - 在 Bootstrap 4-alpha 中使用媒体断点

标签 twitter-bootstrap bootstrap-4 bootstrap-5

在 Bootstrap 3 中我使用这个:

.something {
    padding: 5px;
    @media screen and (min-width: $screen-sm-min) { 
        padding: 20px;
    }
    @media screen and (min-width: $screen-md-min) { 
        padding: 40px;
    }
}

我如何在 Boostrap 4-alpha 中做同样的事情?我在他们的文档中找不到示例。 这是在variables.scss中

$grid-breakpoints: (
  xs: 0,
  sm: 576px,
  md: 768px,
  lg: 992px,
  xl: 1200px
) !default;
@include _assert-ascending($grid-breakpoints, "$grid-breakpoints");
@include _assert-starts-at-zero($grid-breakpoints);

最佳答案

更新:Bootstrap 5。

v5 breakpoints reference (latest)

<小时/>

原始答案 - Bootstrap v4:使用断点混合,如下所示:

.something {
    padding: 5px;
    @include media-breakpoint-up(sm) { 
        padding: 20px;
    }
    @include media-breakpoint-up(md) { 
        padding: 40px;
    }
}

v4 breakpoints reference

v4 alpha6 breakpoints reference

<小时/>

低于完整选项和值。

断点及向上(在值及以上之间切换):

@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) { ... }

断点和上限值:

// 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) { ... }

断点和向下(在值和向下之间切换):

@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, 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

仅断点:

@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) { ... }

仅断点值(仅在值之间切换):

// 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) { ... }

关于twitter-bootstrap - 在 Bootstrap 4-alpha 中使用媒体断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41698747/

相关文章:

javascript - 在 vue bootstrap b-table 单元格内创建一个链接

html - Bootstrap 单选按钮不起作用

javascript - (Bootstrap)悬停按钮上的响应图像?

javascript - 是否可以在不接管整个样式的情况下使用 Bootstrap?

typescript - 如何在我的 Typescript 和 React 应用程序中使用 @types/bootstrap

css - 如何使用 Bootstrap 在响应式 View 中拆分列?

html - Bootstrap : Horizontal Align H1 and dropdown button

twitter-bootstrap - Bootstrap中div内的左对齐和右对齐

javascript - 在 python 中使用 selenium 单击相同的按钮配置

angular - Angular 12 项目的 UI 框架