Skip to content

Instantly share code, notes, and snippets.

@DominicWatts
Created November 21, 2023 15:48
Show Gist options
  • Save DominicWatts/3285b65291058d5449d33a47efbf4f98 to your computer and use it in GitHub Desktop.
Save DominicWatts/3285b65291058d5449d33a47efbf4f98 to your computer and use it in GitHub Desktop.
center-align-image-in-container
<div style="position:relative; width: 100%; aspect-ratio:1; display:block; overflow:hidden;">
    <img src="blah" style="height: 100%; width:auto; position: absolute; left: 50%; top: 50%; transform:translate(-50%,-50%)"/>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment