So, I have a container div
and an Image
component in it. I want the image height be equal to the 100% of container height, and the width of container to be automatically decided based on the width of image according to its aspect ratio. When I use a normal img
tag, this works without a problem, but in case of Next Image
component, the image is left with a width of 0px
. Because it wants me to define a fixed width for the container. ? How can I achieve what I want ?
What I'm doing is this:
for the div:
div {
height: 50px;
width: auto;
}
for the Image component:
<Image src="..." alt="..." layout="fill" />