Skip to content

Instantly share code, notes, and snippets.

@Katsaros
Last active July 8, 2022 12:40
Show Gist options
  • Select an option

  • Save Katsaros/46daa93ed7a123fb4dd1e2d76b8fdf51 to your computer and use it in GitHub Desktop.

Select an option

Save Katsaros/46daa93ed7a123fb4dd1e2d76b8fdf51 to your computer and use it in GitHub Desktop.
How to center divs
<!-- Vertical Centering in CSS -->
<div style="display: table; height: 100%; overflow: hidden;">
<div style="display: table;height: 100%;overflow: hidden;">
<div>
Vertical Center
</div>
</div>
</div>
<!-- General Centering -->
<html>
<body>
<div style="display: flex; text-align: center; justify-content: center">
<div class="row" style="margin:0px;">
<div class="divclass">
<div class="spanclass"><span>hello</span></div>
</div>
</div>
</div>
</body>
</html>
<html>
<head>
</head>
<body>
<div style="height: 100%;overflow: hidden;display: flex;justify-content: center;align-items: center;align-content: center;">
<div style="display: table;margin: auto;overflow: hidden;">
<div>
Vertical Center
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment