<h2>Using grid and ex</h2>
<h2 class="alternate">Using grid and ex</h2>
h2 {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1ex;
  font-size: 2.2rem;
  line-height: 1ex;
  margin-bottom: 3rem;
  padding-block: 0.6ex;
  border-block: 2px solid hotpink;
  background: ivory;
  &::before,
  &::after {
    height: 1ex;
    background: hotpink;
    content: "";
  }
}

.alternate {
  grid-template-columns: auto;
  text-align: center;
  gap: 0;
  color: rebeccapurple;
  background: transparent;
  border: 0;
  &::before,
  &::after {
    background: deeppink;
    mix-blend-mode: color-burn;
  }
}

body {
  font-family: Georgia, serif;
  margin: 0 auto;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.