gpt4 book ai didi

css - Div 在中心?

转载 作者:行者123 更新时间:2023-11-28 10:24:11 28 4
gpt4 key购买 nike

<li class="row">
<div class="small-6 column center">
<img src="test.jpg">
</div>
<div class="small-6 column center">
<p>hello</p>
</div>
</li>

我希望将 hello p 放在列的中心(垂直和水平)。

我用样式来做到这一点:

 p{
bottom: 0;
left: 0;
margin: auto;
position: absolute;
top: 0;
right: 0;
}

问题是,第二列的高度与第一列的高度不同。我怎样才能做到这一点?

这是我的列样式:

.row{
width: 100%;
float: left;

.column{
width: 100%;
position: relative;
float: left;
display: block;
background: yellow;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
}

.small-1 {
width: 8.33333%; }

.small-2 {
width: 16.66667%;}

.small-3 {
width: 25%;}

.small-4 {
width: 33.33333%; }

.small-5 {
width: 41.66667%; }

.small-6 {
width: 50%; }

.small-7 {
width: 58.33333%; }

.small-8 {
width: 66.66667%; }

.small-9 {
width: 75%; }

.small-10 {
width: 83.33333%; }

.small-11 {
width: 91.66667%; }

.small-12 {
width: 100%; }


}

.pull-left{
float: left;
}
.pull-right{
float: right;
}

.center{
text-align: center;
}

最佳答案

你可以做类似的事情

.small-6 {
line-height: 60px;
}

或者像这样

.small-6 {
height: 60px;
}

将 60 更改为适合您的任何值

关于css - Div 在中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23824950/

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