CSS 如何将 List-style-type: "disc" 添加到 <p> 标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4764156/
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 23:31:11  来源:igfitidea点击:

How To Add List-style-type: "disc" to <p> tag

cssimagehtml-lists

提问by user583330

This seems like it ought to be ridiculously easy, but I'm having trouble figuring it out.

这看起来应该非常简单,但我很难弄清楚。

I want to replicate the <li>function so the disc image appears to the left, but applied to a

我想复制该<li>功能,使光盘映像出现在左侧,但应用于

tag

标签

I have this, but it does not show the disc image.

我有这个,但它不显示光盘图像。

.list {
     margin-top: 15px;
     margin-bottom: 15px;
     list-style:disc outside none;
     display:inline; 
     }

<p class="list"><em>And Much, Much More!</em></p>

I want to avoid using any graphics to simulate the bullet if at all possible.
Thanks for the help

如果可能的话,我想避免使用任何图形来模拟子弹。
谢谢您的帮助

回答by user583330

Answer: display: list-item;

答:显示:list-item;

Display must be set to list-item - not inline, and not list!

Display 必须设置为 list-item - 不是内联,也不是列表!

.list {
     list-style:disc outside none;
     display:list-item; 
     }

<p class="list"><em>And Much, Much More!</em></p>

回答by GolezTrol

Well, a p is not a list. Why not use <ul><li>?

嗯,ap 不是一个列表。为什么不使用<ul><li>

[edit] Let me elaborate. The problem is that you set this style on a list, while the disc is shown in the list items. A phas no items in that sense, so there's nothing to apply the disc to.

[编辑] 让我详细说明。问题是您在列表中设置了此样式,而光盘显示在列表项中。Ap在这个意义上没有任何项目,所以没有什么可以应用光盘的。