首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >脚注设计CSS:垂直对齐

脚注设计CSS:垂直对齐
EN

Stack Overflow用户
提问于 2020-07-02 09:32:11
回答 1查看 439关注 0票数 0

你好:我试图在CSS中添加脚注,我有以下CSS代码:

代码语言:javascript
复制
.post-content sup a.footnote {
    display: inline-block;
    margin-left: 5px;
    min-width: 16px;
    height: 16px;
    border-radius: 100%;
    border-bottom: none;
    padding: 1px 3px;
    background: #f4f5f6;
    font-size: 10px;
    text-align: center;
    color: #abb7b7
}

.post-content sup a.footnote:hover {
    background: #abb7b7;
    color: #fff
}

.post-content .footnotes {
    margin-top: 40px
}

@media only screen and (min-width:768px) {
    .post-content .footnotes {
        margin-top: 60px
    }
}

@media only screen and (min-width:1220px) {
    .post-content .footnotes {
        margin-top: 80px
    }
}

.post-content .footnotes ol {
    list-style: none;
    counter-reset: footnotes
}

.post-content .footnotes ol li {
    margin-top: 5px;
    font-size: 13px;
    counter-increment: footnotes
}

.post-content .footnotes ol li:before {
    content: counter(footnotes);
    box-sizing: border-box;
    display: inline-block;
    margin-right: 3px;
    width: 20px;
    height: 20px;
    border-radius: 100%;
    border-bottom: none;
    padding: 2px 3px;
    background: #f4f5f6;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    color: #abb7b7
}

.post-content .footnotes ol li p {
    display: inline;
    max-width: 100%;
    font-size: 13px
}

.post-content .footnotes ol li p a.reversefootnote {
    border-bottom: 0;
    vertical-align: sub
}

这样做的想法是,当我显示一个脚注时,数字会在一个圆圈中显示,它引用脚注,所以当我插入以下HTML代码时:

代码语言:javascript
复制
<p>Some text<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote">1</a></sup>.</p>

有以下脚注:

代码语言:javascript
复制
<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1" role="doc-endnote">
      <p>Some footnote.&nbsp;<a href="#fnref:1" class="reversefootnote" role="doc-backlink">↩</a></p>
    </li>
    ...
  </ol>
</div>

如我上文所述,脚注已予显示。然而,我最后得到了以下结果:

我如何修正它,使数字集中在圆圈上?

谢谢:)

这里有一个指向问题的链接:https://mianfg.me/2019/12/12/test

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-02 09:49:00

通过将直线高度设置为等于高度,文本将垂直位于中间。由于您也使用了text-align: center;,所以在本例中,这将处理水平对齐问题。

代码语言:javascript
复制
.post-content .footnotes ol li:before {
    content: counter(footnotes);
    box-sizing: border-box;
    display: inline-block;
    margin-right: 3px;
    width: 20px;
    height: 20px;
    line-height: 20px;
    border-radius: 100%;
    border-bottom: none;
    padding: 0 3px;
    background: #f4f5f6;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    color: #abb7b7
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62693237

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档