I'm currently working on a website where I have a list of news displayed in divs. Each div contains two inner divs: an image on the left and the title, date, and the first 30 words of the news on the right. I am looking to make the image div adjust its height based on the text div, regardless of the image size or aspect ratio. I want to achieve this without using fixed dimensions to ensure responsiveness. I am using Bootstrap 3.3.7 for this project.
You can view an example of my current progress.
Below is the HTML code I have:
<!-- First News -->
<div class="container-fluid panel panel-default">
<div class="col-xs-12 col-sm-4 news-img-div">
<img src="https://fakeimg.pl/412x112/" alt="img_1" class="img-responsive">
</div>
<div class="col-xs-12 col-sm-8 news-text-div">
<h4>News Title 1</h4>
<p>Nov 6, 2017</p>
<p class="text-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eu vehicula turpis. Donec tristique consequat libero a dapibus. Quisque in dolor tellus. Suspendisse auctor in libero non porta. Aliquam eu.</p>
<a href="" class="btn btn-primary" role="button">See More</a>
</div>
</div>
<!-- Second News -->
<div class="container-fluid panel panel-default">
<div class="col-xs-12 col-sm-4 news-img-div">
<img src="https://fakeimg.pl/350x232/" alt="img_2" class="img-responsive">
</div>
<div class="col-xs-12 col-sm-8 news-text-div">
<h4>News Title 2</h4>
<p>Nov 5, 2017</p>
<p class="text-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eu vehicula turpis. Donec tristique consequat libero a dapibus. Quisque in dolor tellus. Suspendisse auctor in libero non porta. Aliquam eu.</p>
<a href="" class="btn btn-primary" role="button">See More</a>
</div>
</div>
<!-- Third News -->
<div class="container-fluid panel panel-default">
<div class="col-xs-12 col-sm-4 news-img-div">
<img src="https://fakeimg.pl/243x242/" alt="img_curso" class="img-responsive">
</div>
<div class="col-xs-12 col-sm-8 news-text-div">
<h4>News Title 3</h4>
<p>Nov 4, 2017</p>
<p class="text-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eu vehicula turpis. Donec tristique consequat libero a dapibus. Quisque in dolor tellus. Suspendisse auctor in libero non porta. Aliquam eu.</p>
<a href="" class="btn btn-primary" role="button">See More</a>
</div>
</div>
Here is the CSS I have used for visualization purposes:
.news-img-div {
background-color: red;
}
.news-text-div {
background-color:aqua;
}
I have added background colors to the divs for better visualization. Please expand the result tab to ensure the image and text are displayed on the same row.
Is there a way to achieve this using only CSS? Alternatively, I am open to solutions involving JS.