Html 在另一个div的底部对齐div?
下面是css/htmlHtml 在另一个div的底部对齐div?,html,css,css-position,Html,Css,Css Position,下面是css/html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="tex
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
#chatContainer {
position: fixed;
bottom: 20px;
right: 0;
vertical-align: bottom;
}
.chat {
border: 1px solid #999;
float: right;
margin: 0 5px;
height: 200px;
width: 250px;
vertical-align: bottom;
overflow: hidden;
bottom: 0px;
transition: 1s;
}
.title {
padding: 0.5em;
background-color: blue;
color: white;
}
.text {
padding: 10px;
overflow-y: scroll;
overflow-x: hidden;
height: 120px;
}
.inputText {
width: 100%
}
</style>
</head>
<body>
<div id="chatContainer">
<div class="chat" id="{id}">
<div class="title"> <span>{title}</span>
<div style="float:right">
<input class="minimize" name="" value="min" type="button">
</div>
</div>
<div class="text"> </div>
<div class="chatbox">
<input type="text" class="inputText" placeholder="enter text" />
</div>
</div>
<div class="chat" id="{id}" style="height:100px">
<div class="title"> <span>{title}</span>
<div style="float:right">
<input class="minimize" name="" value="min" type="button">
</div>
</div>
<div class="text"> </div>
<div class="chatbox">
<input type="text" class="inputText" placeholder="enter text" />
</div>
</div>
</div>
</body>
</html>
#聊天室{
位置:固定;
底部:20px;
右:0;
垂直对齐:底部对齐;
}
.聊天{
边框:1px实心#999;
浮动:对;
利润率:0.5px;
高度:200px;
宽度:250px;
垂直对齐:底部对齐;
溢出:隐藏;
底部:0px;
过渡:1s;
}
.头衔{
填充:0.5em;
背景颜色:蓝色;
颜色:白色;
}
.文本{
填充:10px;
溢出y:滚动;
溢出x:隐藏;
高度:120px;
}
.inputText{
宽度:100%
}
{title}
{title}
我的问题是,我希望聊天室在底部对齐
下面是我得到的坏结果:
知道怎么解决吗
(我尝试了垂直对齐,但没有成功)
我创造了小提琴:
(点击min查看bug)为css的以下id添加宽度:
#chatContainer {
bottom: 20px;
position: fixed;
right: 0;
vertical-align: bottom;
width: 265px; // added width
}
演示:将框css位置设置为绝对,并将基本定位命令添加到css样式
#id_chat{
position:absolute;
bottom:0;
right:250px; /*width of your very right chat box, + you can add e.g. 10px as margin*/
}
其实很简单,我只是做了一把小提琴,上面显示了一个固定位置的聊天室 底部有一个输入区域 我制作了一个innerholder,以确保它在所有浏览器中都能正常工作 查看代码 代码:
.聊天{
高度:300px;
宽度:200px;
显示:块;
边框:1px实心#000;
位置:固定;
顶部:20px;
左:20px;
}
.chat.innerchat{
位置:相对位置;
身高:100%;
宽度:100%;
}
.chat.innerchat.textbox{
位置:绝对位置;
底部:0;
左:0;
宽度:100%;
边界:无;
背景:#ccc;
颜色:#404040;
高度:30px;
文本缩进:6px;
}
享受不要在聊天框上使用float:right,而是使用display:inline框,并将它们垂直对齐到底部
做一个提琴,这样我就可以更新你的代码:)然后我就可以想出一个解决方案来试试这个提琴它应该可以做到:看看min来重现这个错误还不错。。我的问题是聊天将被动态添加。没错:250px还不够好!这就是你想要的吗?您的错误是由于在降低元素高度时未设置边距顶部造成的。我的回答是,你们显然是通过JS添加了这些聊天,所以为什么不计算位置呢?
<div class="chat">
<div class="innerchat">
<input type="text" class="textbox" placeholder="start chatting" />
</div>
</div>
.chat {
height: 300px;
width: 200px;
display: block;
border: 1px solid #000;
position:fixed;
top:20px;
left:20px;
}
.chat .innerchat {
position:relative;
height:100%;
width:100%;
}
.chat .innerchat .textbox {
position:absolute;
bottom:0;
left:0;
width:100%;
border:none;
background:#ccc;
color:#404040;
height:30px;
text-indent:6px;
}
.chat {
display: inline-block;
vertical-align: bottom;
}