.container {
display: flex;
justify-content: center;
}
.item:first-child {
width: 40%;
background: pink;
padding: 10px;
margin: 10px;
height: min-content;
}
.item:last-child {
width: 20%;
margin: 10px;
padding: 10px;
background: pink;
overflow: auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="item">
<img src="https://www.w3schools.com/css/img_fjords.jpg" width="100%">
</div>
<div class="item">
<p>This is the test paragraph.This is the test paragraph.This is the test paragraph.This is the test paragraph.This is the test paragraph.</p>
<p>This is the test paragraph.This is the test paragraph.This is the test paragraph.This is the test paragraph.This is the test paragraph.</p>
<p>This is the test paragraph.This is the test paragraph.This is the test paragraph.This is the test paragraph.This is the test paragraph.</p>
</div>
</div>
I'm trying to make the text div (.item:last-child) the same height as the image div (.item:first-child) using CSS, the image width can accommodate with different screen size, the text div can scroll. I can do it by JS/jQuery code (commented now), but don't know do it by pure CSS. Can anyone help me on this issue? Thank you.