Background: url ('example.jpg'); Does not work!

Ok here is my file structure:

+ WWW

  • index.html
  • style.css
  • map.jpg

CSS

body {
    background: #000 url('map.jpg') repeat/repeat-x/repeat-y/no-repeat scroll/fixed top/center/bottom/x-%/x-pos left/center/right/y-%/y-pos;
}

HTML:

<html>
<head>
    <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
</body>
</html>

PROBLEM: map.jpg does not appear in any browser (Firefox, Safari) or in TextMate Preview!

+3
source share
7 answers

You have two questions: first turn off your CSS, it should not have a list of styles for each remaining argument:

body {
  background: #000 url('map.jpg');
}

Then yours <body>has no content, so it has no dimensions, you will need to add something there to see a lot, if there is any image, otherwise the height of the element <body>will be very small, if not 0, depending on the browser.

+4
source
body {
    background: #000 url('map.jpg') no-repeat top left;
}

.

+1

CSS, , ?

- :

body {
    background:#000 url('map.jpg');
}
+1

Try to add overflow:hidden;. It worked for me.

+1
source

I worked on wamp ... and it works fine with relative URLs.

body{
    background:url(../image/circle.png) no-repeat; 
}

This must work.

+1
source

Try to get rid of excess garbage in your css:

body {
    background: #000 url('map.jpg');
}
0
source

Make sure the image is in the same folder as your css file.

0
source

Source: https://habr.com/ru/post/1775395/


All Articles