【问题标题】:Let div expand to the bottom if there would be an overflow [duplicate]如果会有溢出,让 div 扩展到底部 [重复]
【发布时间】:2021-10-18 05:58:58
【问题描述】:

所以我建立了一个网站,我在上面实现了一个信使盒。我希望溢出强制 div 将其高度扩展到页面底部。 现在看起来像这样:

html 结构应该是这样的:

<div class="chat">
<div class="message-box">
<div class="others-message">Wie gehts</div>
<div class="my-message"></div>
<div class="others-message"></div>
</div>
...

这是我的css代码:

.chat{
grid-area:chat;
width:400px;
height:600px;
border-radius: 25px;
display:inline-block;
vertical-align:top;
}

.message-box{
display:inline-block;
clear:both;
overflow:auto;
position:relative;
width:360px;
height:75%;
margin:10px;
margin-top:60px;
border-radius:5px;
background-color:#f0ffff;
-webkit-box-shadow: 0px Opx 12px -2px #000000;
box-shadow: Opx Opx 12px -2px #000000;
}

.my-message{
position:relative;
text-align:left;
color:white;
background-color:blue;
border-radius:20px;
padding:10px;
margin:10px;
width:70%;
}

.others-message{
position:relative;
text-align:left;
color: white;
background-color:grey;
border-radius:20px;
padding:10px;
margin:10px;
margin-left:100px;
max-width:70%;
min-height:40px;
}

【问题讨论】:

  • 你在你的消息框上试过word-wrap: break-word吗?
  • 工作得很好,谢谢!!!
  • 你想添加这个作为答案,以便我可以将其标记为解决方案吗?:)
  • 将其添加为答案

标签: html css overflow chat


【解决方案1】:

在消息类选择器上使用word-wrap: break-word

word-wrap 属性允许长词被打断 换行到下一行。

【讨论】:

    【解决方案2】:

    您可以尝试在 CSS 的 my-message 和 others-message 类中添加 widthoverflow 属性。

    【讨论】:

    • 谢谢,但是word-wrap: break-word 帮我做了
    猜你喜欢
    • 1970-01-01
    • 2023-04-04
    • 2012-11-06
    • 2018-02-02
    • 1970-01-01
    • 1970-01-01
    • 2014-07-23
    • 2013-07-05
    相关资源
    最近更新 更多