gpt4 book ai didi

css - 如何给div中的文本填充?

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

每当我给 div 中的文本填充时,div 的整个高度都会发生变化,我必须根据 div 来管理高度。这个我试过了

这是我的 html

<div>Home</div>

这是我使用的 CSS

div {
font-size: 27px;
text-align: center;
margin: 5px 3px 0 0;
margin: 75px 0 0 0;
float: right;
width: 208px;
height:100px;
border-radius:2px;
font-family: "Comic Sans MS", cursive;
background-color: #F00;
color:#FFF;
}

这里,文本在顶部,而我希望文本居中。有人可以帮忙吗?

最佳答案

使用 line-height: 100px; 作为居中文本

Demo Here

关于css - 如何给div中的文本填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20919266/

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