<section>
  <h2>Центрируемый блок<br>по вертикали</h2>
  <span>с помощью единиц измерения vh<br>и трансформации</span>
</section>
section {
  width: 230px;
  padding: 10px 15px;
  margin: 50vh auto 0;
  transform: translateY(-50%);
  background-color: hsl(168, 34%, 59%);
  text-align: center;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.