Html CSS 列表样式类型不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12447611/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:51:27  来源:igfitidea点击:

CSS list-style-type not working

htmlcsshtml-lists

提问by SeinopSys

I have set the list-style-typein CSS, but for some reason it's not showing it.

我已经list-style-type在 CSS 中设置了,但由于某种原因它没有显示出来。

body {
  margin: 0;
}
ol {
  list-style-type: decimal;
  padding-left: 0;
}
<ol>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ol>

回答by Niet the Dark Absol

Because of your padding reset, the numbers are actually off to the left of the page. Try adding:

由于您的填充重置,数字实际上位于页面左侧。尝试添加:

list-style-position: inside;

回答by Musaddiq Khan

display:list-item;
list-style-position:outside;

It may give problem if list display:attribute is set to some thing else than display:list-item;

如果列表display:属性设置为其他内容,则可能会出现问题display:list-item;

回答by noel

Decimal is default for an "ol". No need to declare it. Also the numbers are there just falling off the side of the page i.e. invisible. Adjust your padding and get rid of the redundant declaration. See here

十进制是“ol”的默认值。不需要申报。此外,数字只是从页面的一侧掉下来,即不可见。调整您的填充并删除多余的声明。看这里

回答by Loreena

If nothing of this work, make sure you don't have elements explicitly marked as display block inside the LI. It just happened to me with a H4 A set as block inside the LI. I was about to resign

如果这些都不起作用,请确保您没有在 LI 中明确标记为显示块的元素。它只是发生在我身上,将 H4 A 设置为 LI 内的块。我正要辞职

回答by talentedandrew

just remove "display : block;" from your li element

只需删除“显示:块;” 来自你的 li 元素

回答by ellelle

In my case it wasn't working with <ul>.

就我而言,它不适用于<ul>.

I suspected it was possibly because of a CSS reset file I was using.

我怀疑这可能是因为我使用的 CSS 重置文件。

I set the ul { display:list-item; }as suggested above, and it just worked fine.

ul { display:list-item; }按照上面的建议设置了,它运行良好。

Check if you are using any reset files. They could be tricky at times.

检查您是否正在使用任何重置文件。他们有时可能会很棘手。