Arranging items to be flush at the base of several columns

I need help with positioning buttons at the bottom of three columns of text. I want them to be aligned vertically on the page when the columns are side-by-side, and then placed after each column when viewed in a single-column layout on small screens. The columns don't have backgrounds, so equal length is not mandatory.

Here is the code for the section:

<div 1 - position:relative>
        <div 2 - display:block;overflow:hidden>
            <div 3 - position:relative; float:left>
                <div 4 - display:block>
                    <img src="image1.jpg" />
                    <h1>Title 1</h1>
                    <p> Column 1 text</p>
                </div 4>
            </div 3>
            <div 3 - position:relative; float:left>
                <div 4 - display:block>
                    <img src="image2.jpg" />
                    <h1>Title 2</h1>
                    <p> Column 1 text</p>
                </div 4>
            </div 3>
            <div 3 - position:relative; float:left>
                <div 4 - display:block>
                    <img src="image3.jpg" />
                    <h1>Title 3</h1>
                    <p> Column 1 text</p>
                </div 4>
            </div 3>
        </div 2>
    </div 1>
    

I've experimented with different codes and placements, but haven't found a working solution yet. Existing solutions seem outdated or unclear to me. Positioning the buttons in a separate div after the columns works well on larger screens, but not on smaller ones where they all stack at the end. Placing them at the beginning or end of the columns results in vertical misalignment based on text length.

I attempted using "position:absolute;bottom:0" for div 2 with unsatisfactory outcomes. Any suggestions or solutions would be greatly appreciated.

Answer №1

One alternative approach that does not involve JavaScript is to organize the content in a table format.

<table cellspacing=18px valign=top>
<tr>
    <td align=center><h2>Heading 1</h2></td>
    <td align=center><h2>Heading 2</h2></td>
    <td align=center><h2>Heading 3</h2></td>
</tr>
<tr>
    <td valign=top>
        <img src="image1.jpg" />
        Content for column 1
    </td>
    <td valign=top>
        <img src="image2.jpg" />
        Text goes here.<br />
        And more text.<br />
        Third line of text.<br />
        Final thoughts.
    </td>
    <td valign=top>
        <img src="image3.jpg" />
        Details for column 3
    </td>
</tr>
<tr>
    <td align=center><button>Option A</button></td>
    <td align=center><button>Option B</button></td>
    <td align=center><button>Option C  </button></td>
 </tr>


</table>

This layout can be customized using CSS for each cell as needed.

Alternatively, you could iterate through each div element using pure JavaScript or jQuery, calculate the tallest height, save it in a variable, then revisit the button-containing elements and adjust their heights based on the variable value. Following this method, applying position:absolute;bottom:0px; would function effectively.

Answer №2

One thing to note is that the table's functionality is limited to wider screens. It doesn't have the capability to format text into a single column with buttons interspersed between different sections of text. To achieve this, I utilized display and screen width media queries to show/hide two separate sets of buttons. One set is positioned after each column, while the other is floated in a div located after all the columns. An alternative approach could involve creating two versions and using a media query to determine which one to display based on screen width. Additionally, the issue can be resolved by implementing media queries and large negative margins, as demonstrated in the jsfiddle at jsfiddle.net/DTMgJ/5/.

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

Effective Strategies for Preserving Form Input Values during Validation Failure in Spring MVC

I am currently working on validating user input, and I want the user's input fields to be retained in case of any validation errors. This is how I have set up my input fields: <form:input path="firstName" class="text short" id="firstName" value=" ...

Move to Fieldset Upon Link Click

Here's an example of what I have implemented so far here It's evident that this is not fully functional due to the PHP and jQuery integration. This demo is just a showcase of my progress. I am looking to create a functionality where clicking on ...

A step-by-step guide to showcasing dates in HTML with Angular

I have set up two datepickers in my HTML file using bootstrap and I am attempting to display a message that shows the period between the first selected date and the second selected date. The typescript class is as follows: export class Datepicker { ...

Website errors appear on the hosted page in <body> section without being present in the code

Hello there, I have set up a debug website using my "Olimex ESP-32 POE" to send internal data via JSON, eliminating the need for Serial Output from the Arduino IDE (the reasons behind this are not relevant). #include "Arduino.h" #include <WiF ...

Conceal a particular row in SharePoint by utilizing JavaScript with jQuery

I'm facing an issue with SharePoint 2010 where the _cts folder is visible in all document libraries. Despite my efforts to research and find a solution, I have been unsuccessful so far. For now, my workaround is to hide the entire row. Here's a ...

Step-by-step guide on preventing an item from collapsing in a Bootstrap navbar

Is there a way to exclude a specific item from the navbar collapse box when the screen size becomes small? Here is the current HTML code: <div class="container"> <nav class="navbar navbar-default"> <div class="container-fluid"> ...

Extracting text using Python and Selenium

Having trouble extracting text from HTML using Selenium and Python innerHTML <span data-select="" data-selected="Selected" data-deselect="Press enter to remove" class="multiselect__option"><span>ONE</span></span> <!----> ...

Tips for showing nested JSON data in a PrimeNG table within Angular version 7

I am struggling to display nested json data in a PrimeNG table. When I retrieve the data using an HTTP service, it appears as [object][object] when displayed directly in the table. What I want is to show the nested json data with keys and values separated ...

When adjusting the window size with the <ion-split-pane>, both the menu and router outlet disappear

When I have two ion menus and one main content (router outlet) and resize the page or switch to mobile view, the page appears blank as if the content is missing. Here is the code: <ion-app> <ion-split-pane> <ion-menu side="start" me ...

I would like for my element to increase and decrease in size while rotating when the button is clicked

I am trying to create an element that changes its size while spinning when a button is clicked. It seems to be working fine on hover, but not onclick. Here is the code I have: <div class="rec">Rec</div> <button id="button&quo ...

What's the best way to toggle the visibility of an input-group in Bootstrap?

Is there a way to properly hide and show a Bootstrap 5 input-group? You can see an example here: https://jsfiddle.net/o08r3p9u I'm facing an issue where once the input group is hidden, it doesn't show correctly when displayed again. How can I e ...

Console output shows that the function results in undefined

When I pass a string parameter to a function, I expect the console to display "reff", but it is showing "undefined" instead. Here is the code snippet: var _ref; function foo(_ref='reff') { var bar = _ref.bar; return console.log(bar); } foo ...

Expansive Offspring Division stretching to the Entire Vertical Length of its Guardian Division

I'm attempting to achieve full coverage of the parent div section by my child div section. Take a look at the Example URL (specifically where the Canadian Flag Stand Up Paddle Boarders are located) towards the bottom: Essentially, when I set the widt ...

Div vanishes once SVG Gaussian blur is applied

I'm attempting to add a Gaussian blur effect to an element that contains some child nodes with content. In Chrome, I successfully applied the blur using the following style: -webkit-filter: blur(2px); Unfortunately, Firefox does not support thi ...

Using the "this" keyword in JavaScript to access the "rel"

Take a look at the JSFIDDLE , where you will notice that the rel attribute in the alert is shown as 'undefined' : var ItemTypeArray = $('input[name^=ItemType]:checked').map(function(){ alert(this.id + ' , r= ' + this.rel) ...

Include an edit button with each row in an HTML table for seamless editing of the database

I am currently exploring php and seeking assistance with a project for my internship. I have successfully queried all records from the mysql database and displayed them in an html table. However, I now want to include an edit button in a separate column fo ...

Conceal the iframe if the source is http:// and there is no associated

Is there a way to hide the iframe only if the src starts with "http://"? This is what I have tried so far: <script type="text/javascript> if ( $('iframe[src^="http://"]') ) document.getElementById('iframe').style.d ...

"When attempting to output HTML using PHP, be sure to include a backslash () before special characters like

One issue I am facing is with a PHP code that retrieves HTML content from the database and uses echo to display it on my page. The problem arises when I use echo, as the HTML output ends up looking like this: <div class="\&quot;schema-faq- ...

Incorporate Security Measures into the Form

I am in the process of setting up a form that requires users to enter a specific password provided by me. The user must input "Password123" into the form before they can submit it to my email. If the password is incorrect, the site will redirect to an erro ...

Excess space noted at the bottom of tablet and mobile versions of the page

I'm struggling to troubleshoot an issue with the mobile and tablet versions of a web-shop I'm designing for university. Some pages have excessive space after the HTML tag, but only on certain pages. I've tried commenting out CSS lines relate ...