css - 在全球范围内减少 bootstrap 4 中所有内容的大小
问题描述
有没有办法在全球范围内将 Bootstrap 4 的所有尺寸减少一定数量?
对于我的桌面管理员来说,常规尺寸有点大。与其从引导程序和自定义类中添加小类来获得我想要的大小,不如我可以更新引导程序中的变量,这将减少各处的大小(填充、边距、字体大小等)。
解决方案
在 Boostrap 4 中:
body {
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
}
这里的字体大小定义为1rem
. 在所有 Bootstrap CSS 中,事物的大小都在rem
其中root em
进行更新:
目前在 Bootstrap 4 中:
:root {
--blue: #007bff;
... colours ...
--dark: #343a40;
--breakpoint-xs: 0;
--breakpoint-sm: 576px;
--breakpoint-md: 768px;
--breakpoint-lg: 992px;
--breakpoint-xl: 1200px;
--font-family-sans-serif: -apple-system,BlinkMacSystemFont,"Segoe UI", ... ,Roboto;
--font-family-monospace: SFMono-Regular, ... ,monospace
}
*,::after,::before {
box-sizing: border-box
}
html {
font-family: sans-serif;
line-height: 1.15;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: transparent
}
更新:
在:root
或html
部分中,您将字体大小设置为设置大小,以 px 为单位,这取决于您要查找的内容:
html {
font-family: sans-serif;
line-height: 1.15;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: transparent
font-size: 12px; /* for example */
}
或者
:root {
...
...
font-size: 12px; /* for example */
}
这会处理所有按钮和 div 以及所有其他元素的填充和边距吗?一个大按钮使用较小的字体会看起来很奇怪。
这将处理 CSS 中大小em
或rem
单位的所有内容,我没有进行详尽的检查,但看起来它几乎涵盖了所有内容。
推荐阅读
- jenkins - 比较 Jenkins 中的构建结果
- typescript - Atlassian Forge:我在哪里可以找到触发函数的类型定义
- android - 如何在使用导航组件时隐藏片段中的视图
- java - 如何在 Java 中为字段的动态数据类型创建 POJO 类?
- compression - 关于 TDengine 数据库压缩设置的问题
- python - 用于将 html 转换为图像或 pdf 的 Python 或 Django 库
- django - 将 dropzone.js 与 django 集成时出现错误“状态为 405(不允许方法)”
- android-jetpack - 从 BottomSheetDialogFragment 导航而不显示底层片段
- excel - Excel 的外部链接
- python - 如何按顺序将第一个数组乘以第二个数组?