How do I position an image at the bottom of div?

Dustin Lee picture Dustin Lee · Jul 29, 2013 · Viewed 149.6k times · Source

I want an html image to be flush with the bottom of a div tag. I can't seem to find a way to accomplish this.

Here is my HTML:

<div class="span8">
  <img src="/img/play-shot1.jpg" class="text-center shadow">
</div>

The problem is that the div is nested within other divs that have padding or margins.

Answer

Matt Lambert picture Matt Lambert · Jul 30, 2013

Add relative positioning to the wrapping div tag, then absolutely position the image within it like this:

CSS:

.div-wrapper {
    position: relative;
    height: 300px;
    width: 300px;
}

.div-wrapper img {
    position: absolute;
    left: 0;
    bottom: 0;
}

HTML:

<div class="div-wrapper">
    <img src="blah.png"/>
</div>

Now the image sits at the bottom of the div.