0

I am trying to center vertically and horizontally an image with variable width and height, maxing at 1000px. I archived vertical center but I am unable to add horizontal center without breaking vertical... Here is my code:

<div style="margin-left:auto;margin-right:auto;width:70%;height:1000px;width:1000px;">
    <div style="display:table-cell;vertical-align:middle;height:1000px;width:1000px;">
        <img src="images/a.png">
    </div>
</div>

1 Answers1

1

Just add text-align: center; to outer div.

JSFiddle

Tigran Petrossian
  • 1,158
  • 1
  • 7
  • 16