gpt4 book ai didi

html - div包含的h3不能垂直居中

转载 作者:行者123 更新时间:2023-11-28 08:20:59 39 4
gpt4 key购买 nike

我的 h3 没有垂直居中有问题。在 Firebug 中,如果我将 top:50% 更改为 top:51% 然后再更改回来,它会自行修复。

div中的H3需要垂直居中。

链接:here

CSS:

.review-large {
text-align: center;
clear: both;
margin-top: 20px;
margin-bottom: 50px;
position: relative;
width: 100%;
min-height:127px;
background-image: url(../images/review-images/quote-left.jpg), url(../images/review-images/quote-right.jpg);
background-position: left center, right center;
background-repeat: no-repeat;
text-align:center;
}

.review-large h3 {
color: #00adee;
font-size: 33px;
font-weight: bold;
line-height: 33px;
padding:0 60px;
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
margin:0;
}

最佳答案

您应该使用表格/表格单元格行为。将容器放在 display:table;和表格单元格中的 h3;并设置垂直对齐:中间。同时删除位置变换和顶部,如:

.review-large {
display: table;
text-align: center;
clear: both;
margin-top: 20px;
margin-bottom: 50px;
position: relative;
width: 100%;
min-height:127px;
background-image: url(../images/review-images/quote-left.jpg), url(../images/review-images/quote-right.jpg);
background-position: left center, right center;
background-repeat: no-repeat;
text-align:center;
}

.review-large h3 {
display: table-cell;
vertical-align: middle;
color: #00adee;
font-size: 33px;
font-weight: bold;
line-height: 33px;
padding:0 60px;
position: relative;
margin:0;
}

关于html - div包含的h3不能垂直居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28763330/

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