【问题标题】:How do I fit the content inside this div if max-width to the parent div is given如果给定父 div 的最大宽度,我如何将内容放入此 div
【发布时间】:2021-11-20 06:36:07
【问题描述】:

enter image description here

我正在使用一个最大宽度为 80% 的容器,在扩展文本后,容器被卡在 80%,而不是根据文本灵活。 有人请给出解决方案

【问题讨论】:

  • 发布您的代码,以便我们重现您的问题。

标签: css storybook


【解决方案1】:

如果您共享代码而不是图片,它将非常有用。据我了解问题-> 如果您的块小于 80%,则块宽度应等于内容宽度-> 文本宽度。正确的? 这是一个例子:

<div class="test">
  here is the text, which I can make bigger and everything will still take 80% maximum
</div>

.test {
  background: red;
  max-width: 80%;
  display: inline-block;
}

如果我理解错了,请纠正我。 谢谢。

【讨论】:

    猜你喜欢
    • 2014-09-05
    • 2017-12-09
    • 1970-01-01
    • 1970-01-01
    • 2014-11-30
    • 1970-01-01
    • 2011-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多