I have three columns (single row) that contains text and a centered button at the bottom. Based on the visitors viewport, sometimes the text ends up making one of the columns longer (vertically) than the other, causing the buttons at the bottom to not line up.
To solve this, I set “equalize columns” on (within the Divi theme) and based on the temporary red background I added to the columns, they seem to be the same height. However, the two buttons on the left, despite being inside a column that is the same height as the biggest one (on the right), are not floating to the bottom of the div. Here is a screenshot:
Here is the button code that I use in each div:
<div class="homepage-blurb-buttons-div1"><div class="homepage-blurb-buttons-div2">[maxbutton id="1" text="FREE SITE AUDIT" url="https://www.example.com/examplepage"]</div></div>
And here is the CSS for them (was mainly for simply centering them):
.homepage-blurb-buttons-div1 { text-align:center; margin-top:25px; }
.homepage-blurb-buttons-div2 { display:inline-block; }
I have tried to set the parent (div1) to “position: relative;” and the child (div2) to “position: absolute; bottom: 0;” as recommended elsewhere but this is what happens:
All I want to achieve is to push the button div to the bottom of the already equalized columns. In my screenshotted examples, that would mean pushing the “Free Site Audit” and “Free Analysis” to the bottom.
NOTE: Both the divs and the button doesn’t have any bottom margins or padding.
UPDATE: I have just noticed that although the columns are being equalized, it is not adjusting the overall parent div. So in other words, the buttons are being aligned as low as they can go, so what I really need is some CSS to force the two DIVs on the left to take up all available space?
3
Answers
You can do this using
position
. Check snippet below..You can use flexible items for solving this problem.
On the div that wraps around each of your red boxes and is one level above your div1 just add a flex-direction. Here it sets the direction of flexible items to vertical:
On your div1 you can use this, which will move the div to the end of the flexible items column:
For more info:
I suggest you use Flexbox.
The below pseudo code shows when one use
margin-top: auto
in a flex column direction, it push the element towards the bottom of its parent.