【发布时间】:2014-06-16 15:45:48
【问题描述】:
这是一个聊天室,里面有一个 div .words 作为容器,里面有一个 .content div。
我想从 .content 底部显示文本,所以我使用 position:absolute, bottom:0;在 .content 上。但如果.content 增长高于.words,我希望它显示滚动条。所以我在 .words 上添加了溢出:自动。
如果我删除底部:0,溢出:自动将正常工作。但如果 bottom:0 则不起作用。
如何让输入从底部显示,溢出时会有滚动条?
CSS:
.tbchat-room{
position: fixed;
bottom:0;
width:260px;
border:1px solid #aaa;
background:#fff;
}
.tbchat-room .head{
padding: 3px 10px;
background:#3d9ac1;
color:#fff;
}
.tbchat-room .words{
height:230px;
background:#ececec;
overflow:auto;
position:relative;
}
.tbchat-room .words .content{
position:absolute;
}
.tbchat-room .say{
width:246px;
margin:0;
border-top: 1px solid #ccc;
border-bottom: 0;
border-left: 0;
border-right: 0;
padding:4px 6px;
}
.pull-right{
float:right;
}
.content{
padding:5px 10px;
}
HTML:
<div class="tbchat-room">
<div class="head">
<span class="title">Chat Room</span>
<a class="room-close-button pull-right">×</a>
</div>
<div class="words">
<div class="content">
<div>sample text</div>
<div>sample text</div>
</div>
</div>
<input class="say" type="text"/>
</div>
【问题讨论】:
-
删除
botton:0并尝试以另一种方式滚动。 stackoverflow.com/questions/270612/scroll-to-bottom-of-div
标签: css html scroll vertical-alignment