UL 是否有默认边距或填充 [英] Does UL have default margin or padding
问题描述
这似乎是一个愚蠢的问题,但我已将 UL 添加到基本页面,并且列表似乎偏离了中心.名单没有什么特别之处.没有添加特定的 css:只是一个列表.当我实时加载时,它略微偏离中心.
左侧是否有默认边距或填充?
This might seem like a dumb question, but I've added an UL to a basic page and the list seems to be off-centered. There's nothing special about the list. No specific css added: just a list. When I load live it's slightly off center.
Is there a default margin or padding on the left side?
<h3>Title Heading</h3>
<ul id="listItems">
<li>itemOne</li>
<li>itemTwo</li>
<li>itemThree</li>
</ul>
主体具有居中、对齐、浮动等所有css代码.标题标题"完美对齐.只是列表有点不对.
The main body has all the css code for centering, aligning, float, etc. The 'Title Header' align perfectly. Just list is a little off.
谢谢.
哦,不知道这是否重要,但我添加了 'id' 原因...想使用 'first-of-type' 给第一个项目 em(粗体).
Oh, don't know if this is important, but I added the 'id' cause... wanted to use 'first-of-type' to give 1st item em(bold).
推荐答案
问题是默认情况下,浏览器有自定义 css - 例如在 chrome 中:
The problem is that by default, browsers have custom css - in chrome for example:
ul, menu, dir {
display: block;
list-style-type: disc;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
-webkit-padding-start: 40px;
}
您必须为您的 ul
使用自定义规则:
You'll have to use a custom rule for your ul
:
element.style {
margin-left: 0px;
/* set to 0 if your not using a list-style-type */
padding-left: 20px;
}
这篇关于UL 是否有默认边距或填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!