The background-image does not work from my css file

0

I have a problem with the "background-image" property since my css file

<!DOCTYPE html>
<html lang="ES">
<head>
 <title></title>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0, 
 shrink-to-fit=no">
 <link rel="stylesheet" type="text/css" href="css/Estilos.css">     
</head>
<body>

<div class="Fondo">
</div>

</body>

and this is my css

.Fondo{
  background-image: url(img/Fondo_Error.png);
  border: 2px solid black;
  height: 150px;
  }

since the css the background-image does not work for me but if I put it inside the tag, it just works for me.

<div class="Fondo" style="background-image: url(img/Fondo_Error.png);">

</div>

It should be noted that the border and height if I work from the css.

    
asked by Aldair B.S. 29.04.2018 в 00:23
source

1 answer

0

The file Styles.css is in a folder called css, and the HTML is in a directory above the CSS directory, so if you put in the CSS that the background image is going to be an image that is in the same directory that the Styles.css.

You should put the following code in your CSS:

.Fondo{
  background-image: url(../img/Fondo_Error.png);
  border: 2px solid black;
  height: 150px;
}

Since you are indicating that the image Background_Error.png is in the img directory, but a directory above the css directory.

    
answered by 29.04.2018 / 04:26
source