gpt4 book ai didi

html - 将字母彼此重叠/在容器中将字母居中?

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

我需要在链接中将一个字母显示在另一个字母之上,并希望它们居中。我已经尝试过 position: relative 和 absolute,但无法将字母居中。

有什么想法吗?我希望它们完全一样,不要问我为什么 :)

代码如下:

<a href="#">
<span>O</span>
<span>B</span>
</a>

我只知道父链接的宽度,但不知道给定字母的宽度是多少。

这是播放宽度的代码:

http://jsfiddle.net/ZYhzJ/

编辑

这是它应该是什么样子的示例(它没有居中,如果我不知道这些跨度的宽度,我不能使用负边距):

http://jsfiddle.net/ZYhzJ/2/

最佳答案

http://jsfiddle.net/d7Qhq/1/

a {
text-align: center;
display: block;
background-color: red;
line-height: 50px;
width: 50px;
height: 50px;
border-radius: 100px;

position: relative;
}

a span {
position: absolute;
display: block;
line-height: 50px;
width: 50px;
height: 50px;
}

类似的东西?

关于html - 将字母彼此重叠/在容器中将字母居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12875752/

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