2013-07-12 25 views

回答

0

如果使用floatting方法,除了应先在流量: http://jsfiddle.net/W3MKx/1/

<div id="all"> 
    <aside id="ball"> 
     <form> 
      <input type="text" id="ueoa" autocomplete="off" placeholder="Search user" /> 
      <ul id="caoeu"></ul> 
     </form> 
    </aside> 
    <article id="chat"> 
     <div id="chat-header"> <span class='label'>Site</span> 
<span id="iiae"></span> 

      <button class="btn" id="nht"> 
       <img src="img/icon/htino.png" />View</button> 
     </div> 
     <div id="chat-entries"></div> 
    </article> 
</div> 
1

我建议做以下几点:(working jsFiddle

不改变适用你的HTML结构以下CSS:

#all { 
    background: blue; 
    overflow:hidden; /* This is mandatory to make the parent wrap around the children */ 
} 

#ball { 
    background: red; 
    float: right; /* float sidebar to the right */ 
    width:200px; /* constant width as you requested */ 
} 

#chat{ 
    width:calc(100% - 210px); /* You can set the width in any way you choose - just make sure to leave room for the sidebar */ 
    float:left; /* float the chat to the left */ 
} 

当使用浮动元素时,最好将overflow:hidden;设置为容器 - 这将强制它环绕所有的孩子,而不管他们的身高。您还需要设置聊天的宽度,以便有侧边栏的空间。将聊天浮动到左侧并将侧边栏浮动到右侧。