これは、複数レベルの番号付けを使用した ol リストの良い例です。
例SCSS は次のようにコンパイルされます。
ol {
list-style: none;
position: relative;
padding-left: 15;
margin: 0;
}
ol {
counter-reset: level0 0;
}
ol li::before {
content: counter(level0,decimal) "";
counter-increment: level0;
position: absolute;
right: 100%;
margin-right: 15px;
text-align: right;
font-weight: bold;
font-size: 0.8em;
}
ol li:empty + {
counter-reset: level0 0;
}
ol li:empty::before {
display: none;
}
ol ol {
counter-reset: level1 ;
}
ol ol li::before {
content: counter(level0,decimal) "." counter(level1,decimal) "";
counter-increment: level1;
position: absolute;
right: 100%;
margin-right: 15px;
text-align: right;
font-weight: bold;
font-size: 0.8em;
}
ol ol li:empty + ol {
counter-reset: level1 ;
}
ol ol li:empty::before {
display: none;
}
ol ol ol {
counter-reset: level2 ;
}
ol ol ol li::before {
content: counter(level0,decimal) "." counter(level1,decimal) "." counter(level2,decimal) "";
counter-increment: level2;
position: absolute;
right: 100%;
margin-right: 15px;
text-align: right;
font-weight: bold;
font-size: 0.8em;
}
ol ol ol li:empty + ol ol {
counter-reset: level2 ;
}
ol ol ol li:empty::before {
display: none;
}
ol ol ol ol {
counter-reset: level3 ;
}
ol ol ol ol li::before {
content: counter(level0,decimal) "." counter(level1,decimal) "." counter(level2,decimal) "." counter(level3,decimal) "";
counter-increment: level3;
position: absolute;
right: 100%;
margin-right: 15px;
text-align: right;
font-weight: bold;
font-size: 0.8em;
}
ol ol ol ol li:empty + ol ol ol {
counter-reset: level3 ;
}
ol ol ol ol li:empty::before {
display: none;
}
ol ol ol ol ol {
counter-reset: level4 ;
}
ol ol ol ol ol li::before {
content: counter(level0,decimal) "." counter(level1,decimal) "." counter(level2,decimal) "." counter(level3,decimal) "." counter(level4,decimal) "";
counter-increment: level4;
position: absolute;
right: 100%;
margin-right: 15px;
text-align: right;
font-weight: bold;
font-size: 0.8em;
}
ol ol ol ol ol li:empty + ol ol ol ol {
counter-reset: level4 ;
}
ol ol ol ol ol li:empty::before {
display: none;
}
ol ol ol ol ol ol {
counter-reset: level5 ;
}
ol ol ol ol ol ol li::before {
content: counter(level0,decimal) "." counter(level1,decimal) "." counter(level2,decimal) "." counter(level3,decimal) "." counter(level4,decimal) "." counter(level5,decimal) "";
counter-increment: level5;
position: absolute;
right: 100%;
margin-right: 15px;
text-align: right;
font-weight: bold;
font-size: 0.8em;
}
ol ol ol ol ol ol li:empty + ol ol ol ol ol {
counter-reset: level5 ;
}
ol ol ol ol ol ol li:empty::before {
display: none;
}
ol ol ol ol ol ol ol {
counter-reset: level6 ;
}
ol ol ol ol ol ol ol li::before {
content: counter(level0,decimal) "." counter(level1,decimal) "." counter(level2,decimal) "." counter(level3,decimal) "." counter(level4,decimal) "." counter(level5,decimal) "." counter(level6,decimal) "";
counter-increment: level6;
position: absolute;
right: 100%;
margin-right: 15px;
text-align: right;
font-weight: bold;
font-size: 0.8em;
}
ol ol ol ol ol ol ol li:empty + ol ol ol ol ol ol {
counter-reset: level6 ;
}
ol ol ol ol ol ol ol li:empty::before {
display: none;
}
ol ol ol ol ol ol ol ol {
counter-reset: level7 ;
}
ol ol ol ol ol ol ol ol li::before {
content: counter(level0,decimal) "." counter(level1,decimal) "." counter(level2,decimal) "." counter(level3,decimal) "." counter(level4,decimal) "." counter(level5,decimal) "." counter(level6,decimal) "." counter(level7,decimal) "";
counter-increment: level7;
position: absolute;
right: 100%;
margin-right: 15px;
text-align: right;
font-weight: bold;
font-size: 0.8em;
}
ol ol ol ol ol ol ol ol li:empty + ol ol ol ol ol ol ol {
counter-reset: level7 ;
}
ol ol ol ol ol ol ol ol li:empty::before {
display: none;
}
li {
margin-top: 0.5em;
margin-bottom: 0.5em;
position: relative;
}