Html 使用 CSS 删除 ul 缩进
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9620594/
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
Removing ul indentation with CSS
提问by solerous
I cannot seem to remove the indent from my unordered list when long lines in my list wrap around. Here is what my list looks like:
当我的列表中的长行环绕时,我似乎无法从我的无序列表中删除缩进。这是我的清单:
- Windows users can use putty
- Mac users can use the Terminal.app
- Linux users can use SSH [email protected] port 22
- ...........>Or use an SFTP program like Cyberduck just point it at .........................................>ourserver.com, port 22
- Windows 用户可以使用 putty
- Mac 用户可以使用 Terminal.app
- Linux 用户可以使用 SSH [email protected] 端口 22
- ......> 或者使用像 Cyberduck 这样的 SFTP 程序,只需将其指向 ...................... ......>ourserver.com,端口 22
(the dots show the indents)
(点表示缩进)
I've read a bunch of solutions and tried setting margin and padding to zero, using text-indent, list-style, but nothing works. I think the problem is that there is a heading above the list that I need to be centered and so I'm setting the margins to auto and then it's messing up the list below. But even if I put say two divs inside the parent div it doesn't work.
我已经阅读了一堆解决方案,并尝试使用文本缩进、列表样式将边距和填充设置为零,但没有任何效果。我认为问题在于列表上方有一个标题需要居中,因此我将边距设置为自动,然后将下面的列表弄乱了。但即使我在父 div 中放置了两个 div,它也不起作用。
Here is the HTML/CSS (I included everything in case there is some setting that is causing all of the other solutions to fail)
这是 HTML/CSS(我包含了所有内容,以防某些设置导致所有其他解决方案失败)
<div id="info">
<p><strong>Did you know you can SSH directly to ourserver.com?</strong> </p>
<ul>
<li>Windows users can use putty</li>
<li>Mac users can use the <a href="http://www.terminfo.org">Terminal.app</a></li>
<li>Linux users can use SSH [email protected] port 22</li>
<li>Or use an SFTP program like <a href="http://cyberduck.ch/">Cyberduck</a> just point it at ourserver.com, port 22</li>
</ul>
</div>
#info {
color:#FFFFFF;
width:440px;
margin-left:auto;
margin-right:auto;
border-radius: 10px;
border-style:solid;
border-width:2px;
border-color:#FFF;
padding-bottom:20px; padding-left:20px; padding-right:20px;
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#333333), to(#cccccc));
overflow: hidden;
}
#info ul li {
float:left;
}
回答by Zac
This code will remove the indentation and list bullets.
此代码将删除缩进并列出项目符号。
ul {
padding: 0;
list-style-type: none;
}
回答by pleerock
-webkit-padding-start: 0;
will remove padding added by webkit engine
将删除由 webkit 引擎添加的填充
回答by Smamatti
Remove this from #info
:
从以下内容中删除#info
:
margin-left:auto;
Add this for your header:
为您的标题添加此内容:
#info p {
text-align: center;
}
Do you need the fixed width etc.? I removed the in my opinion not necessary stuff and centered the header with text-align
.
你需要固定宽度等吗?我删除了我认为不必要的东西,并用text-align
.