Bootstrap中的媒体查询允许您根据视口大小移动,显示和隐藏内容。在LESS文件中,使用以下媒体查询在Bootstrap网格系统中创建关键断点:
/* Small devices (tablets, 768px and up) */ @media (min-width: @screen-sm-min) { ... } /* Medium devices (desktops, 992px and up) */ @media (min-width: @screen-md-min) { ... } /* Large devices (large desktops, 1200px and up) */ @media (min-width: @screen-lg-min) { ... }
有时这些扩展为包括最大宽度,以将CSS限制为较窄的设备集:
@media (max-width: @screen-xs-max) { ... } @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { ... } @media (min-width: @screen-md-min) and (max-width: @screen-md-max) { ... } @media (min-width: @screen-lg-min) { ... }