Created
June 1, 2022 19:44
-
-
Save gsrai/cf5c97cac67105a5e81e5fdfad76928f to your computer and use it in GitHub Desktop.
How to center a div
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>center a div</title> | |
<style> | |
.container { | |
height: 100vh; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
.content { | |
max-width: 200px; | |
max-height: 200px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<!-- just imagine this is a div --> | |
<img class="content" src="https://picsum.photos/200" /> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment