Html 在无序列表中将列表项左对齐
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9111204/
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
Align list item to the left in unordered list
提问by Birdman
I have the following html and css:
我有以下 html 和 css:
HTML:
HTML:
<div id="wrapper">
<ul>
<li>li1</li>
<li>li2</li>
</ul>
</div>
CSS:
CSS:
#wrapper
{
}
#wrapper ul
{
width:50px;
height:100px;
border-style:solid;
border-width:1px;
list-style-type:none;
}
#wrapper ul li
{
border-style:solid;
border-width:1px;
}
Which results in the following unordered list:
这导致以下无序列表:
How do I align the list-items to the left in the unordered list?
如何在无序列表中将列表项与左侧对齐?
I've tried float and margin in the "#wrapper ul li", but that doesn't solve the problem..
我已经在“#wrapper ul li”中尝试了浮动和边距,但这并不能解决问题..
回答by Rohan Prabhu
Add a padding-left: 0pt
to the #wrapper ul
block:
padding-left: 0pt
在#wrapper ul
块中添加一个:
#wrapper ul
{
width:50px;
height:100px;
border-style:solid;
border-width:1px;
list-style-type:none;
' CHECK THE NEXT LINE '
padding-left: 0pt;
}
回答by Tomasz Machura
Try to decrease padding-left of your UL element. If it won't help, play with padding-left and margin-left of UL and LI.
尝试减少 UL 元素的 padding-left。如果没有帮助,请使用 UL 和 LI 的 padding-left 和 margin-left。
回答by onof
Your unordered list markers need to be put outside:
您的无序列表标记需要放在外面:
#wrapper ul {
list-style-type: none;
list-style-position: outside;
}