html - 内容没有正确包装?

标签 html css

我的作品集网站出现问题,内容未正确包装。对于大于 480 像素的宽度,它在三列 View 中看起来不错,但当它低于该值时,它会切换到两列布局/移动 View ,并且不再完全正确换行。

有那么大的空间,我正试图弄清楚如何纠正它。主页是唯一的问题。任何帮助将不胜感激!

HTML 骨架:

<div id="wrapper">
  <section>
    <ul id="gallery">
      <li></li>
    </ul>
  </section>
</wrapper>

相关 CSS:

#wrapper {
 overflow: auto;
 margin: 0 auto 100px auto;
 max-width: 940px;
 padding: 0 5%;
 }

#gallery {
 margin: 0;
 padding: 0;
 list-style: none;
 }

#gallery li {
 float: left;
 width: 45%;
 margin: 2.5%;
 background-color:  #f2f2f2;
 }

#gallery li a p {
 margin: 0;
 padding: 5%;
 font-size: 0.5em;
 color: #3b4145;
 }

最佳答案

移动版添加#gallery li:nth-child(odd) {clear: left;},三列撤销。


你还应该为三列布局制定相关规则#gallery li:nth-child(3n+1) {clear: left;}

它目前靠运气(由于特定元素的内容,如果您更改它们的顺序,它将失败)

关于html - 内容没有正确包装?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40269983/

相关文章:

javascript - 当我添加新文本字段时,文本字段会重置

css - HTML5:文本区域占位符::在内容 css 之后在 Mozilla 和 IE 中不起作用

php - 简单的 html dom 奇怪的行为

css - 这是 Firefox 的 css 错误吗

javascript - 具有随时间褪色效果的文本颜色

html - 相对 URL 和尾部斜杠

html - Bootstrap Tabs 不工作但代码看起来不错

html - 如何用边界边上的链接创建一个圆

CSS 布局 : text overwriting footer, 文本隐藏在图像等后面

html - 与无序列表内联的框,bootstrap 3