One way to achieve this is by using the following CSS code:
.container {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
asked 9 months ago Asked
4 Answers
122 Views
I'm struggling to perfectly center a div both horizontally and vertically using CSS. I've tried various methods, including using flexbox and positioning, but can't seem to get it right. Any insights or best practices?
One way to achieve this is by using the following CSS code:
.container {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
One way to achieve this is by using the following CSS code:
.center-div {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Prueba de postjfidsaifjisauhfdiuhsaiufhisahfidsafhduisahifsauPrueba de postjfidsaifjisauhfdiuhsaiufhisahfidsafhduisahifsauPrueba de postjfidsaifjisauhfdiuhsaiufhisahfidsafhduisahifsauPrueba de postjfidsaifjisauhfdiuhsaiufhisahfidsafhduisahifsauPrueba de postjfidsaifjisauhfdiuhsaiufhisahfidsafhduisahifsauPrueba de postjfidsaifjisauhfdiuhsaiufhisahfidsafhduisahifsauPrueba de postjfidsaifjisauhfdiuhsaiufhisahfidsafhduisahifsauPrueba de postjfidsaifjisauhfdiuhsaiufhisahfidsafhduisahifsau
That is very correct! I like the simplicoty of all the things that have been built here! Hooray!