Hero Section: Section smaller than image? How to fix?

This is probably a very dumb question, but I am new to building websites and CSS and such so please bear with me.

Why is my section not stretching to fit the image that it contains? As a result, the container seems to remain only as big as the section.

I am depending on the section being as tall as the image, responsively, in order to properly position the various elements in the container.

Only changes made:
Image:

  • Position = Absolute
  • Min. width = 100%
  • Object fit = Cover

Any help or insight would be appreciated.

Note: I cannot link you the site, unfortuately, as it is locally hosted.

Try
position:absolute *you did it.
top:0;
left:0;
right:0;
bottom:0;

Instead of min-width.

I just made that change, but unfortunately, no luck :frowning:

Thank you for responding though!

The section change to position relative and see?

I tried that as well and no dice :confused:

This is what I set for my hero image.

It does well.

Hmm, I’m not sure why it’s not working for me. I must be doing something really silly.

Maybe I need to come back to this tomorrow with fresh eyes. Thank you so much for taking the time. :slight_smile:

If your site is online, feel free to share the URL, so I try to see if it works fine here.

It’s currently locally hosted but I will move it online tomorrow and add a link here. Thank you!

1 Like

You probably forgot to set section’s position to relative.

He said that he tried.

Ok. Then he needs to set the section position relative and image position not set and container position to absolute (with right, left, top and bottom to 0).
This way, the section would be at least as tall as the image. And he can change width and height of image in different breakpoints as he likes.