Rendering open sans google web fonts with bootstrap?
Asked Answered
V

2

9

I'm trying to use google web fonts open sans with bootstrap.

I'm loading the fonts with:

I have a site-specific.css that loads after bootstrap. I've tried:

.body { font-family: 'Open Sans', sans-serif;}

and also:

.bootstrap-container *,    
.bootstrap-container body, 
.bootstrap-container td, 
.bootstrap-container tr, 
.bootstrap-container div, 
.bootstrap-container p, 
.bootstrap-container form, 
.bootstrap-container input, 
.bootstrap-container select, 
.bootstrap-container textarea, 
.bootstrap-container font {
font-family: 'Open Sans', sans-serif;
}

But it seems that no matter what class selector I use, the fonts don't render and the bootstrap fonts are inherited instead. I'm not sure how to debug this.

Viewer answered 11/12, 2012 at 17:30 Comment(1)
Why don't you just customize Bootstrap?Parotic
F
9

Provided you haven't altered the core files of Bootstrap, I would make this easier on yourself and use their "customise" feature. Re-download it after placing your font names in and replace your existing bootstrap files with the new ones.

You can customise it here:

http://getbootstrap.com/customize/

Doing this will at least ensure that you don't miss something...and please, avoid using !important as suggested above (unless you really need to). Hope that helps?

Floria answered 11/12, 2012 at 17:37 Comment(3)
just insert 'Open Sans' in the box @sansFontFamily on the customize page before downloading it, and don't forget to include the link from google webfonts api in the head of your documentFooted
I'm using bootstrap from the bootstrap CDN. I'll try this method though. I just don't understand why the overriding inherited font styles seems so difficult.Viewer
Did this work for you? Have you considered accepting an answer as correct? This will help others in future with similar problems. Thanks.Floria
R
4

Use CSS !important

.bootstrap-container *,    
.bootstrap-container body, 
.bootstrap-container td, 
.bootstrap-container tr, 
.bootstrap-container div, 
.bootstrap-container p, 
.bootstrap-container form, 
.bootstrap-container input, 
.bootstrap-container select, 
.bootstrap-container textarea, 
.bootstrap-container font {
font-family: 'Open Sans', sans-serif !important; <-------- Here
}
Rosenstein answered 11/12, 2012 at 17:32 Comment(1)
!important didn't have any effect on the rendered output.Viewer

© 2022 - 2024 — McMap. All rights reserved.