Search code examples
htmlcssimagevertical-alignment

place product image at bottom of the box


CODE

I want image to aligned at bottom of the box. There will be product images which are coming from backend and there is not fix size for it.

HTML

<ul>
  <li><img src="http://img3.wikia.nocookie.net/__cb20120422063108/nickelodeon/images/2/27/Spongebob1.gif" alt="" /></li>
  <li>
    <img src="http://img2.wikia.nocookie.net/__cb20120717231330/hulksmash/images/7/78/Image_placeholder.jpg" alt="" />
  </li>
</ul>

CSS

ul {
  list-style: none;
}
li {
  float: left;
  width: 276px;
  text-align: center;
  border:1px solid #ccc;
  height: 276px;
  margin: 5px
}
img {
  vertical-align: bottom
}

Solution

  • This css did the trick

    ul {
      list-style: none;
    }
    li {
      width: 276px;
      text-align: center;
      border:1px solid #ccc;
      height: 276px;
      margin: 5px
      vertical-align: bottom;
      display: table-cell;
      vertical-align: bottom;
    }
    img {
      vertical-align: bottom
    }