Image does not catch characteristic of the div in which it is inserted

Asked

Viewed 53 times

2

I have a header tag, where is my menu, this header tag has 80% screen width and is fixed at the top. I have just below the menu an image, which I want to take 100% of the screen, but is inside the same header tag. It’s like this image doesn’t get the width of the header tag, and instead get 100% of the screen, but still get fixed at the top along with the header?

1 answer

1


Has.

Set the image with:

position: fixed;
width: 100%;

left: 0; 
right: 0;
margin: auto;

margin-top: 100px; /* Aqui é o Tamanho do Header em Px */

The margin-top must be the height of <header>.

  • It worked! But I had a problem. The image was fixed below the menu exactly as it should be, but it wasn’t centered on the page, it was to the right,?

  • I added three more properties, left, right e margin: auto. Add them.

  • 1

    Perfect! It was exactly the way I needed it, thank you so much for your time and help! ;)

Browser other questions tagged

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