gpt4 book ai didi

html - 没有固定高度的单行和多行CSS的垂直居中

转载 作者:太空宇宙 更新时间:2023-11-04 08:41:57 25 4
gpt4 key购买 nike

我在 html 中有一些文本标签,例如 <label>Short</label><label>This is a long label which is split into two line</label> .这些标签位于不同高度的 div 元素中。我怎样才能让我的文字居中?我用过display: table-cell; vertical-align: center;适用于单行但不适用于双行,它将双行文本推到 <div> 之外element.有什么帮助吗?

最佳答案

试一试,它可能对你有用:

{ display: flex; align-items: center; justify-content: center; }

关于html - 没有固定高度的单行和多行CSS的垂直居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44060492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com