I'm working with this HTML setup:
<div class="container">
<img class="image" />
<div class="overlay">
<div class="insides">more content here</div>
</div>
</div>
and trying to style it using this CSS code:
.container {
position: relative;
height: 88vh;
margin: 0;
}
.image {
height: 100%;
position: absolute;
margin-right: auto;
margin-left: auto;
left: 0;
top: 0;
bottom: 0;
right: 0;
}
.overlay {
position: absolute;
}
These are the specific requirements I need to meet:
- Ensure that the image fills the available vertical space and is centered horizontally. (So far, so good)
- Create an overlay of the same size as the image without specifying an exact
width
. (Currently running into issues with this) - Position icons in precise locations on the image. (I'm considering using percentages for the
top
andleft
properties, but it may be more complicated than anticipated.)
Is there a way to achieve all of these specifications - having a horizontally centered image that expands to fill the vertical space, an accurate overlay, and fixed elements on specific parts of the image?
Although I would prefer a CSS workaround, I'm open to also exploring a Javascript solution if it's necessary to dynamically calculate the image width for the overlay.