Html 不同缩进的项目符号列表

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

bulleted list with different indentation

htmlcsshtml-lists

提问by sova

Can I make bulleted lists on my site that use <ul> and <li> tags have a different indentation distances?

我可以在我的网站上制作使用 <ul> 和 <li> 标签具有不同缩进距离的项目符号列表吗?

  • Element One
  • Element Two
  • and even this line which is not in an <li> tag are indented
  • 元素一
  • 元素二
  • 甚至这行不在 <li> 标签中的行也是缩进的

  • List elements without the <ul> tags are
  • 没有 <ul> 标签的列表元素是
  • not indented
  • 没有缩进
  • I would like to indent some elements, but the default distance is too much and the sans-indent is too little.

    我想缩进一些元素,但默认距离太大而无缩进太小。

    回答by thirtydot

    <ul style="padding-left:20px">
        <li>Element 1</li>
        <li>Element 2</li>
    </ul>
    

    I think the default indentation is 40px, this halves it.

    我认为默认缩进是40px,这将其减半。

    回答by ebaum

    li {
      margin-left: 10px;
    }
    ul li{ 
      margin-left: 20px;
    }
    

    A slightly cleaner way to adjust both of the indentations. Margin and padding differ, so use whichever suits you best.

    一种更简洁的方法来调整两个缩进。边距和填充不同,因此请使用最适合您的那个。