我正在实现 jQuery Masonry 插件,但我遇到了元素宽度超过一列的问题,这意味着所有 Masonry 元素的 div 宽度并不相同。有人可以帮我吗?
<!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>Test</title>
<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="js/masonry.min.js" type="text/javascript"></script>
</head>
<style>
.item0,.item1,.item2,.item3,.item4,.item5,.item6,.item7,.item8{float:left; margin: 10px;
background:#999;}
.item1,.item0 {
width:300px;
}
.item2 {
width:200px;
}
.item3,.item8 {
width:100px;
}
.item4,.item5,.item6,.item7{
width:100px;
}
#container{
float:left; width:1000px;
}
</style>
<script type="text/javascript">
$(function(){
$('#container').masonry(
{});
});
</script>
<body>
<div id="container">
<div class="item0">1 tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf</div>
<div class="item0">2 sdf sdf sdf sdf d dsfdsfds sf sdf sdfsdf </div>
<div class="item1">3 sdfsdfsdf sdf sdfsdf sdf sdfs ddsf dsf sd sdf </div>
<div class="item2">4 tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf</div>
<div class="item3">5 sdf sdf sdf sdf d dsfdsfds sf sdf sdfsdf </div>
<div class="item4">6 sdfsdfsdf sdf sdfsdf sdf sdfs ddsf dsf sd sdf </div>
<div class="item5">7 tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf</div>
<div class="item6">sdf sdf sdf sdf d dsfdsfds sf sdf sdfsdf </div>
<div class="item7">sdfsdfsdf sdf sdfsdf sdf sdfs ddsf dsf sd sdf </div>
<div class="item8">tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf</div>
<div class="item7">sdfsdfsdf sdf sdfsdf sdf sdfs ddsf dsf sd sdf </div>
<div class="item8">tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf tsetsdf sdf sdfs dsdf sds dsf sdf dsf dsf df df df df dfs dfsdf sdf df sdf sdf sdf sdf</div>
</div>
</body>
</html>