Html 删除 <li> 缩进

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

Remove <li> indentation

htmlcss

提问by Philip Kirkbride

I've removed the bullet on my lists using

我已使用删除列表中的项目符号

ul li { list-style: none; }

But I'm still getting an indentation on the lists as if the bullet was there.

但我仍然在列表上缩进,好像子弹就在那里。

enter image description here

在此处输入图片说明

I need the list-item in the image to be exactly centered.

我需要图像中的列表项完全居中。

回答by worenga

Browsers ship a default styling attached to <ul/>and <li/>tags

浏览器提供附加到<ul/><li/>标签的默认样式

ul,li { list-style-type: none;
        list-style-position:inside;
        margin:0;
        padding:0; }

http://meyerweb.com/eric/tools/css/reset/

http://meyerweb.com/eric/tools/css/reset/

回答by samayres1992

All the answers provided will fix your issue, but I definately recommend that you look in to using a reset stylesheet so you don't have cross browser issues!

提供的所有答案都可以解决您的问题,但我绝对建议您考虑使用重置样式表,以免出现跨浏览器问题!

The best one (well most popular one at least), is most likely this:

最好的(至少是最受欢迎的),很可能是这样的:

http://html5doctor.com/html-5-reset-stylesheet/

http://html5doctor.com/html-5-reset-stylesheet/

Hope that helps your issue, but if you don't want to use a reset style sheet simply:

希望这对您的问题有所帮助,但如果您不想简单地使用重置样式表:

ul, li{
    margin: 0;
    padding: 0;
}

回答by DACrosby

If you want to center the text, try

如果要使文本居中,请尝试

li{ 
  padding-left: 0px; 
  padding-right:0px; 
  margin-left:0px; 
  margin-right:0px; 
  text-align:center;
}

回答by Mahsa Teimourikia

You can also add a margin and padding 0:

您还可以添加边距和填充 0:

ul li { 
   list-style: none; 
   margin:0;
   padding:0;
}