bulleted list with different indentation

2019-03-27 01:51发布

问题:

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

  • Element One
  • Element Two
  • and even this line which is not in an <li> tag are indented

  • List elements without the <ul> tags are
  • not indented
  • I would like to indent some elements, but the default distance is too much and the sans-indent is too little.

    回答1:

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

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



    回答2:

    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.