Positioning Alignment for a CSS Layout with Two Columns

I am trying to achieve a specific layout using CSS. I want the signature to align with the bottom of the other boxes in the design. The challenge is that either box can have different amounts of content, and the signature should always align with the lowest point of the two boxes. For instance, if one box has less content but the other is longer, there should be a gap between the text and the signature to maintain alignment. However, if the first box is longer, the second box should scale accordingly while the signature remains at the bottom.

So far, I've experimented with various techniques like absolute positioning and vertical alignment, but I haven't been able to achieve the desired result. One idea I have is to use absolute positioning for the signature and create a blank element of the same size to maintain the document flow. Another idea is to use blank space beneath the text to push the signature down, but I'm not sure how to implement this effectively in CSS.

If anyone has any suggestions or solutions, I would greatly appreciate it.

This is the current code:

<div class="tborder {$altbg}" style="{$post_extra_style} {$post_visibility} width: auto;" id="post_{$post['pid']}">

<div style="overflow:hidden; border-collapse: collapse; position: relative;">

<div class="post_left" style="width: 19%;">

<div class="post_user" style="text-align: center; font-size: 1.25em; min-height:50px">
<span style="vertical-align: middle;"><strong>{$post['profilelink']}</strong></span>
</div>
<div class="post_userbit" style="width: 100%; text-align: center; margin: 0 auto;">
<div style="width: 100%; text-align: center; margin: 0 auto; >{$post['useravatar']}<br />
{$post['groupimage']}
</div>
<div style="width: 100%; text-align: center; margin: 0 auto; padding-top: 0.5em; padding-bottom: 0.5em;"><strong>
<span class="medtext">
{$post['userstars']}
{$post['usertitle']}<br />
{$post['user_details']}
</strong>
</div>
<div class="post_awards" style="width: 189px; margin: 0 auto;">
{$post['myawards']}<br />
</div>
</span>
</div>
</div>

<div class="post_right" style="width: 78%; align: right; height: 100%;">

<div class="post_meta" style="min-height:50px">
<span class="smalltext">{$post['postdate']} {$post['posttime']}</span>
{$post['posturl']}
</div>
<div id="pid_{$post['pid']}" class="post_body;">
{$post['message']}
</div>

<table align="left" width="78%" border="0" cellpadding="0" cellspacing="0" class="postbit_signature" style="bottom: 0;">

            <tr valign="bottom">
                <td align="left">{$post['attachments']}{$post['signature']}</td>
            </tr>
        </table>

</div>
</div>

<div style="clear: both"></div>

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="postbit_buttons">

            <tr valign="bottom">
                <td align="left"><span class="smalltext">{$post['button_email']}{$post['button_pm']}{$post['button_www']}{$post['button_find']}{$post['button_rep']}</span></td>
                <td align="right">{$post['button_tyl']}{$post['button_edit']}{$post['button_quickdelete']}{$post['button_multiquote']}{$post['button_warn']}{$post['button_reply_pm']}{$post['button_replyall_pm']}{$post['button_report']}{$post['button_forward_pm']}{$post['button_delete_pm']}{$post['button_quote']}
</td>
            </tr>
        </table>

</div>

View the current output here: https://i.sstatic.net/48wEo.png

Answer №1

Check out this CSS and HTML code snippet for creating a table layout:

<!-- CSS -->

*{box-sizing:border-box;}
#table{display:table;width:100%;}
#table ul{display:table-row;}
#table ul li{display:table-cell;width:20%;border:2px solid #ccc;padding:10px;}
#table ul li+li{width:80%;position:relative;}

#signature{position:absolute;left:10px;bottom:10px;} /* left and bottom should be equal to left and bottom padding of parent element for proper alignment */
#dummy-signature{visibility:hidden;margin:15px;}


<!-- HTML -->

<div id="table">
    <ul>
        <li>
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
        </li>


        <li>
            Lorem Ipsum is simply dummy text of the printing and typesetting industry.  Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

            <div id="signature">Signature</div>
            <div id="dummy-signature">Signatureeee</div>
        </li>
    </ul>
</div>

Answer №2

If you're looking to create a structured table layout using CSS, you can try the following approach:

Here is the HTML structure:

<div class="table">
    <div class="table-row">
        <div class="table-col abc">
            <p>
                This is a sample paragraph. 
                This is a sample paragraph. 
                This is a sample paragraph.
                This is a sample paragraph.
            </p>
        </div>
        <div class="table-col xyz">
            Sample Text
        </div>
    </div>
</div>

And here is the corresponding CSS:

.table { 
    display: table; 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 5px; 
}

.table-row { 
    display: table-row; 
}

.table-col { 
    display: table-cell;
    box-sizing: border-box;
    border: 3px solid black;
    padding: 20px;
}

.left { 
    width: 20%; 
}

.right { 
    width: 80%; 
}

Check out the DEMO to see it in action!

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

In the XHTML mode, MathOverflow's invaluable mathematical expertise shines brightly

I am interested in incorporating the unique “piece of valuable flair™” from MathOverflow onto my website. The issue I am facing is that I want my webpage to comply with XHTML5 standards, meaning it should be served with the MIME type application/xht ...

How to make external links open in a new window within wagtail

Recently, I made a change to include target="_blank" in external links by implementing the following code: @hooks.register('after_edit_page') def do_after_page_edit(request, page): if hasattr(page, "body"): soup = BeautifulSoup(page. ...

Does anyone know how to designate a Thumbnail when playing Audio on iOS Safari?

I recently launched a website to showcase my new podcast. The audio is embedded in a media player on the page, and when it's playing, it shows up on the Control Center audio tab and even on the lock screen. However, the thumbnail displayed is just a ...

Encountered a challenge when attempting to substitute styles using classes in material-ui

While working on implementing a table using the TableRow component from material-ui, I encountered an issue with customizing the background color when the "selected" property is true. The default theme applies a pink background-color in such cases, but I w ...

Adjust the height of a div according to the width using CSS in a progressive manner

I'm looking to create a fluid container that adjusts its height gradually based on the width of the window (as the div's width is set to 100%). Similar to the behavior achieved with the aspect-ratio CSS rule, I want the height to smoothly increas ...

What does the class "md-2n" signify in Bootstrap 4?

Can you explain what 'md' stands for in this context? I understand that 'm' refers to margin, but what about 'd' in the first line of code? Also, what does the 'n' in 'n2' stand for? How is it different fr ...

What is the best way to include a padding at the top of the second row?

I have two rows with three columns each. I am trying to create some spacing between the two rows. I attempted to achieve this by wrapping the rows and adding padding to the last child (which should be the second row). However, this approach did not work a ...

How can I use XPATH and Python Selenium to select the text node that is outside of an <a> element?

Check out the following link: Within this section of code: //*[@id="main-contents"]/div[1]/table[1]/tbody/tr/td, there is a piece of text Mottled Boar slain (10) //*[@id="main-contents"]/div[1]/table[1]/tbody/tr/td/a This part contains only: Mo ...

What is the best way to access dropdown sub-menu options from a complex multi-level navigation bar

Struggling to figure out how to open my dropdown sub-menu using CSS. Hoping to make it so the user can open it by hovering over the corresponding tag. I attempted to use #lablinksDD to trigger the opening of #ddSbMenu when hovered over #menuDD with #labLin ...

Utilizing JSON Data with JQuery: A Beginner's Guide

I am using a setTimeout function to reload another function every 5 seconds. The update_list function is responsible for rendering entrances in a view. However, when there are many entrances and you have scrolled down, the list empties and reloads every e ...

Arranging an Array by Two Distinct Characteristics

I currently have an array that is grouped and sorted based on the "Program" attribute, which is working well. However, I now need to sort by a different attribute (Deliverable) within each group. Is this possible? If so, how can I achieve it? Below is an ...

Customer uploaded an image to the WordPress header but it is not aligning correctly

Trying to align an image added by my client in the WordPress header. As someone who is still learning CSS, I'm struggling to get it exactly where we want it. Visit the site here The Options House graphic currently sits on the right. My goal is to ha ...

Positioning an absolute div inside a relative div within a v-for loop while using VueJS and Element UI

I am experimenting with rendering a list of <el-card> items using a transition-group. Each card has a front and back side that flip when a button is clicked. To achieve a smooth flip transition, I need to apply the style: position: absolute; top: 0; ...

Learn the process of creating various themes with Tailwind CSS

When exploring Tailwind CSS, it appears that specific colors need to be specified in classes like this: <div class="bg-yellow-200 dark:bg-gray-800"></div> However, I am interested in offering 10 different themes for users to choose f ...

Ways to align pictures in the center vertically when placed side by side

Can someone help me make the transition between tall and short images on my website smoother? I am not familiar with coding terminology, so please bear with me. The attached image provides a visual representation of the changes I am looking for: click he ...

Having problems with loading @font-face in Ionic Framework Android app build?

While working on an app in Ionic Framework, I encountered a peculiar issue. https://i.stack.imgur.com/xk8uD.png In my Ionic Framework application, I am importing @font-face and running the app on an Android device (Galaxy SIII). Strangely, the font (Mont ...

How can I incorporate a counter into my ng-repeat loop in Angular?

Do you know where I can find documentation on adding a numbered count to each item returned by an ng-repeat in Angular? This is not like assigning an Id, but more like, if 4 items are returned, each JSON object could include a number before the data. Her ...

Tips for increasing the complexity of your bottom-line animation

Hello everyone, I am currently learning the basics of CSS and have a question about a specific animation effect. Please bear with me if this type of inquiry is not suitable for StackOverflow. In my index.html file, I have the following code: <n ...

PHP overall outcome

I have created a form that includes checkboxes, but I am facing difficulty in calculating the total result based on the selections. Ideally, if a user selects three checkboxes, the total should be $3, and if only one checkbox is selected, the total should ...

What are some strategies for increasing efficiency in my drag and drop process?

Update #2 Wow, transition was stuck at .35s. My CSS just wasn't updating properly :( UPDATE: Anyone know if requestAnimationFrame could help with this? I've got a rotating image reel and I want users to be able to swipe left or right to switch ...