Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Bootstrap's global default font size?

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?

like image 788
Chetan Avatar asked Feb 23 '15 16:02

Chetan


People also ask

Is Bootstrap's global default font-size?

Bootstrap's global default font-size is 14px, with a line-height of 1.428.

What is Bootstrap's default font?

Bootstrap 4 Default Settings Bootstrap 4 uses a default font-size of 16px, and its line-height is 1.5. The default font-family is "Helvetica Neue", Helvetica, Arial, sans-serif. In addition, all <p> elements have margin-top: 0 and margin-bottom: 1rem (16px by default).

How do I reset my default font-size?

Go to Format > Font > Font. + D to open the Font dialog box. Select the font and size you want to use. Select Default, and then select Yes.

How do I change the default font-size in Bootstrap?

If you are tied to v3, I would recommend changing that value to 1rem , and then setting html {font-size: 14px} as in the example above. This is the best way. Bootstrap 4 will magically size like v3 once you change this to 14px.


2 Answers

Bootstrap uses the variable:

$font-size-base: 1rem; // Assumes the browser default, typically 16px 

I don't recommend mucking with this, but you can. Best practice is to override the browser default base font size with:

html {   font-size: 14px; } 

Bootstrap will then take that value and use it via rems to set values for all kinds of things.

like image 64
CloudMagick Avatar answered Oct 26 '22 14:10

CloudMagick


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.

like image 35
Jake Wilson Avatar answered Oct 26 '22 14:10

Jake Wilson