gpt4 book ai didi

html - 垂直对齐标记中的跨度

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

这是我的标记。解决方案必须针对跨度中的单行或双行动态工作。所以它应该是可以添加到其中每一个并且工作正常的css。从互联网上看,这似乎是不可能的。请证明我错了。

<ul style="text-align:center; list-style-type: none;">
<li style="width: 200px">
<a href="http://www.bing.com" style="display: block; height:35px; background: Black;">
<span>Vertical Align This Text</span>
</a>
</li>
</ul>

<ul style="text-align:center; list-style-type: none;">
<li style="width: 200px">
<a href="http://www.bing.com" style="display: block; height:35px; background: Black;">
<span>Vertical Align This Text With Double Line As Well</span>
</a>
</li>
</ul>

最佳答案

这对我有用:

<ul style="text-align:center; list-style-type: none;">
<li style="width: 200px; display: table">
<a href="http://www.bing.com" style="display: table-cell; height:35px; background: Black; vertical-align: middle; text-align:center">
<span>Vertical Align This Text</span>
</a>
</li>
</ul>

<ul style="text-align:center; list-style-type: none;">
<li style="width: 200px; display: table">
<a href="http://www.bing.com" style="display: table-cell; height:35px; background: Black; vertical-align: middle; text-align:center">
<span>Vertical Align This Text With Double Line As Well</span>
</a>
</li>
</ul>

为方便起见的 CSS 代码:

ul {
list-style-type: none;
}

li {
width: 200px;
display: table;
}

a {
display: table-cell;
height: 35px;
background: black;
vertical-align: middle;
text-align: center;
}

关于html - 垂直对齐标记中的跨度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5476238/

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