1

So I was having this trouble that my background image was not working at all...

I had the .css file correctly added with element in html. However I never got it to work. The only way it started to show me the background image was when I decided to create a NEW .css file which i called bodystyle.css and it finally did show me the background image.

The code used was the one below... I just pasted it to the new .css file and included the new file and it worked like a charm... why would this happen? Has anybody encounter this?

body {
    height: 100%;
    font-size: 62.5%;
    font-family: "Trebuchet MS", Arial, Tahoma, sans-serif;
    color: #333;
    background: url('http://wilco/includes/img/body-bg.jpg');
    padding-top: 0px;
}

a {
    color: #4681da;
    text-decoration: none;
}
Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
S.H.
  • 2,833
  • 3
  • 26
  • 28
  • 2
    Seems like a caching related issue. – Josh Crozier Oct 10 '13 at 04:27
  • http://stackoverflow.com/questions/12717993/stylesheet-not-updating Yep... just read about it :D. Thanks. Silly me. I mean I found a silly solution... but its annoying none the less. – S.H. Oct 10 '13 at 04:28
  • Are you getting this problem only with background image or with all the elements? – vishalkin Oct 10 '13 at 04:39
  • I am getting it with all elements. The problem as I see is the cache from the server. I am using wamp server. I am just trying to figure out how to erase the cache from it. – S.H. Oct 10 '13 at 04:51

3 Answers3

1

This is modify version of your program

Directory Structure: in windows

D:\MYPROG\wilco\includes\img

in this folder your image body-bg.jpg exist

D:\MYPROG\styles Your css file NEW .css exist

AND last

D:\MYPROG your prog.html file exist

Code is as follow

<!DOCTYPE html>
<html lang="en">
  <head>

    <title></title>
    <link href="styles/NEW .css" rel="stylesheet" type="text/css"/>
  </head>
  <body>
  <div>

  <p> This is my Background</p>

  </div>
  </body>
</html>

AND THIS IS YOUR CSS FILE

body {
    height: 100%;
    font-size: 62.5%;
    font-family: "Trebuchet MS", Arial, Tahoma, sans-serif;
    color: #333;  width:970px;height:;background-position: center top; 
    margin:auto;
    background-image: url("../wilco/includes/img/body-bg.jpg");
    background-repeat: repeat;
    padding-top: 10px;
}

a {
    color: #4681da;
    text-decoration: none;
}

I tried in my computer its working. you try with your image and tell me if any queries

bye

0

What I do to "fix" this, is F12 to open the developer console (in most modern browsers), navigate to the head element, then the link element, and open the link to the css file in a new window. Once it is there, press Ctrl+F5 (or Cmd+R on OSX).

Then go back and refresh your page...

daniel.gindi
  • 3,457
  • 1
  • 30
  • 36
0

All your files (.html,.css and background image) should be in the same folder. try checking that..