<style>
li:before {
content: "";
display: inline-block;
height: 1rem; // or px or em or whatever
width: .5rem; // or whatever space you want
}
</style>
它工作得非常好,不需要太多额外的规则或html。
<ul>
<li>Some content</li>
<li>Some other content</li>
</ul>
ol,
ul {
list-style-position: inside;
}
li {
list-style-type: none;
}
ol {
counter-reset: ol; //reset the counter for every new ol
}
ul li:before {
content: '\2022 \00a0 \00a0 \00a0'; //bullet unicode followed by 3 non breakable spaces
}
ol li:before {
counter-increment: ol;
content: counter(ol) '.\00a0 \00a0 \00a0'; //css counter followed by a dot and 3 non breakable spaces
}
li:before {
content: "";
margin-right: -5px; /* Adjust this to move text closer to the bullet */
}
li {
text-indent: 5px; /* Aligns second line of text */
}
<ul>
<li> Item 1 ... </li>
<li> Item 2 ... this item has tons and tons of text that causes a second line! Notice how even the second line is lined up with the first!</li>
<li> Item 3 ... </li>
</ul>
<ul>
<li>Oh dear</li>
<li>what happened</li>
<li>to the bullet spacing?</li>
</ul>
我们可以通过在项目符号后面添加一个标准空格字符来重新引入空格。
ul.custom-bulleted {
list-style-type: "• ";
}
<ul class="custom-bulleted">
<li>Ah, that's better.</li>
<li>I've never cared for sticky bullets.</li>
</ul>
<ul>
<li>I'm an unstyled list.</li>
<li>I never have that problem!</li>
</ul>
ul li::marker {
content: '•'; /* as a side effect sets the space to zero */
font: 1.2em/1 sans-serif; /* adjust the bullet size */
}
ul li {
padding-left: .2em; /* have full control over the bullet space */
}