html - 如何去掉 UL 左边的空格?

标签 html css

好的,为了解释这一点,我在此处制作了一个可访问的 JSFiddle:JSFiddle

我想删除 UL 左侧的间距,我尝试删除列表样式,但这行不通。任何帮助表示赞赏。 谢谢。

ul li {
    list-style: none;
    display: inline;
    margin: 0 auto;
    padding: 0;
    list-style-type: none;
}

最佳答案

从列表本身移除填充,而不仅仅是列表的元素。

ul {
  padding: 0;
}

body {
  margin: 0 0 0 0px;
}
#header {
  background-color: #141414;
  height: 50px;
  width: 100%;
}
#wrapper {
  width: 100%;
  font-size: 0px;
}
#footer {
  background-color: #141414;
  width 100%;
  min-height: 200px;
}
ul li {
  list-style: none;
  display: inline;
  margin: 0 auto;
  padding: 0;
  list-style-type: none;
}
ul {
  padding: 0;
}
.galleryimg {
  width: 20%;
  margin: 0 auto;
}
<div id="header">

</div>
<div id="wrapper">
  <ul>
    <li>
      <img class="galleryimg" src="http://placehold.it/500x500"></img>
    </li>
    <li>
      <img class="galleryimg" src="http://placehold.it/500x500"></img>
    </li>
    <li>
      <img class="galleryimg" src="http://placehold.it/500x500"></img>
    </li>
    <li>
      <img class="galleryimg" src="http://placehold.it/500x500"></img>
    </li>
    <li>
      <img class="galleryimg" src="http://placehold.it/500x500"></img>
    </li>

    <li>
      <img class="galleryimg" src="http://placehold.it/500x500"></img>
    </li>
    <li>
      <img class="galleryimg" src="http://placehold.it/500x500"></img>
    </li>
    <li>
      <img class="galleryimg" src="http://placehold.it/500x500"></img>
    </li>
    <li>
      <img class="galleryimg" src="http://placehold.it/500x500"></img>
    </li>
    <li>
      <img class="galleryimg" src="http://placehold.it/500x500"></img>
    </li>
  </ul>
</div>
<div id="footer">
  sup m8
</div>

关于html - 如何去掉 UL 左边的空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28053127/

相关文章:

html - flexbox 父 div 在 ios 10 safari 中没有高度但在 ios 11 safari 中不是这样

javascript - Flex slider 在较小宽度的屏幕上重叠滑动

javascript - 隐藏/更改/添加图像

javascript - 选择一个以特定 div 内的内容结尾的 id

html - 如何让最小宽度在 Chrome 中的按钮上工作? (苹果系统)

html - Ruby 处理带计数的拆分列无序列表的方法?

javascript - 有什么比 HTML5 localStorage 更大的吗?

css - 如何使用伪元素在悬停时突出显示段落

javascript - 悬停弹出菜单不适用于导航子链接

html - 如何全宽内联按钮?