Bootstrap 4参考手册
实用工具 | Utilities
尺寸 | Sizing
使用我们的宽度和高度实用程序轻松制作宽或高(相对于其父项)的元素。
宽度和高度实用程序从$sizes
Sass地图中生成_variables.scss
。包括支持25%
,50%
,75%
,和100%
默认。根据需要在这里生成不同的实用程序,修改这些值。
打开getbootstrap.com上的示例
<div class="w-25 p-3" style="background-color: #eee;">Width 25%</div>
<div class="w-50 p-3" style="background-color: #eee;">Width 50%</div>
<div class="w-75 p-3" style="background-color: #eee;">Width 75%</div>
<div class="w-100 p-3" style="background-color: #eee;">Width 100%</div>
打开getbootstrap.com上的示例
<div style="height: 100px; background-color: rgba(255,0,0,0.1);">
<div class="h-25 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 25%</div>
<div class="h-50 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 50%</div>
<div class="h-75 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 75%</div>
<div class="h-100 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 100%</div>
</div>
您也可以根据需要使用max-width: 100%;
和使用max-height: 100%;
实用程序。
打开getbootstrap.com上的示例
<img class="mw-100" src="..." alt="Max-width 100%">
打开getbootstrap.com上的示例
<div style="height: 100px; background-color: rgba(255,0,0,0.1);">
<div class="mh-100" style="width: 100px; height: 200px; background-color: rgba(0,0,255,0.1);">Max-height 100%</div>
</div>
实用工具 | Utilities相关

Bootstrap 是一套用于 HTML、CSS 和 JS 开发的开源工具集。利用我们提供的 Sass 变量和大量 mixin、响应式栅格系统、可扩展的预制组件、基于 jQuery 的强大的插件系统,能够快速为你的想法开发出原型或者构建整个 app 。
主页 | https://getbootstrap.com/ |
源码 | https://github.com/twbs/bootstrap |
版本 | 4 |
发布版本 | 4.0.0-beta.2 |