Several simple vertical center way

1. diplay: table

.parent{
  display: table
}
.child{
  display: table-cell;
  vertical-align: middle
}
Copy the code

2. display: flex

.box{ display: flex; justify-content: center; // spindle flex-direction default is row align-items: center; / / auxiliary shaft}Copy the code

3. position: relative

.box{
  position: relative;
  top: 50%;
  left: 50%;
  transform: tranlate(-50%, -50%);
}
Copy the code

4. margin: auto

.box{
  margin: auto 0;
}
Copy the code