Bootstrap 3 断点和媒体查询 [英] Bootstrap 3 breakpoints and media queries
问题描述
在 Bootstrap 3 媒体查询文档上,它说:
我们在 Less 文件中使用以下媒体查询在我们的网格系统中创建关键断点.
We use the following media queries in our Less files to create the key breakpoints in our grid system.
超小型设备(手机,小于 768 像素):没有媒体查询,因为这是 Bootstrap 中的默认设置
Extra small devices (phones, less than 768px): No media query since this is the default in Bootstrap
小型设备(平板电脑,768 像素及以上):@media (min-width: @screen-sm-min) { ... }
Small devices (tablets, 768px and up):
@media (min-width: @screen-sm-min) { ... }
中型设备(台式机,992 像素及以上):@media (min-width: @screen-md-min) { ... }
Medium devices (desktops, 992px and up):
@media (min-width: @screen-md-min) { ... }
大型设备(大型台式机,1200 像素及以上):@media (min-width: @screen-lg-min) { ... }
Large devices (large desktops, 1200px and up):
@media (min-width: @screen-lg-min) { ... }
我们是否应该能够使用 @screen-sm
、@screen-md
和 @screen-lg
名称我们的媒体查询也是如此?因为它对我不起作用.我必须使用诸如 @media (min-width: 768px) {...}
之类的像素测量值才能工作.我做错了什么吗?
Are we supposed to be able to use the @screen-sm
, @screen-md
, and @screen-lg
names in our media queries as well? Because it doesn't work for me. I have to use pixel measurements such as @media (min-width: 768px) {...}
before it will work. Am I doing something wrong?
另外,对超小型设备的 480px 的引用是错误的吗?不应该说高达 767 像素吗?(从文档中删除)
推荐答案
Bootstrap 4 Media Queries
// 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) { ... }
Bootstrap 4 在 Sass 中提供了源 CSS,您可以通过 Sass Mixins 包含:
Bootstrap 4 provides source CSS in Sass that you can include via 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;
}
}
引导程序 3 媒体查询
/*========== Mobile First Method ==========*/
/* Custom, iPhone Retina */
@media only screen and (min-width : 320px) {
}
/* Extra Small Devices, Phones */
@media only screen and (min-width : 480px) {
}
/* Small Devices, Tablets */
@media only screen and (min-width : 768px) {
}
/* Medium Devices, Desktops */
@media only screen and (min-width : 992px) {
}
/* Large Devices, Wide Screens */
@media only screen and (min-width : 1200px) {
}
/*========== Non-Mobile First Method ==========*/
/* Large Devices, Wide Screens */
@media only screen and (max-width : 1200px) {
}
/* Medium Devices, Desktops */
@media only screen and (max-width : 992px) {
}
/* Small Devices, Tablets */
@media only screen and (max-width : 768px) {
}
/* Extra Small Devices, Phones */
@media only screen and (max-width : 480px) {
}
/* Custom, iPhone Retina */
@media only screen and (max-width : 320px) {
}
引导程序 2.3.2 媒体查询
@media only screen and (max-width : 1200px) {
}
@media only screen and (max-width : 979px) {
}
@media only screen and (max-width : 767px) {
}
@media only screen and (max-width : 480px) {
}
@media only screen and (max-width : 320px) {
}
资源来自:https://scotch.io/quick-tips/default-sizes-for-twitter-bootstraps-media-queries
这篇关于Bootstrap 3 断点和媒体查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!