CSS& jQuery调整大小问题

时间:2012-12-28 15:01:20

标签: javascript jquery css css3

我正在尝试创建一个可调整大小的聊天框。 我几乎拥有它,除非我调整底部部分的大小,并且我不能使userList成为固定大小,不会受到调整大小的影响。

jsbin

HTML:

  <div id="chatWindow">
    <div id="dragBar"></div>
    <div id="container">
      <div class="content">
      <p>aici vine niste text</p></div>
      <div class="content">
      <p>aici vine niste text</p></div>
    </div>

    <div id="usersList">
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
      <div class="user"></div>
    </div>


  <div id="inputTxt"></div>

  </div>

CSS:

body{
    background: #e6e6e6 
}

#chatWindow{
width:750px;
height:400px;
background-color:white;
border-style:solid;
border-width:1px;
border-color:darkgray;
}

#usersList{
  position:relative;
  background-color:#CCC;
  height:88%;
  width:25%;
  position:relative;
  float:right;
  overflow-y:scroll;
}

#dragBar{
  background-color:darkblue;
  width:750px;
  min-height:23px;
  max-height:23px;

}

#container{
 float:left;
  width:75%;
  height:88%;
  background-color:#CCC;
  clear:both;
  overflow-y:scroll;
  word-wrap:break-word;
}

.content{
  width:95%;
  min-height:10px;
  background-color:lightgray;
  float:left;
  margin:5px;
  clear:both;
}

#inputTxt{
  position:absolute;
  width:100%;
  height:25px;
  background-color:green;
  clear:both;
  bottom:0px;
}

.user{
  margin:4px;
  width:150px;
  height:30px;
  background-color:white;
  margin-left: auto ;
  margin-right: auto ;


}

JS:

$(function() {
  $( "#chatWindow" ).resizable({
    alsoResize: '#dragBar',

   });
    });

2 个答案:

答案 0 :(得分:0)

将底部固定为固定部分。

body{
background: #e6e6e6 
}

#chatWindow{
width:750px;
height:400px;
background-color:white;
border-style:solid;
border-width:1px;
border-color:darkgray;
  position: relative;
  padding-bottom: 48px;
}

#usersList{
  position:relative;
  background-color:#CCC;
  height:100%;
  width:25%;
  position:relative;
  float:right;
  overflow-y:scroll;
}

#dragBar{
  background-color:darkblue;
  width:750px;
  min-height:23px;
  max-height:23px;

}

#container{
 float:left;
  width:75%;
  height:100%;
  background-color:#CCC;
  clear:both;
  overflow-y:scroll;
  word-wrap:break-word;
}

.content{
  width:95%;
  min-height:10px;
  background-color:lightgray;
  float:left;
  margin:5px;
  clear:both;
}

#inputTxt{
  position:absolute;
  width:100%;
  height:25px;
  background-color:green;
  clear:both;
  bottom:0;
  z-index: 1;
}

.user{
  margin:4px;
  width:150px;
  height:30px;
  background-color:white;
  margin-left: auto ;
  margin-right: auto ;


}

小提琴:http://jsbin.com/ibimaq/18/edit

答案 1 :(得分:0)

尝试添加overflow:hidden到#chatWindow。

#chatWindow{overflow:hidden;}

http://jsbin.com/ibimaq/19/edit