css - 将文本包裹在 div 内而不是展开它

标签 css

注意:我的 div 有自动宽度,我想保持这种状态。我认为如果我以某种方式弄清楚如何使用 CSS 给它一个等于当前(自动)宽度的最大宽度,我的问题就会得到解决,但我还没有找到任何东西。

问题: Problem, (ignore the background text, the div on which the messages show is transparent.) (忽略背景文本,显示消息的 div 是透明的。)

断线所需的宽度:
Desired width at which like should break

这是我的 CSS:

div.chat div#chatOutput {
   height: 370px;
   margin-bottom: 5px;
   max-height: 450px;
   min-height: 130px;
   border: 1px solid;
   overflow-y: scroll;
   padding: 5px;
}

还有我的 HTML:

<div class="chat">
            <h4><a title="Click to copy channel link" href="#">#</a> <span id="chatChannelName">General</span></h4>
            <div id="chatOutput"></div>
            <br />
            <div class="chat-group">
                <input type="text" maxlength="80" class="form-control" id="chatInput" placeholder="Type your message.." />
                <button class="btn btn-primary" id="chatSend"><i style="float: none;" class="fa fa-send"></i> Send</button>
            </div>
        </div>

最佳答案

尝试溢出:

一些属性:
可见 |隐藏 |滚动|汽车 |继承

关于css - 将文本包裹在 div 内而不是展开它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46579322/

相关文章:

javascript - 如何在 "Simplest jQuery Slideshow"上添加导航箭头?

html - Chrome 截掉了左边的部分字体,firefox 和 IE 显示正常。 Chrome 错误?

html - Svg 剪辑路径在 Firefox、IE 和 Opera 中不起作用

html - 我怎样才能得到我想回复的特定评论的 ID

css - 在 CSS-Grid-Layout 中使用 Angular *ngFor?

css - 很难找到页面的事件父类,应该显示为两个主菜单的子菜单

html - 用 css 完成这个网格

html - 向非响应式网站添加响应式背景图片

javascript - 使图像大小相同而不单独操纵它们的大小?

css - 如何将变换比例限制为 CSS 中父元素的宽度和高度?