-2

How can I position a paragraph within a div to the very bottom?

I am trying a position-relative (on div), position-absolute (on p) combo but it doesn't work. I want the "Read more" text to be at the very bottom of the div because there are several of these divs next to each other and they very in text length.

HTML:

<div class="card-body">
 <h3><a href="project2.html">Joia</a></h3>
  <p>Concept design for an eCommerce solution for a local art store (exercise).</p>
  <p class="read-more"><a href="project2.html">Read More</a></p>
</div>

CSS:

 .card-body {
        position: relative;
    }

    .read-more {
        position: absolute;
        bottom: 0;
        left: 0;
    }

1 Answers1

0

Flexbox can do this without positioning:

* {
  margin: 0;
  padding: 0
}

.card-body {
  display: flex;
  flex-direction: column;
  height: 150px;
  border: 1px solid grey;
}

.read-more {
  margin-top: auto;
}
<div class="card-body">
  <h3><a href="project2.html">Joia</a></h3>
  <p>Concept design for an eCommerce solution for a local art store (exercise).</p>
  <p class="read-more"><a href="project2.html">Read More</a></p>
</div>
Paulie_D
  • 107,962
  • 13
  • 142
  • 161