DEV Community

Discussion on: The Art of Centering

Collapse
 
theonlybeardedbeast profile image
TheOnlyBeardedBeast • Edited

one more, nowadays not that usefull

.parent {
  display: table;
  width: 100%;
}
.child {
  display: table-cell;
  text-align: center;
  vertical-align: middle;
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
cjcon90 profile image
Ciaran Concannon

Cool! I've actually never used display: table; for anything but just reading about it now, interesting property! Thanks 😁

Collapse
 
theonlybeardedbeast profile image
TheOnlyBeardedBeast

This is the way we are using for old browsers fallback, in the worst case you have to use table elements directly.