Error setting a background to a label and placing an image above the background of the label

Asked

Viewed 63 times

-4

//html

 <label class="home-header icon-menu">
                <img src="arquivos/menu.svg">
            </label>

//css

.icon-menu {
    position: relative;
    top: 0.5cm;
    left: 0.39cm;
    cursor: pointer;
    background: red;
}
  • Face but this is not a background, it is an image within a label. Explain better what you are trying to do, if possible edit your reply and put also an image of the layout you want to do

  • Okay has the image inside the label. So I’d like to put a background in the image. For example : It has the label after the background and finally the image under the background.

2 answers

0

Look, the way you’re using the image is wrong. For a Background, you will need to define in css that that image is a background (no need to call it in html), you will also need to define the behavior of the image within the container, follow example code.

ps: If classes are being used by other tags that you do not want to apply the background, it is appropriate to create an additional class or ID for the object in question.

html:

 <label id="backimg" class="home-header icon-menu"/>

css:

#backimg {
position: relative;
top: 0.5cm;
left: 0.39cm;
cursor: pointer;
width: 50px; <!-- especificar um tamanho para a tag é importante -->
height: 150px;
background: url('c:/caminho da imagem') no-repeat;
}

-1


Thanks to everyone who tried to help me in the answers, I asked the question the wrong way, now edited to be clearer. With @hugocsl explanation, I was testing in my code and I realized that I was missing the display: inline block. Thank you all. I’m sorry!

Browser other questions tagged

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