Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User agent stylesheet overriding my table style? Twitter Bootstrap

I'm using twitter bootstrap. My problem is that font-sizes in tables are wrong. For some reason the User Agent stylesheet is overriding the bootstrap table styles.

On the twitter bootstrap page (http://twitter.github.com/bootstrap/base-css.html) everything is of course working correctly.

In my inspector I see the following difference:

My page:

CSS style for my page

The twitter bootstrap page:

CSS style for twitter bootstrap page

So definitely the problem is that the user agent stylesheet is overriding the bootstrap styles.

I haven't been able to figure out why this is different on my page and the twitter bootstrap page.

Most of the other CSS is working fine.

My css import:

<link href="/media/bootstrap/css/bootstrap.css" rel= "stylesheet">

CSS import on twitter bootstrap page:

<link href="assets/css/bootstrap.css" rel="stylesheet">
like image 645
Riku Avatar asked Feb 16 '12 09:02

Riku


4 Answers

I actually figured this out myself. I had the <!DOCTYPE html> tag wrongly written. So if you have this problem make sure the doctype declaration is correct!

like image 76
Riku Avatar answered Oct 19 '22 17:10

Riku


Please import the docs.css into your application as well. If I must say so, you must have realized that the Twitter Bootstrap Docs are using bootstrap.css and a custom docs.css. Try doing, which you can download from the github package. Then, try playing around with the table classes in docs. css without messing with the master css. Or try adding DOCTYPE in headers.

<link href="/media/bootstrap/css/docs.css" rel= "stylesheet">
like image 33
Ali Gajani Avatar answered Oct 19 '22 18:10

Ali Gajani


If declaring <!DOCTYPE html> in the very beginning doesn't work, then it's probably not your user-agent style sheet casuing it. It may be Bootstrap's style sheet overriding your styles (I've had this problem). Make sure your style sheet is linked to after Bootstrap's style sheet in your HTML.

<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/mystylesheet.css" rel="stylesheet"> <!-- Your custom style sheet goes after Bootstrap's -->
like image 1
bgashler1 Avatar answered Oct 19 '22 18:10

bgashler1


I had the same issue as the OP. I wanted lovely small text and some user stylesheet was overiding it and putting:

font-size: medium;

When I wanted:

font-size:8pt;

I placed the following at the top of my HTML page:

<!DOCTYPE html>

All was good then, a bad habit to get into to not declare doctype at the top. All user stylesheets have now gone.

To discover what is overriding what on your CSS it is always a good idea to inspect element (F12) and you can modify and untick attributes on the fly until you get to right, then update your CSS file with it!

However if you do have a user stylesheet issue, these values will be locked.

like image 1
Rmj86 Avatar answered Oct 19 '22 17:10

Rmj86