Home css File path in Background-image: URL

File path in Background-image: URL

Author

Date

Category

I do not want to boot the background picture. In the internet there are several options:

body {
Background-image: URL (img / bg.jpg);
Background-Color: # C7B39B;
}

and second option:

p {
  Background-Color: White;
  Color: Black;
  Background-image: url ('/ img / pushkin.gif');
 }

I tried two – do not work. If the background pattern is in one folder with style.css and writing Background-image: URL (Pushkin.gif); – Everything works.

Maybe the case in directories?

/ lib /
  / CSS /
  / img /

p.s. File *. CSS connected, everything works except graphics.


Answer 1, Authority 100%

Yes, the case in directories, the file searches from the current directory to rise to the level above, you need to write two points: ...
For example:

p {
 Background-Color: White;
 Color: Black;
 Background-image: url ('../ img / pushkin.gif');
}

Path means you need to climb the parent directory, go to the IMG folder and find the file pushkin.gif .


Answer 2, Authority 29%

If the directory structure is as you specified, then you need to write the path to the picture relative to the location of the CSS file, which in this case is like this:

background-image: url ('.. / img / bg.jpg');

And always, always, when you specify some pictures of the picture, you need to specify the image dimensions. (i.e. width and height)


Answer 3, Authority 14%

To install a background image:

body {
  Background: url ('. / img / bg.jpg');
  Background-Color: # C7B39B;
}

not background-image , but just background: url .


Answer 4

If you have pictures stored in / lib / img / then write background: url (/lib/img/img.gif)

“/” At the beginning means the root of the site

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions