1 Reply Latest reply on Mar 1, 2013 8:56 AM by josh.dura

    Align verticaly inside div?


      Hi there.

      I need to align an image, vertically, inside a div. I've used the responsive layout preset "Center background image" but it's not perfect... it's moving toward the top/left (botttom/left same problem). I've also tried the "vertical-align: middle" but it doesn't seem to work...

      Is there a workaround for this?


        • 1. Re: Align verticaly inside div?
          josh.dura Adobe Employee

          As far as images go, they behave like block elements in this regard, so using vertical-align won't work. That property will only work on inline elements. To vertically align a block element is pretty tricky in CSS, but there are a few options. If you can have a fixed height in the element, you can absolutely position the element and just use the margin-top or top positions to position it correctly. The other way would be to use line-height to fill its height. Unfortunately, both of these methods can be a bit wonky. Vertically aligning elements has been a thorn in developers sides for many many years.