css center vertically and horizontally

51

.parent {
  position: relative;
}
.child {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}
.center {
  display: flex;
  align-items: center;
  justify-content: center;       
}
.parent{
	display: flex;
    justify-content: center;
  	align-items: center;
}
/* Child elements will be perfectly centered automatically */

Comments

Submit
0 Comments