Can I put a background-image in a Section?

Asked

Viewed 1,613 times

2

I created a section in my HTML and CSS:

section{
    background-image: url(../img/bkg2.jpg);
}

But the image does not appear. And I checked the path and it is correct.

  • This is not very correct but it tries to put this piece of your css inside the <head> with the <style> tag and see if it goes.

  • Open the console and see if there are any errors

2 answers

1

For sure!

    section {
    	background-image: url("https://static.pexels.com/photos/294674/pexels-photo-294674.jpeg");
        width: 100%;
        height: 500px;
    }
<section></section>

The image appears, but the problem is in the dimensions of your Section!

I recommend not making use of CSS generalizing elements like this, use Class and ID. For all your sections will be equal.

0

header#cabecalho {
    border-bottom: 1px #606060 solid;
    height: 150px;
    background: url("../_imagens/glass-logo-peq.jpg") no-repeat 0px 80px;
}

hello, maybe assigning an id to a specific area of your Section will help.

I hope I helped! = D.

  • Helped yes, I had forgotten the height. Thank you very much <3

Browser other questions tagged

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