css - 带 flex 的内联 div

标签 css flexbox

假设我有 2 个应该内联的 div,如果内容多于父 div,我想让第二个 div 增长到第一个 div 以下。现在当我添加 flex 并使它们内联时,它看起来像这样: JSFiddle

是这样的:

enter image description here

有什么建议吗?

最佳答案

这对于 flexbox 是不可能的。

但是,如果您制作所需的元素display:inline,它就是。

.field,
.field-items,
.field-item {
  display: inline;
}

h2 {
  margin-top: 0;
  display: inline;
}
<div class="group-title-wrapper">
  <div class="field field-name-post-date field-type-ds field-label-hidden">
    <div class="field-items">
      <div class="field-item even">08 January</div>
    </div>
  </div>

  <div class="field field-name-title field-type-ds field-label-hidden">
    <div class="field-items">
      <div class="field-item even" property="dc:title">
        <h2>Vokalia and Consonantia, there live the blind texts.Lorem ipsum dolor amet schlitz ennui taxidermy bespoke vinyl lyft iceland selfies quinoa intelligentsia. Tacos semiotics yuccie fam photo booth hella health goth kitsch whatever waistcoat.</h2>
      </div>
    </div>
  </div>
</div>

关于css - 带 flex 的内联 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54303799/

相关文章:

css - Flexbox 列自底部对齐

html - 如何在导航栏中添加单独的标题

css - float 的 div 不会扩展到父 div 的全宽。为什么?

javascript - 将 Python 后端与桌面应用程序的 HTML/CSS/JS 用户界面集成?

javascript - 如何切换页面的一部分,以便从一段文本转到另一段文本?

html - 使图像缩放以在适合 flexbox 时保持其纵横比

Div 下的 CSS Div

html - 尝试创建页眉、内容和页脚的基于 flex 的布局

html - 为什么 flex 元素不缩小过去的内容大小?

css - SVG 和 CSS 中的简单速度计动画