Twitter Bootstrap makes background image dissappear - css

In my main css file I have this:
background: url(/images/bg_1.jpg) repeat;
And it works fine, I have a background image showing. But when I include the bootstrap.min.css v3.1.1 file in the html (above my css file in the code), the background just goes white.
<link rel="stylesheet" type="text/css" href="/CSS/bootstrap.min.css" />
Any ideas why?

Chances are the bootstrap.min.css contains a css declaration which has a higher specificity
on the element(s) in question. Use firebug or the chrome inspector to look at the styles being applied to this element. You'll be able to see which css declration has a higher specificity and which has therefore overridden your main.css declaration.

Related

Overriding Bootstrap classes in CodePen site

I have free account on CodePen. In my code I use Bootstrap but I also override some Bootstrap classes in the CodePen CSS editor. In the head tag of HTML editor, I defined the loading order:
link rel="stylesheet" type="text/css" href="bootstrap.min.css" <br>
link rel="stylesheet" type="text/css" href="custom.css"
I.e. my custom.css I must override the Bootstrap classes. But it does not work in the CodePen editor. I have to use the !important rule to override Bootstrap classes too many.
The main thing is my code works perfectly in Google Chrome and Firefox without using the !important rule when I open custom.html on my local computer.
Why does not it work in the CodePen editor and why does it make such a big difference?
It seems that the order is :
!important
inline style
<style> in the html part
style in the css part
style in css settings.
If you want to avoid adding !important, you should add your link in the settings.
Go to the Settings -> css-> ->Add External Stylesheets/Pens -> add you css link -> save & close.
(Codepen link)

dreamweaver ignores css files

<link href="/qbaccounting.ca/_css/qba_main.css"
rel="stylesheet" type="text/css">
<link href="/qbaccounting.ca/_css/qba_content.css"
rel="stylesheet" type="text/css"
here is my css link in my dreamweaver web page. when i see it in drw, it looks good, text centered, color white, nice background, logo image, but when i upload it to the server it is as if there is no css file at all, no image, and text half centered, half not.
tried deleting index and css files, copied instead of put, nothing works.
what to do?
Your second link tag is missing the closing >

Fonts turning bold, not supposed to

Okay, I'm not going to post the entire css code for your own sake lol, but it's here http://pattersoncode.ca/incls/style.css
Anyway, I don't know whether it's a problem with my browser (Safari 7) but whenever the page fully loads, all the writing turns bold, and it looks out of place.
As you can see, I've set font-weight: normal !IMPORTANT on many areas of my code to see if that would solve it, but it didn't.
I guarantee you have a LABEL or H2 that isn't closed properly. You have only have only 2 elements with a bold definition: LABEL and H2 If you have closing tags missing or out of sequence, the style will cascade in the document, making everything bold.
Looks like Google's #font-face declaration is overwriting your own font-weight. That may be because Google's Font CSS comes right AFTER your style.css. Try placing Google's font-face css BEFORE your style.css, like this:
<link href="http://fonts.googleapis.com/css?family=Muli:300" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="http://pattersoncode.ca/incls/style.css">
Then reset overwrite font-weight again in your style.css

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:
The 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">
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!
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">
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 -->
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.
Check whether your CSS is called or not in browser dev tools (press F12) under network column.
If it is not called, use your style sheets with1 rel="stylesheet" type="text/css".
It worked for me.

CSS not working in stylesheet

I have a set of Styles that were first created inside the style attribute on a page.
I want to move it from being on the page itself into a stylesheet.
however, when I move it to a .css file, the page breaks, move the code back to the html doc and it works fine again.
This makes absolutely no sense, moving styles from a style to a css file shouldnt break the code should it?
Am I missing something? I am not changing any of the code, its simply a copy and paste.
This is just a shot in the dark as (at the time of this post) you haven't provided source code.
Make sure you're linking to your stylesheet using a link tag in the head of the HTML document.
If you had:
<style type="text/css">
/* <![CDATA[ */
#someid
{
margin: 0;
padding: 3px 12px;
}
/* ]]> */
</style>
You'll need to have
#someid
{
margin: 0;
padding: 3px 12px;
}
in your CSS file with:
<link rel="stylesheet" type="text/css" href="path/to/style.css" />
to link to the stylesheet.
Some common newbie mistakes include:
<style type="text/css" src="path/to/style.css">: because it's a similar syntax to the <script> tag, which would make sense, but is invalid
<link rel="stylesheet" src="path/to/style.css">: but link elements use href not src
placing link elements within the body: although browsers will tend to manage link elements in the body, there are likely going to be some errors, and it's not a defined behavior
not specifying a doctype declaration: allows the browser to go into quirks mode, which is never a good idea.
You should make sure the stylesheet is properly imported.
Sometimes the #import doesn't work well if not used accordingly, so always reference your stylesheet:
<link rel="stylesheet" type="text/css" href="name-of-stylesheet.css" />
Always remember to close the <link> tag as it's a self-close tag. I think #zzzzBov forgot to mention that.
Finally, if that doesn't work, try to override some of the styles by physically writing (above the </head> section) something like:
<style type="text/css">
body { background: blue; }
* { color: red; }
</style>
and see if that gives you a blue background and red colored text. It should. After that, try to implement the referencing method and make sure you reference the stylesheet file to the right directory.
Good luck!
I had the same problem, but the cause was not some mistake in the code but the fact that the .css file was loaded with some delay after making the modifications in it. The server needed 5 - 10 minutes to update the changes.
I had this problem as well, and the reason was that the path had to be updated for some url() references since the css file was in another folder than the html file it previously was called from.
So basically
background-image: url('patterns/debut_dark.png');
had to be changed to
background-image: url('../patterns/debut_dark.png');
Don't include <style type="text/css"></style> in your .css file.
I had the same issue and was quite frustrating. I had a css file that was properly referenced, however not all the elements were being loaded from it. As it turns out, it was a cache problem in Chrome. After clearing it and restarting the window, the css elements were working correctly.
Ran across same problem. Found there were lines in my css file that should have been commented out (a block of colour palette information that I had cut and paste to the top of the file for quick reference).
If all your syntax seems fine, then its most likely a browser cache problem that we can easily fix. In your html/php file, reference your new .css style sheet (e.g. styles.css) by adding an extra random parameter. This will force browsers visiting your page to fetch your latest styles.css.
In the of your html/php file, you should have something like this to load your new styles.css file:
<link rel="stylesheet" type="text/css" href="styles.css" />
simply change it to be like this:
<link rel="stylesheet" type="text/css" href="styles.css?ref=v1" />
that extra "?ref=v1" will prevent browsers from re-using the styles.css file they have cached, and will force browsers to get your very latest styles.css file. As you make updates to the styles.css file and upload them to your web server, just change the "v1" to "v2" etc. or whatever naming system you like so that browsers are forced to reload the latest styles.css. Note adding this "?ref=v1" to the link does not need you to change the name of your styles.css file (you can change the file name but i find that gets messy). This is a simple and clean way to force browsers into re-fetching your very latest .css file.

Resources