Search code examples
htmlcssflexboxtwitter-bootstrap-4

Bootstrap Flexbox align div to bottom of div stops other divs from aligning


I'm trying to align a div to sit at the bottom of the parent div using flex box. I want the footer-bottom to be aligned at the bottom of each card. I've tried using align-self: end; which works but this stops the titles from aligning. See js fiddle

I'm aware bootstrap 4 has a way of doing this by using the default card syntax but i need to include columns within each card for when it goes down to mobiles.

Can anyone help me please?

<div class="mb-4 col-lg-4 normal-article">
        <article class="card">

                <div class="row no-gutters">



                        <div class="col-md-3 col-lg-12 order-12 order-md-1">
                            <div class="mobile-display">
                                <div class="card-img-top thumbnail" style="background-image:url('http://skeleton-theme.local/wp-content/uploads/2017/09/ukmr-_0022_talk-of-the-town-318x179.jpg')">
                                </div>
                                <div class="d-md-none">
                                    <p>Social shifts over the last decade have increased the pressure to live in well connected centres of population. </p>
                                </div>
                            </div>
                        </div>




            <div class="order-1 order-md-12 col-md-9 col-lg-12">


                <div class="card-body">

                <div class="entry-meta">
                    <span class="cat-links"> <a href="http://skeleton-theme.local/category/south-east/" rel="category tag">South East</a></span><span class="d-none edit-link"><a class="post-edit-link" href="http://skeleton-theme.local/wp-admin/post.php?post=3433&#038;action=edit">Edit <span class="screen-reader-text">"Talk of the Town"</span></a></span>             </div>

                <header class="entry-header">

                    <h2 class="entry-title"><a href="http://skeleton-theme.local/talk-of-the-town/" rel="bookmark">Talk of the Town</a></h2>
                </header><!-- .entry-header -->


                </div><!-- .card-body -->


            </div>
                            <div class="order-12 col-12 footer-bottom">
                    <div class="card-footer">
                        <small class="text-muted"><span class="posted-on">Posted on <a href="http://skeleton-theme.local/talk-of-the-town/" rel="bookmark"><time class="entry-date published" datetime="2017-09-14T15:00:44+00:00">14/09/2017</time></a></span></small>
                    </div>
                </div>
                            </div>

        </article>
    </div>

Solution

  • okay here is how i'd fix this.

    1. add the css flex-direction: column; to your .no-gutters css rule
    2. your no-gutters div has 3 children. on the first and second child, add flex: 1; or whatever values based on the ration you want to give the two divs, and on the third child (footer-bottom) add flex: 0 auto;