.parent {
display: flex;
justify-content: center;
align-items: center;
}
/* 100vh = 100% Viewport Height */
body {
display: flex;
height: 100vh;
flex-direction: column;
justify-content: center;
}
/* add */ align-items: center; /*to also center horizontally.*/
/* Flex */
.center {
display: flex;
justify-content: center;
align-items: center;
}
/* Without Flex */
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.parent {
display: flex;
justify-content: center;
align-items: center;
}
Code Example |
---|
Css :: rotate element css |
Css :: style scroll react csss |
Css :: create notification badge in css |
Css :: centre align in position absolute |
Css :: css blink animation |
Css :: react html height 100% |
Css :: sass class with another class |
Css :: how to add a background color in css |
Css :: comment one line css |
Css :: css align text |
Css :: making a circle css |
Css :: jquery change css variiable value |
Css :: background clip text |
Css :: center text in css |
Css :: webpack/load/css |
Css :: how to view downloading speed |
Css :: css supports |
Css :: canvas disable antialiasing |
Css :: rgba green color |
Css :: cool hover effects css |
Css :: purgecss cli |
Css :: css animation display none |
Css :: add quotes in quote css |
Css :: make text bold without font-weight |
Css :: rounded corners css button |
Css :: center div css flex |
Css :: how to use css transform matrix |
Css :: scss extend |
Css :: css table th width |
Css :: different measurements in css |