如何改变Bootstrap的全局默认字体大小? [英] How to change Bootstrap's global default font size?

查看:5323
本文介绍了如何改变Bootstrap的全局默认字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bootstrap的全局默认字体大小为14px,行高为1.428。如何更改其默认全局设置?



我需要在所有多个条目中更改bootstrap.min.css吗?



http://getbootstrap.com/customize/



在此页面上自定义您想要的任何内容,然后您可以下载具有自己的字体大小和任何其他您想要更改的自定义构建。



不建议直接改变CSS文件(或者只是添加重写Bootstrap CSS的新CSS样式),因为其他Bootstrap样式的值来自基本字体大小。例如:



https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_variables.scss#L52



您可以看到基本字体大小用于计算h1,h2,h3等的大小。如果刚刚更改CSS中的字体大小(或添加您自己的覆盖字体大小)所有其他值根据Bootstrap的设计,在计算中使用的字体大小将不再成比例准确。



正如我所说,你最好的办法是使用自己的自定义工具。



如果您使用的是SASS或LESS,那么在编译之前,您将在变量文件中更改字体大小。


Bootstrap's global default font-size is 14px, with a line-height of 1.428. How can I change its default global settings?

Will I have to change bootstrap.min.css in all the multiple entries?

解决方案

There are several ways but since you are using just the CSS version and not the SASS or LESS versions, your best bet to use Bootstraps own customization tool:

http://getbootstrap.com/customize/

Customize whatever you want on this page and then you can download a custom build with your own font sizes and anything else you want to change.

Altering the CSS file directly (or simply adding new CSS styles that override the Bootstrap CSS) is not recommended because other Bootstrap styles' values are derived from the base font size. For example:

https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_variables.scss#L52

You can see that the base font size is used to calculate the sizes of the h1, h2, h3 etc. If you just changed the font size in the CSS (or added your own overriding font-size) all the other values that used the font size in calculations would no longer be proportionally accurate according to Bootstrap's design.

As I said, your best bet is to just use their own Customize tool. That is exactly what it's for.

If you are using SASS or LESS, you would change the font size in the variables file before compiling.

这篇关于如何改变Bootstrap的全局默认字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆