问题
我需要内容强制在 X 轴上滚动,而不是在 Y 轴上滚动。
HTML
我知道这是格式错误,但它是动态生成的并且没有空格。
<div class="folderWrapper" id="folderContainer"><div class="folderBox ui-droppable folderBoxSel" onclick="folderSelected(0)" id="fBox0"><div class="counter" id="fCount0">4</div><div class="folderName">Unsorted</div></div><div class="folderBox ui-droppable" onclick="folderSelected(1)" id="fBox1"><div class="counter" id="fCount1">0</div><div class="folderName">test</div></div><div class="folderBox" onclick="folderSelected(1)" id="fBox1"><div class="counter" id="fCount1">0</div><div class="folderName">test</div></div><div class="folderBox" onclick="folderSelected(1)" id="fBox1"><div class="counter" id="fCount1">0</div><div class="folderName">test</div></div><div class="folderBox" onclick="folderSelected(1)" id="fBox1"><div class="counter" id="fCount1">0</div><div class="folderName">test</div></div><div class="folderBox" onclick="folderSelected(1)" id="fBox1"><div class="counter" id="fCount1">0</div><div class="folderName">test</div></div></div>
用一个文件夹内框很好地格式化:
<div class="folderWrapper" id="folderContainer">
<div class="folderBox ui-droppable folderBoxSel" onclick="folderSelected(0)" id="fBox0">
<div class="counter" id="fCount0">4</div>
<div class="folderName">Unsorted</div>
</div>
</div>
CSS
.folderWrapper{
overflow-x:scroll;
overflow-y:hidden;
height:85px;
white-space:nowrap;
margin-bottom:5px;
}
.folderBox{
float:left;
background-image:url(../images/artworking/folder.png);
background-position:center top;
background-repeat:no-repeat;
width:85px;
height:55px;
position:relative;
padding:5px;
z-index:4;
white-space:nowrap;
}
.folderBox:hover{
cursor: pointer;
}
如果有人可以提供帮助,谢谢!
编辑
Bazzz 的答案适用于所有浏览器,除了 IE 兼容模式(不幸的是它必须兼容),它给出了以下外观:
使用 IE 破解: