我创建了这个jsbin:http://jsbin.com/qoriqihapara/1/edit
如你所见,我有两个问题我不知道如何解决
right的计算并不完美。代码:
var right = 10;
var rightPadding = 10;
function CreateDiv(id)
{
var ToAppend = "<div class='Msg_container_dv' id='Msg_container_dv_" + id + "' style='right:" + right + "px' >"
+ "<div class='Chat_Header_dv'>"
+ "<table><tr>"
+ "<td><a href='javascript:void(0)' onclick='closeChatwnd(\"Msg_container_dv_" + id + "\")' >close window</a></td>"
+ "</tr></table>"
+ "</div>"
+ "<div class='Chat_Body_Container' id='Chat_Body_Container_" + id + "'>" + id + "...</div>"
+ "<div class='Chat_Footer_Container'>text here...</div>"
+ "</div>";
right = right + (280 + rightPadding); // 280 is the width of the chat window
$("#chat_div_container").append(ToAppend);
}
function closeChatwnd(id)
{
$("#" + id).remove();
right = right - (280 + rightPadding);
}发布于 2014-08-20 08:18:51
我建议这样做:
#chat_div_container
{
padding-right:15px;
position:fixed;
bottom:0px;
right:0px;
width:200%; /*or more*/
}对于Msg_container_dv
.Msg_container_dv
{
height:280px;
width:280px;
border:1px solid #868686;
bottom:0px;
float:right;
}简单又简单。
不要忘记从style='right:" + right + "px'中删除Msg_container_dv
https://stackoverflow.com/questions/25399416
复制相似问题