I have a .post div which is the display:grid, and I made all the columns and rows auto to adjust to the size of whatever my img is going to be. The img has a max-width of 19em and I don't want the .post div to exceed whatever the image width ends up being with that max-width, but when my p tag is too long, the width of my div extends with it, beyond the img width. I want the p tag to go on the next line below it when it goes beyond the width of my img, but I'm not sure how to do this.
.post {
display: inline-grid;
grid-template-columns: auto;
grid-template-rows: auto auto auto;
border: solid 2px gray;
margin: 5px 10px;
grid-template-areas:
'top top top'
'name name name'
'comment comment .';
}
.post > img {
max-height: 19em;
max-width: 19em;
grid-area: top;
}
.post > h3 {
grid-area: name;
padding-left: 5px;
padding-top: 5px;
color: #0f0;
}
.post > p {
grid-area: comment;
padding: 4px 4px 6px 6px;
white-space: initial;
}
<div class="post">
<img src="https://placehold.it/600x400" alt="">
<h3>Heading</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
</div>
EDIT: I do not want to fix this by making height auto on my images, since some of my images are too large I want to restrict their height to 19em. How can I solve this without removing the height restriction on my image?