【问题标题】:Aligning side by side in a modal在模态中并排对齐
【发布时间】:2014-09-23 15:26:45
【问题描述】:

这是我的fiddle

HTML

<div id="wrapper">
    <div class="notes">One</div>
    <div class="notes">two</div>
    <div class="notes">three</div>
    <div class="notes">four</div>
</div>

CSS

#wrapper {
    width: 300px;
    overflow-x: scroll;
    overflow-y: scroll;
    border: 1px solid black;
}
.notes {
    color: red;
    border: 1px solid green;
    margin: 5px;
    width: 200px;
    height: 150px;
    display: inline-block;
}

我有一个 300 像素宽度的包装 div。

内部 div 是根据服务器请求动态生成的,每个 div 的宽度为 200px。

现在我需要在包装器中并排设置,当它达到 300px 时,它需要以滚动模式显示..

似乎我的代码中有一些问题。请帮忙...

【问题讨论】:

  • 这是一个弹出窗口。对不起,多出来一行 :)
  • jsfiddle.net/rnu721kw/2 嘿,也许身高会有所帮助?
  • @Nerfair:我需要一个活动滚动条来查看所有子 div

标签: html css


【解决方案1】:

您可以将white-space: nowrap; 提供给包装器,然后为每个项目将其重置为white-space: normal;

Example Here

#wrapper { white-space: nowrap; }
.notes { white-space: normal; }

您可能还想remove the white-space between inline block elements。有几种方法可以实现这一点,其中一种可能是将 font-size: 0 设置为父级,然后将其重置为子级的 font-size: 16px

Updated Example

【讨论】:

  • @steeve 请更新小提琴,包括弹出窗口。
猜你喜欢
  • 2020-08-12
  • 2016-07-10
  • 1970-01-01
  • 2014-09-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-17
  • 1970-01-01
  • 2021-09-06
相关资源
最近更新 更多