当每个行高不同时,如何在 flexbox 中垂直居中文本?

问题描述

我有三个水平的文本部分,每个文本都有不同的 line-height。但是,它们应该垂直对齐。

div {
  display: flex;
  align-items: center;
  width: 300px;
  background-color: skyblue;
}

p {
  font-size: 20px;
  font-weight: bold;
  margin: 0;
}

p:first-child {
  line-height: 1.33;
}

p:nth-child(2) {
  line-height: 1.65;
}
<div>
  <p>texttext1</p>
  <p>texttext2</p>
  <p>texttext3</p>
</div>

但是,当我使用 flex 的 align-items 时,它不起作用。还有其他解决方案吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)