The height of the rows in my CSS grid is determined by the grid items. How can I prevent an image in the grid being used in determining the height of the rows? Instead, I want the image to shrink to fit inside the rows (their height is determined by other grid items).
I've tried adding min-height: 0
to the grid container as suggested in Why don't flex items shrink past content size? as well as max-height: 100%
to the image but to no avail.
The grid without the image:
The grid with the image:
#hotel-editor {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 0.3fr 1.5fr 1fr 0.3fr;
grid-gap: 21px;
min-height: 0;
min-width: 0;
}
.hotelimage {
grid-column: 1 / 2;
grid-row: 1 / 3;
height: 100%;
min-height: 0;
min-width: 0;
}
.uploadedimg {
max-height: 100%;
max-width: 100%;
min-height: 0;
min-width: 0;
}
.hotel-info {
display: contents;
}
<div id="hotel-editor">
<div class="hotelimage" style="background: transparent;">
<img src="https://upload.wikimedia.org/wikipedia/commons/6/62/Paracas_National_Reserve%2C_Ica%2C_Peru-3April2011.jpg" class="uploadedimg">
</div>
<div class="hotel-info">
<input type="text" name="name" placeholder="Name">
<br>
<textarea name="description" placeholder="Description"></textarea>
</div>
<input type="submit" name="submit" class="submitbtn" value="Update">
</div>
JsFiddle: https://jsfiddle.net/ntyj76he/