DaneSuegi
DaneSuegi

Reputation: 7

Image won't appear when used as a background

I have this folder "student" in my main folder, called "main". And I have php file in this address "main/student/home.php". which uses CSS in this address "main/config/style.css".

I want give a image on my "home.php", image on "main/images/1.jpg".

But when I wrote this on my style.css the image won't appear.

This is my style.css

body {
    margin: 0;
    padding: 0;
    background: #c09854 url(images/img1.jpg) repeat-x;
    font-family: 'Arvo', serif;
    font-size: 14px;
    color: #3B3B3B;
}

I am really confused bout this, what should I do?

Upvotes: 0

Views: 87

Answers (5)

Cryptographic_ICE
Cryptographic_ICE

Reputation: 619

can you load the image on the page in straight HTML? that will tell you if your path is correct, the image exists, and permissions etc.

The css looks okay so I assume its an issue with the image path.

you can also try breaking out the background tags like this:

background-image:url('images/img1.jpg'); background-repeat:repeat-x;

Upvotes: 0

vitaliy zadorozhnyy
vitaliy zadorozhnyy

Reputation: 1246

in css path should be specified relative to style sheet file so specifying like this

 background: #c09854 url(../images/img1.jpg) repeat-x;

should help.

Upvotes: 0

STP38
STP38

Reputation: 331

It should be this:

background: url(main/images/1.jpg) repeat-x #c09854;

If that doesn't work, try this:

background: url(../images/1.jpg) repeat-x #c09854;

Upvotes: 1

melvas
melvas

Reputation: 2366

You wrote different urls and names of files: "main/images/1.jpg" and "images/img1.jpg". Maybe there is your problem?

Upvotes: 0

Eswara Reddy
Eswara Reddy

Reputation: 1647

You should give styles in the following format

background:#ffffff url('../images/img_tree.png') no-repeat right top;

Upvotes: 2

Related Questions