如何使元素不会扩展到其内容的大小并保持其可变宽度的内联块父级的宽度?

时间:2017-11-23 01:54:43

标签: css

想象一下结构:

<div class="container">
    <div class="first">Variable, but Desired Width</div>
    <div class="second">Text that may be long. But it should not exceed the width of the element above.</div>
</div>

我正在寻找纯CSS 解决方案(如果可能的话)以下内容:

  • .first是内联块,其宽度可能因内容而异。

  • 我希望.second占据.first的全宽,不超过

一张图片胜过千言万语:

enter image description here

0 个答案:

没有答案