简体   繁体   English

垂直对齐有序列表中的样式数字

[英]Vertically align styled numbers in ordered list

I found this lovely style for numbered lists but I would like to know if it can be improved to center the numbers with the content of each list item.我为编号列表找到了这种可爱的样式,但我想知道是否可以改进它以将数字与每个列表项的内容居中。 Thanks!谢谢!

http://codeitdown.com/ordered-list-css-styles/ http://codeitdown.com/ordered-list-css-styles/

ol.print-list {
    list-style-type: none;
    list-style-type: decimal !ie; /*IE 7- hack*/

    margin: 0;
    margin-left: 4em;
    padding: 0;

    counter-reset: li-counter;
}
ol.print-list > li{
    position: relative;
    margin-bottom: 20px;
    padding-left: 0.5em;
    min-height: 3em;
}
ol.print-list > li:before {
    position: absolute;
    top: 0;
    left: -1.33em;
    width: 1.2em;
    height: 1.2em;

    font-size: 2.5em;
    line-height: 1.2;
    text-align: center;
    color: #f5f5f5;

    border: 1px solid #c5c5c5;
    border-radius: 50%;
    background-color: #4CAF50;
    content: counter(li-counter);
    counter-increment: li-counter;
}

<ol class="print-list">
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
</ol>

https://jsfiddle.net/mx3m3avv/ https://jsfiddle.net/mx3m3avv/

you just had to add a line-height to:你只需要添加一个 line-height 到:

ol.print-list > li{
    position: relative;
    margin-bottom: 20px;
    padding-left: 0.5em;
    min-height: 3em;
    line-height: 3em;
}

jsfiddle提琴手

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM