gpt4 book ai didi

css - 垂直居中某些文本

转载 作者:行者123 更新时间:2023-11-28 08:40:05 25 4
gpt4 key购买 nike

你好,我这里有一张图片

http://puu.sh/eeOTZ/1e14f8b0ce.png

然后文本被推到顶部?

是否有可以使其位于中心的属性?

这是我试过的 CSS。

 text-align: center;
margin: center;

最佳答案

为此你需要line-height。我也添加了您自己的图片以供引用:

* {font-family: 'Segoe UI'; font-size: 10pt;}
.tabs, .tabs li {margin: 0; padding: 0; list-style: none; display: block;}
.tabs li {display: inline-block; background-color: #ccc; line-height: 50px; padding: 0 10px; border-top: 2px solid #999;}

.theImg {background: url("http://i.stack.imgur.com/rld5h.png") center center no-repeat; line-height: 45px; width: 122px; text-align: center; margin: 20px; font-weight: bold;}
<ul class="tabs">
<li>Tab 1</li>
<li>Tab 2</li>
<li>Tab 3</li>
</ul>

<!-- Using your code! -->

<div class="theImg">Text</div>

关于css - 垂直居中某些文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27843300/

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