0

How to vertically align the headline in the following example, without using position: absolute in combination with transform: translateY(-50%) etc. and also without setting a manual line height with a fixed px amount? In the example I gave the parent a fixed height, but this is only for demonstration purposes, the solution should not rely on that.

.newsletter {
  background: black;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
   -ms-flex-direction: row;
    flex-direction: row;
  height: 140px; }

.newsletter__column {
  -webkit-box-flex: 1;
   -ms-flex-positive: 1;
    flex-grow: 1;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
   -ms-flex-direction: row;
    flex-direction: row;
  -webkit-box-pack: center;
   -ms-flex-pack: center;
    justify-content: center;
  -ms-flex-line-pack: center;
   align-content: center; }

.newsletter__title {
  margin: 0;
  padding: 0;
  color: white;
  background: red;
}
<section class="newsletter">
  <div class="newsletter__column">
  <h1 class="newsletter__title">Newsletter</h1></div>
</section>
user3292653
  • 602
  • 1
  • 7
  • 25

0 Answers0