Html 从 <ul> 中删除项目符号

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

Getting rid of bullet points from <ul>

htmlhtml-lists

提问by Sam Khan

I have the following list:

我有以下清单:

 <ul id="otis">
 <li>Benz</li>
 <li>Other Benz</li>
 <li>Other Other Benz</li>
 </ul>

I want to get rid the bullets so i tried:

我想摆脱子弹所以我试过:

 ul#otis {
 list-style-type: none;
 }

That didn't work though. What is the proper way to remove the bullets from the displayed list?

但这并没有奏效。从显示的列表中删除项目符号的正确方法是什么?

回答by David says reinstate Monica

Assuming that didn't work, you might want to combine the id-based selector with the liin order to apply the css to the lielements:

假设这不起作用,您可能希望将id-based 选择器与 the结合使用li,以便将 css 应用于li元素:

#otis li {
    list-style-type: none;
}

Reference:

参考:

回答by John Olav

I had the same extreme irritating problem myself since the script did not take any notice of my styelsheet. So I wrote:

我自己也遇到了同样极端恼人的问题,因为脚本没有注意到我的样式表。所以我写道:

<ul style="list-style-type: none;">

That did not work. So, in addition, I wrote:

那没有用。所以,另外,我写道:

<li style="list-style-type: none;">

Voila! it worked!

瞧!有效!

回答by Philpot

To remove bullet points from unordered lists , you can use:

要从无序列表中删除项目符号,您可以使用:

list-style: none;

You can also use:

您还可以使用:

list-style-type: none;

Either works but the first is a shorter way to get the same result.

要么有效,但第一个是获得相同结果的较短方法。

回答by Kishan

The following code

以下代码

#menu li{
  list-style-type: none;
}
<ul id="menu">
        <li>Root node 1</li>
        <li>Root node 2</li>
    </ul>

will produce this output:

将产生这个输出:

output is

输出是

回答by Paul Kaplan

Try this instead, tested on Chrome/Safari

试试这个,在 Chrome/Safari 上测试

ul {
 list-style: none;
}

回答by Stuff

Put

<style type="text/css">
 ul#otis {
     list-style-type: none;
   }
</style>

immediately before the list to test it out. Or

紧接在列表之前进行测试。或者

<ul style="list-style-type: none;">

回答by Rokan Nashp

To remove bullet from ULyou can simply use list-style: none;or list-style-type: none;If still not works then i guess there is an issue of priority CSS. May be globally UL already defined. So best way add a class/ID to that particular UL and add your CSSthere. Hope it will works.

要删除项目符号,UL您可以简单地使用list-style: none;list-style-type: none;如果仍然无效,那么我想存在优先级CSS的问题。可能是全球 UL 已经定义的。所以最好的方法是向那个特定的 UL 添加一个类/ID,然后在那里添加你的CSS。希望它会起作用。

回答by pokumars

This worked perfectly HTML

这完美的 HTML

<ul id="top-list">
        <li><a href="#">Home</a></li>
        <li><a href="#">Process</a></li>
        <li><a href="#">Work</a></li>
        <li><a href="#">Team</a></li>
        <li><a href="#">Contact</a></li>
      </ul>

CSS

CSS

#top-list{
  list-style-type: none;
  list-style: none;}

回答by Luke

for inline style sheet try this code

对于内联样式表试试这个代码

<ul style="list-style-type: none;">
    <li>Try This</li>
    </ul>

回答by PeeHaa

There must be something else.

一定还有别的东西。

Because:

因为:

   ul#otis {
     list-style-type: none;
   }

should just work.

应该只是工作。

Perhaps there is some CSS rule which overwrites it.

也许有一些 CSS 规则会覆盖它。

Use your DOM inspector to find out.

使用您的 DOM 检查器来查找。