使用 CSS 网格对齐 ALT SYMBOL 和常规文本?

Use CSS grid to align an ALT SYMBOL and regular text?

任何人都知道将 "alt symbol" 与 "regular text" 对齐的最佳方法 - 似乎无法让这两个在没有一些 hacky 操作的情况下都居中(或任何东西)。

我目前正在使用 CSS 网格,但如果其他解决方案易于实施且可持续,我愿意接受它们。

display.jsx

  <div onClick={props.toggle} className='data__item__header'>
    <span className='data__item__header__bullet'>&#9679;</span>
    <p className='data__item__header__title'>Clashes {props.index}</p>
  </div>

display.scss

.data__item__header {
  display: grid;
  grid-template-columns: 20px 1fr;
  line-height: 20px;
  align-content: center;
  grid-gap: 10px;
}

.data__item__header__bullet {
  font-size: 36px;
  color: $tomato;
  border: 1px solid blue;
  display:grid;
  text-align: center;
}

.data__item__header__title {
  border: 1px solid green;
}

目前是:

应该是:

align-self: centerjustify-self: center添加到.data__item__header__bullet元素,同时调整行高-见下面的演示:

.data__item__header {
  display: grid;
  grid-template-columns: 20px 1fr;
  line-height: 36px; /*changed*/
  /* align-content: center; */ /* not needed */
  grid-gap: 10px;
}

.data__item__header__bullet {
  font-size: 36px;
  color: $tomato;
  border: 1px solid blue;
  display:grid;
  text-align: center;
  align-self: center; /* added */
  justify-self: center; /* added */
}

.data__item__header__title {
  border: 1px solid green;
}
<div  class='data__item__header'>
    <span class='data__item__header__bullet'>&#9679;</span>
    <p class='data__item__header__title'>Clashes {props.index}</p>
  </div>

不使用 &#9679; 字符, 可能会给您带来对齐问题,您可以使用 border-radius 来为您提供更好的项目符号样式 - 请参阅下面的演示:

.data__item__header {
  display: grid;
  grid-template-columns: 20px 1fr;
  grid-gap: 10px;
}

.data__item__header__bullet {
  background: blue;
  border-radius: 100%; /* added */
  height: 10px; /* added */
  width: 10px; /* added */
  display:grid;
  text-align: center;
  align-self: center; 
  justify-self: center; 
}

.data__item__header__title {
  border: 1px solid green;
}
<div  class='data__item__header'>
    <span class='data__item__header__bullet'></span>
    <p class='data__item__header__title'>Clashes {props.index}</p>
  </div>