简体   繁体   中英

Center image vertically and horizontally with % width and height

how do i center a img with % width and height vertically and horizontally. The img is going to be responsive to the screen resolution and i need it to stay centered.

I was able to fix this by putting this img in a table like this

<table align="center" valign="center">
  <tr>
    <td style="text-align:center;">
      <img style="width:80%;max-width:500px;" src="logo.png"/>
    </td>
  </tr>
</table>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM