我有这些html标记
<div class="chatbar">
<div class="chatbox" style="margin-right:0px"> first</div>
<div class="chatbox" style="margin-right:5px"> chatbox</div>
<div class="chatbox" style="margin-right:10px"> chatbox</div>
<div class="chatbox" style="margin-right:15px"> chatbox</div>
<div class="chatbox" style="margin-right:20px"> chatbox</div>
<div class="chatbox" style="margin-right:25px"> chatbox</div>
</div>
我希望聊天栏div带有水平滚动条.. 但它不起作用,这是我的CSS
.chatbox{
float:right;
height: 180px;
width: 250px;
margin-right:10px;
border-right:1px solid red;
border-left:1px solid red;
}
.chatbar {
border: 1px solid blue;
overflow-x:scroll;
overflow-y:hidden;
width: 980px;
height: 200px;
position: relative;
bottom:10px;
float:right;//
}
元素正在追逐彼此。希望找到解决方案。
答案 0 :(得分:1)
尝试在.chatbox CSS中添加'position:relative'?
.chatbar { width:200px; overflow-x:auto; overflow-y:hidden; }
.wrapper { width: 600px; }
.chatbox { width:100px; float:left; }
<div class="chatbar">
<div class="wrapper">
<div class="chatbox"> first</div>
<div class="chatbox"> chatbox</div>
<div class="chatbox"> chatbox</div>
<div class="chatbox" > chatbox</div>
<div class="chatbox" > chatbox</div>
<div class="chatbox" > chatbox</div>
</div>
</div>