gpt4 book ai didi

css - 文本垂直对齐在 div 中不起作用?

转载 作者:太空宇宙 更新时间:2023-11-03 20:23:29 24 4
gpt4 key购买 nike

.st_content_heading{
width:500px;
height:250px;
background:red;
border:1px solid #ccc;
float:left;
margin:0px;
padding:0px;
display:table-cell;
vertical-align:middle;
}
<div class="st_content_heading" style="vertical-align:middle;">Content for class "st_content_out" Goes Here</div>

最佳答案

如果您 float 元素,您将失去表格单元格状态。

.st_content_heading{
width:500px;
height:250px;
background:red;
border:1px solid #ccc;
/* float:left; take this out */
margin:0px;
padding:0px;
display:table-cell;
vertical-align:middle;
}

关于css - 文本垂直对齐在 div 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4863601/

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