我在這裏製作一個頁面http://arin.esy.es/arin/site/species.php如何強制div與滾動條一起顯示?
問題是魚div(有class「節點」)似乎包裝在父div(類「row」)中。我想要它,以便所有節點div都在行div中水平行1行。我不希望它包裹。另外還有更多的行格。
我也希望它,以便沒有任何行divs獲得任何滾動條。應該有一個水平滾動條,但它應該只適用於行div的父級,這是一個td標籤。垂直滾動條不應該存在。水平滾動只有在需要時纔可見。
有誰知道如何做到這一點?
謝謝。
HTML
<!DOCTYPE >
<html>
<head></head>
<body>
<table id="fish_container">
<tbody>
<tr>
<td id="category_container" valign="top">
<div class="row">
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
<div class="node" style="background-image: url(http://arin.esy.es/arin/scripts/config/../../pics/category/1/1.png);"></div>
</div>
</td>
<td id="species_container" valign="top"></td>
</tr>
</tbody>
</table>
</body>
</html>
CSS
html {
background-color:blue;
}
#fish_container {
width:100%;
height:100%;
}
#category_container {
width:75%;
height:100%;
overflow-x: scroll;
}
#species_container {
width:25%;
height:100%;
overflow-x: scroll;
overflow-y: scroll;
}
.row {
width:100%;
height:100px;
text-align: center;
white-space: nowrap;
}
.node {
width:100px;
height:100px;
display: inline-block;
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
border: 2px solid transparent;
}
.node:hover {
border: 2px solid green;
}
發表了一些代碼.. –
這應該只是CSS,你不應該爲它需要任何Javascript。 – Barmar
可以製作一個寬度爲50000px的元素,這樣子女就不會換行(或者任何合理的)。將其父項的溢出設置爲自動或滾動 – charlietfl