Develop a strategy for aligning images below text of varying heights within the Bootstrap Grid system

I am currently facing the challenge of vertically aligning images inside a Bootstrap grid below text with containers of varying heights.

Click here for the Fiddle

Here is the current state: https://i.sstatic.net/Oo4UM.jpg

This is my desired outcome: https://i.sstatic.net/pDz3v.jpg

I prefer to find a solution without using JavaScript, as I believe it would only impact responsiveness.

My attempted solutions include:

  1. Utilizing flexbox, but struggling to keep images aligned at the bottom
  2. Applying display:table-cell; and vertical-align:bottom properties to the figure element, but facing issues with container height uniformity without flexbox
  3. Trying out absolute positioning on the figure with bottom:0;, however, this interferes with parent container height

The HTML structure used:

<div class="row">
  <div class="col-xs-3"> 
    <p>
      Insert text here
    </p>
    <figure>
      <img src="http://placehold.it/150x150">
    </figure>
  </div>
  <div class="col-xs-3">
    <p>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent dapibus suscipit nisl id sagittis. Suspendisse ex neque, tempus a bibendum eget, elementum eget lorem. Integer ultricies turpis eget nibh pulvinar, at facilisis diam dapibus. Quisque non turpis eget libero consequat fringilla vel et sem.
    </p>
    <figure>
      <img src="http://placehold.it/150x150">
    </figure>
  </div>
  <div class="col-xs-3">
    <p>
      Insert more text here
    </p>
    <figure>
      <img src="http://placehold.it/150x150">
    </figure>
  </div>
</div>

Answer №1

Using Flexbox for column layout.

To ensure equal height columns, set the .row div to display:flex.

Each column needs display:flex with flex-direction:column.

Lastly, apply margin-top:auto to the figure to position it at the bottom.

.row.flex {
  display: flex;
}
.row.flex > div {
  display: flex;
  flex-direction: column;
}
.row.flex > div figure {
  margin-top: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="row flex">
  <div class="col-xs-3">
    <p>
      Content goes here
    </p>
    <figure>
      <img src="http://placehold.it/150x150">
    </figure>
  </div>
  <div class="col-xs-3">
    <p>
      More content here
    </p>
    <figure>
      <img src="http://placehold.it/150x150">
    </figure>
  </div>
  <div class="col-xs-3">
    <p>
      Additional text
    </p>
    <figure>
      <img src="http://placehold.it/150x150">
    </figure>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Seeking assistance with coding a beginner-level Google Chrome extension

Currently, I am working on developing a basic Google Chrome extension with 2 or 3 browser actions. I have been using Selenium IDE to capture the necessary steps in Firefox that I need for my project. However, I am unsure of how to translate these recorde ...

Integrating dynamic transition effects using Jquery Mobile for <div> elements

Just a friendly reminder, I must admit that my knowledge of Javascript is quite limited. I received a script from Padilicious to implement swipe navigation on my Jquery Mobile Site. It involves adding functions to a div tag like this: <div data-ro ...

Rock Paper Scissors Debugged

Question I have been working on a rock paper scissors game. The functionality I have implemented so far includes: Allowing the player to select a choice The computer randomly selects a choice Changing the images representing the hands based on the choic ...

Combining two HTML tables using jQuery/JavaScript

My table is displayed below: <table id="first" class="merge"> <tr> <td>Mick Jagger</td> <td>30</td> <td>50</td> <td>10</td> </t ...

A plethora of options for popup modals in jQuery, including stacked modals and various alternative modal

Is there an alternative to using multiple modals? I require the ability to have multiple instances of modals. Upon clicking "Open modal" on the main page, a form modal (Modal-A) should open, with a link inside Modal-A that can open another modal (Modal-B) ...

The PHP file on my local WAMP server seems to be having trouble retrieving inputs from the HTML's GET or POST methods

<!DOCTYPE HTML> <html> <body> <form action="testrun.php" method="GET"> Name: <input type="text" name="name"><br> E-mail: <input type="text" name="email"><br> <input type="submit"> </form> </bo ...

How to enhance a jQuery tab control by implementing custom JavaScript forward and back arrows?

Although there are other questions related to this topic, mine is unique. I have a scrolling jQuery feature that utilizes tabs for selection and is automated. Modifying the layout is challenging because it is dynamic and depends on the number of items in t ...

Click to reveal sliding menu bar

Trying to create a sliding menu bar (.top-bar) that activates when clicking an arrow (#hide), causing the arrow to also slide up and switch from an up arrow to a down arrow. Here is my unsuccessful attempt: $(document).ready(function(){ $("#hide").c ...

Bootstrap 4's hamburger icon in the navbar toggler displaying only two lines, rather than three

I have created a navbar using Bootstrap 4. Although the navbar is functional, I am facing an issue that I have not been able to resolve on my own. When collapsed, the hamburger icon only displays two lines instead of three. I suspect that the problem lie ...

Activate the radio button with jQuery when the event occurs

I have been experimenting with using HTML and JS along with the functionality provided by bootstrap-switch.org to toggle between two groups of radio buttons within a form. However, I am encountering difficulty in setting the first radio button in the secon ...

JavaScript script that parses innerHTML

Does the behavior of element.innerHTML = '<script>alert()</script>'; differ across browsers? Can I consistently expect innerHTML to not parse scripts? ...

automatically changing radio button selection based on dropdown choice

Let's address the issue at hand: I have a dropdown list with over three options, and alongside it, a radio group for yes or no responses. What I am aiming to achieve is setting the radio button to "no" when option 1 is selected, and to "yes" when any ...

Is there a way to change the color of a number's font based on whether it is preceded by a "+" or "-" sign?

I am currently working on a stocks widget and I have a specific requirement. Whenever there is a change in value in the Change or Changeinpercent columns, I need to dynamically set the font color to red for a decrease (-) or green for an increase (+). Her ...

Removing parent elements with JQuery

I have a piece of third-party HTML that I need to work with: <tr> <td> <asp:Label ID="lblURL" AssociatedControlID="txtURL" runat="server" EnableViewState="false" CssClass="FieldLabel" /> ...

Guide to generating a dropdown menu and linking it with data received from a server

I am completely new to Angular and recently received a project involving it. My task is to create a nested dropdown list for Json data retrieved from a server using Rest Api calls. The data contains a Level attribute that indicates the hierarchy level of ...

Change the order of the div to be placed before the previous element

In this scenario, the third div is positioned to the right of the second div rather than the first div. There is space available to the right of the first div, but it is constrained from appearing above the second div. How can I adjust the placement of th ...

Achieving perfect vertical alignment for both single and multi-worded links

Is there a way to vertically center single and multi-worded links in a horizontal navigation bar? Currently, the multi-worded links appear centered while the single worded links float to the left. I attempted to adjust the width of ul li a and ul li.colour ...

Phonegap experiencing difficulty converting HTML5 mobile app for IOS compatibility

After creating a Mobile Application project on Dreamweaver CS6 with HTML5, CSS3, and AJAX, I encountered an issue when trying to upload it on Phonegap. The app only converted successfully for android and windows, but showed errors for IOS and Blackberry. ...

Null values from sliders causing issues in dynamic shiny application upon initialization and throughout updates

Working on a complex web application with nested navigation and tabs using R's Shiny package. In some cases, accessing slider values from input$ returns NULL unexpectedly, leading to errors in dependent outputs. To resolve this issue, users can trigg ...

Is there a way to shade the entire webpage background in HTML?

Instead of affecting other DOM classes, I tried using another div but it doesn't darken the whole page. This means I have to manually modify each DOM class. Is there a way to overlay the entire document with a semi-transparent gray plane? ...