【发布时间】:2018-02-02 13:02:27
【问题描述】:
谁能告诉我为什么行方向弹性容器中的 div 内的文本不能正确换行但会溢出?
如果我把方向改成section,文字会换行,我不明白为什么……
html,
body {
height: 100%;
}
body {
overflow-y: scroll;
margin: 0;
}
div,
main,
section {
align-items: stretch;
display: flex;
flex-shrink: 0;
flex-direction: column;
flex-wrap: nowrap;
position: relative;
}
main {
flex-grow: 1;
}
section {
flex-flow: row nowrap;
flex-grow: 1;
justify-content: center;
margin: 0 auto;
max-width: 1280px;
padding: 60px 0;
}
.content {
flex-grow: 1;
justify-content: start;
}
<body>
<main>
<section>
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum eget nulla sagittis sem egestas molestie. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
</div>
</section>
</main>
</body>
【问题讨论】:
-
似乎在 sn-p 中工作正常,你必须有一些其他风格搞砸了任何不适合你的东西
-
文本到底在哪里溢出?我在你的代码 sn-p 中没有看到它。
-
抱歉我改了代码
-
您是否有更多关于您尝试如何格式化文本的信息?更改某些属性(例如 flex-shrink)可能会产生巨大的变化,但这完全取决于您想要对文本完成什么。
标签: html css flexbox word-wrap