简体   繁体   English

对齐问题嵌套的包含有不同字体大小的有序列表

[英]alignment issue nested ordered list containing containing different font size

im trying to create list in html/css like below 我试图在html / css中创建列表,如下所示

1. Heading
1. content one
2. content two
3. content three

2. Heading
1. content one
2. content two
3. content three

and so on.. 等等..

the font size of the heading and content (including number) are different 标题的字体大小和内容(包括数字)不同

my problem is that i can't get the nested child list to align with the parent list. 我的问题是我无法使嵌套子列表与父列表保持一致。 it works when the fond-sizes are the same, but when i change it, the alignment changes as well. 当喜欢的大小相同时,它可以工作,但是当我更改它时,对齐方式也会改变。

anyone got any ideas on how i can best achieve this? 任何人都对我如何最好地实现这一目标有任何想法?

this is the html css i have so far 这是我到目前为止的HTML CSS

<style>
 ol {
    list-style: decimal;
    margin: 30px 0 0 30px; 
}
ol li {
    margin-left: 20px;
    font-size: 20px; 
}
 ol li h2 {
    font-weight: bold;
    font-size: 20px; 
}
ol li ol {
    margin: 0 0 0 0; 
}
ol li ol li {
    margin: 0 0 0 0;    
    font-size: 15px; 
}
ol li ol li p{
    font-size: 15px;
}
 </style>

<ol>        
    <li>
        <h2>Heading 1</h2>          
        <ol>
            <li>
                <p>content 1</p>
            </li>
            <li>
                <p>content 2</p>
            </li>
        </ol>
    </li>

    <li>
        <h2>Heading 2</h2>          
        <ol>
            <li>
                <p>content 1</p>
            </li>
            <li>
                <p>content 2</p>
            </li>
        </ol>
    </li>
</ol>

Just alter the margin-left or padding-left of ol li ol . 只需更改ol li olmargin-leftpadding-left Try different values until you get the desired result. 尝试不同的值,直到获得所需的结果。

http://jsfiddle.net/LyrsY/ (However, jsFiddle uses a CSS reset that may give a different appearance than your page.) http://jsfiddle.net/LyrsY/ (但是,jsFiddle使用CSS重置,其外观可能与您的页面不同。)

Just add this code: 只需添加以下代码:

ol {
    margin: 0px;
    padding: 0px;   
}

As per i understand that's you want . 据我了解,那是你想要的。 Check this http://jsfiddle.net/ZHLKy/ 检查此http://jsfiddle.net/ZHLKy/

 ol {
    list-style: decimal inside;
}

UPDATED 更新

give margin to ol li ol & margin-left to your P like this: 给保证金ol li ol &保证金左边给你的P像这样:

ol li ol {
    margin: 0 0 0 1px;
}

ol li ol li p{
    font-size: 15px;
    display:inline;
    margin-left: 3px;
}

Check this http://jsfiddle.net/ZHLKy/2/ 检查此http://jsfiddle.net/ZHLKy/2/

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

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