Background image in white

Asked

Viewed 637 times

1

I’m having a problem with html, because I need to add an image in the background of a container and I’m using bootstrap, I tried to add the class in a separate css, but it still doesn’t work

.bg-back{
  background-color: transparent;
  background-image: url("./imagem/bg.jpg");

}
<main>
<section class="bg-back">
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
<div class="container" align="center">
       <div class="input-group col-lg-6">
           <input type="text" class="form-control" placeholder="">
           <span class="input-group-btn">
               <button class="btn btn-default" type="button">Pesquisar</button>
           </span>
       </div>
   </div>
    <br>
    <br>
    <br>
    <br>
</section>
</main>

  • Rick take the quotes on background-image thus: url(./imagem/bg.jpg) if it still doesn’t work is because the path to your folder is wrong, then you can try to put a " . " more at the beginning of the path, if the image is a folder "outside" of the folder where your file is .css. thus: " ../ " background-image: url(../imagem/bg.jpg);

  • @hugocsl worked, answers the topic to put your answer with right. Thank you.

  • Thanks Rick I’ll do it, thanks for the force!

1 answer

0


Rick believes that the problem as I said in the comment is that a " is missing. " in the path from your directory to the image folder. Changed from ./ for ../ In this answer you can read more about the subject if you are interested Path to access html folders ,css,php etc

If the image is a folder "outside" of the folder where your .css. file is, you should do so: ".. / " before the folder name:

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

Another observation is that you do not need to put enclosed quotes from the path inside the url() although some consider this a good practice.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.