我在項目中使用了Horizontal-scrolling圖片庫。簡短腳本(<50行)在jfiddle中工作,但不是瀏覽器
最近滾動停止工作,我一直在試圖找出原因。最終,我決定回到項目的這個部分的源頭並努力工作,但我甚至無法運行它。
我必須做一些簡單的錯誤 - 任何想法?
我的代碼:
HTML
<head>
<script type="text/javascript" src="./jquery-2.0.2.min.js"></script>
<link rel="stylesheet" type="text/css" href="./waterfall3.css" />
<script type="text/javascript" src="./waterfall.js"></script>
</head>
<body>
<div class="media">
<div class="imageContainer">
<div class="image"><a href="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSGr4F-VQME__rGsSQitz9PkWGJ7C1XbUlhkleUw-5JVyYImWJ6hg"><img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSGr4F-VQME__rGsSQitz9PkWGJ7C1XbUlhkleUw-5JVyYImWJ6hg" height="250px" style="max-width: 100%;" alt=""></a></div>
<div class="image"><a href="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSGr4F-VQME__rGsSQitz9PkWGJ7C1XbUlhkleUw-5JVyYImWJ6hg"><img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSGr4F-VQME__rGsSQitz9PkWGJ7C1XbUlhkleUw-5JVyYImWJ6hg" height="250px" style="max-width: 100%;" alt=""></a></div>
<div class="image"><a href="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSGr4F-VQME__rGsSQitz9PkWGJ7C1XbUlhkleUw-5JVyYImWJ6hg"><img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSGr4F-VQME__rGsSQitz9PkWGJ7C1XbUlhkleUw-5JVyYImWJ6hg" height="250px" style="max-width: 100%;" alt=""></a></div>
</div>
</div>
</body>
JS
var imageWidth = 300;
$(".imageContainer").width($(".image").length*imageWidth);
CSS
.media
{
width: 300px;
height: 288px;
float: left;
display: inline-block;
overflow-x: auto;
-ms-overflow-x: auto;
overflow-y: hidden;
-ms-overflow-y: hidden;
white-space: nowrap;
}
.image
{
float: left;
height: 240px;
width: 300px;
margin: 0;
text-align:center;
border: 0px solid white;
}
.imageContainer
{
float:left;
}
你檢查控制檯,看看你錯過任何包括?也許jQuery或瀑布不在特定的文件夾? –
可能是'DOCTYPE'聲明的問題.. 99%肯定.. –
當您請求DOM時,您應該將JS代碼包裝在DOM就緒處理程序中:'$(function(){ $(「。imageContainer」)。 width($(「。image」).length * imageWidth); –