How do I insert an image as the background of a div?

1

I want to add an image as the background of a div, and for this, I'm using the following code:

<div class="container">
    <div class="row">
        <div class="col-xs-12">
            <div class="imagemDeFundo">
                <p>Hello world</p>
            </div>
        </div>
    </div>
</div>

In my CSS it looks like this:

.imagemDeFundo{
    background-image: url(imgs/backgroundpage.png); 
    width: 400px;
    height: 400px;
}

My image is not appearing. What am I doing wrong?

    
asked by anonymous 14.09.2016 / 21:41

2 answers

1

It seems to be working .... Check the path as mentioned in the comment.

.imagemDeFundo{
    border: 1px solid black;
    background: url('https://www.askideas.com/media/11/Evolution-Something-Went-Wrong-Funny-Computer.jpg') no-repeat; 
    width: auto;
    height: 400px;
}
<div class="container">
    <div class="row">
        <div class="col-xs-12">
            <div class="imagemDeFundo">
                <p>Hello world</p>
            </div>
        </div>
    </div>
</div>
    
14.09.2016 / 22:00
1

Apparently everything is correct. Try to use background , instead of background-image :

.imagemDeFundo{
    background: url('imgs/backgroundpage.png'); 
    width: 400px;
    height: 400px;
}
    
14.09.2016 / 22:58