我有一个 Parent Div chatRooms
,里面有很多chatRoom
's,并且chatRoomName
Div 仅用于正确格式化。
我的意图是让每一个都chatRoom
float:left;
在前一个旁边chatRoom
,然后有一个水平滚动条,以防 all 的最大宽度chatRoom
超过父 div 的宽度chatRooms
,这实际上是有效的,但超出chatRoom
的被放置在第二行, 不是在最后一个旁边chatRoom
,我希望它们都在同一行上说,即使其中一些看不到,但是当我向右滚动时我将能够看到它们。
<div id="chatRooms">
<div class="chatRoom">
<div class="chatRoomName">
IUL
</div>
</div>
<div class="chatRoom">
<div class="chatRoomName">
CCE
</div>
</div>
<div class="chatRoom">
<div class="chatRoomName">
CCE
</div>
</div>
<div class="chatRoom">
<div class="chatRoomName">
CCE
</div>
</div>
<div class="chatRoom">
<div class="chatRoomName">
CCE
</div>
</div>
<div class="chatRoom">
<div class="chatRoomName">
CCE
</div>
</div>
<div class="chatRoom">
<div class="chatRoomName">
CCE
</div>
</div>
<div class="chatRoom">
<div class="chatRoomName">
CCE
</div>
</div>
<div class="chatRoom">
<div class="chatRoomName">
CCE
</div>
</div>
<div class="chatRoom">
<div class="chatRoomName">
CCE
</div>
</div>
</div>
CSS:
#chatRooms
{
border-style:solid;
border-width: 1px;
border-color: green;
overflow-x:scroll;
margin-top:5px;
height:30px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.chatRoom
{
width:100px;
border-style:solid;
border-color:green;
margin-right:1px;
float:left;
cursor:pointer;
}
.chatRoomName:hover
{
color:chartreuse;
}
.chatRoomName
{
background-color:green;
border-style:solid;
border-color:green;
color:white;
}