滝の流れのレイアウトコードの一例


 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> </title>
<script type="text/javascript" src="js/jquery.js"></script>
<style type="text/css">
body, div, img, h1, h2, h3, h4, h5, h6 { padding:0px; margin:0px; }
img { border:none; }
.wrapper { width:960px; margin:0 auto; }
#con1_1 { position:relative; }
#con1_1 .product_list { position:absolute; left:0px; top:0px; padding:10px; background:#eee; }
.product_list img { width:200px; display:block; }
.product_list h2 { padding:5px 0px; font-size:12px; text-align:center; color:#333; }
</style>
</head>
<body>
<div class="wrapper">
<h3> </h3>
<div id="con1_1">
<div class="product_list"> <a href="#"><img src="images/img1.jpg"></a>
<h2> </h2>
</div>
<div class="product_list"> <a href="#"><img src="images/img2.jpg"></a>
<h2> </h2>
</div>
<div class="product_list"> <a href="#"><img src="images/img3.jpg"></a>
<h2> </h2>
</div>
<div class="product_list"> <a href="#"><img src="images/img4.jpg"></a>
<h2> </h2>
</div>
<div class="product_list"> <a href="#"><img src="images/img5.jpg"></a>
<h2> </h2>
</div>
<div class="product_list"> <a href="#"><img src="images/img6.jpg"></a>
<h2> </h2>
</div>
<div class="product_list"> <a href="#"><img src="images/img7.jpg"></a>
<h2> </h2>
</div>
<div class="product_list"> <a href="#"><img src="images/img8.jpg"></a>
<h2> </h2>
</div>
</div>
<h3> js </h3>
</div>
</body>
<script type="text/javascript">
/*
:1. li
2. top 0
3. li
4. li li
*/
var margin = 10;//
var li=$(".product_list");//
var li_W = li[0].offsetWidth+margin;//
function liuxiaofan(){
var h=[];//
var n = 960/li_W|0;
for(var i = 0;i < li.length;i++) {
li_H = li[i].offsetHeight;// li
if(i < n) {//n li, n
max_H =Math.max.apply(null,h);
h[i]=li_H;// li
li.eq(i).css("top",0);// Li top 0
li.eq(i).css("left",i * li_W);// i li i*li
}
else{
min_H =Math.min.apply(null,h) ;// ,
minKey = getarraykey(h, min_H);//
h[minKey] += li_H+margin ;//
li.eq(i).css("top",min_H+margin);// Li, li
li.eq(i).css("left",minKey * li_W); // i li i*li
}
$("h2").eq(i).text(" :"+li_H);// H2
}
max =Math.max.apply(null,h) ;
$("#con1_1").css("height",max);
}
/* for in ( ) */
function getarraykey(s, v) {for(k in s) {if(s[k] == v) {return k;}}}
/* onload, */
window.onload = function() {liuxiaofan();};
window.onresize = function() {liuxiaofan();};


$(function(){
$(".product_list").hover(function(){
$(this).css("background-color","#ddd");
},function() {
$(this).css("background-color","#eee");
});
});
</script>
</html>