html - 脚注设计 CSS:垂直对齐
问题描述
您好:我正在尝试在 CSS 中设置脚注样式,并且我有以下 CSS 代码:
.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 代码时:
<p>Some text<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote">1</a></sup>.</p>
有以下脚注:
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:1" role="doc-endnote">
<p>Some footnote. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
...
</ol>
</div>
脚注如我上面解释的那样显示。但是,我最终得到以下结果:
如何修复它以使数字以圆圈为中心?
谢谢 :)
这是该问题的链接:https ://mianfg.me/2019/12/12/test
解决方案
通过将 line-height 设置为等于高度,文本现在将垂直居中。由于您还使用text-align: center;
了 ,因此在这种情况下,它负责水平对齐。
.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
}
推荐阅读
- angular - export pdf using angular ignie UI for angular
- java - How to capture video from camera,process it (do some task on it),then show it real-time on the screen to the user in android?
- python - 如何在方法之后多次使用 Tkinter,或者是否有替代方法?
- css - Bootstrap Popover on SVG icon - Wrong Arrow Direction
- electron - Open file in existing electron window instead of creating new one in Windows
- javascript - React native Dropdownalert with Navigation not working together in Redux Saga
- ios - Xcode swift: How to add a share screen where you can share your own app
- java - Java HTMLUnit and html2canvas to generate image "Cannot modify readonly property:"
- html - how can i get Drop down Selected text mvc
- c++ - 使用传递的 lambda 调用 std::visit