html – 在无序列表中将列表项对齐到左侧

前端之家收集整理的这篇文章主要介绍了html – 在无序列表中将列表项对齐到左侧前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有以下html和css:

HTML

  1. <div id="wrapper">
  2. <ul>
  3. <li>li1</li>
  4. <li>li2</li>
  5. </ul>
  6. </div>

CSS:

  1. #wrapper
  2. {
  3. }
  4.  
  5. #wrapper ul
  6. {
  7. width:50px;
  8. height:100px;
  9. border-style:solid;
  10. border-width:1px;
  11. list-style-type:none;
  12. }
  13.  
  14. #wrapper ul li
  15. {
  16. border-style:solid;
  17. border-width:1px;
  18. }

这导致以下无序列表:

如何在无序列表中将列表项对齐到左侧?

我在“#wrapper ul li”中尝试过float和margin,但这并没有解决问题.

解决方法

在#wrapper ul块中添加一个padding-left:0pt:
  1. #wrapper ul
  2. {
  3. width:50px;
  4. height:100px;
  5. border-style:solid;
  6. border-width:1px;
  7. list-style-type:none;
  8. ' CHECK THE NEXT LINE '
  9. padding-left: 0pt;
  10. }

猜你在找的HTML相关文章