码迷,mamicode.com
首页 > 其他好文 > 详细

图片自动排列

时间:2017-06-17 18:19:40      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:http   this   rip   prepare   插件   plug-in   footer   log   宽度   

技术分享

 

 

<body>

<div id="container">
<header>
<h1>jQuery Wookmark 插件示例jQuery Wookmark 插件示例jQuery Wookmark 插件示例</h1>
</header>
<div id="main" role="main">

<ul id="tiles">
<li><img src="images/image_1.jpg" width="200" height="283"><p>1</p></li>
<li><img src="images/image_2.jpg" width="200" height="300"><p>2</p></li>
<li><img src="images/image_3.jpg" width="200" height="252"><p>3</p></li>
<li><img src="images/image_4.jpg" width="200" height="158"><p>4</p></li>
<li><img src="images/image_5.jpg" width="200" height="300"><p>5</p></li>
<li><img src="images/image_6.jpg" width="200" height="297"><p>6</p></li>
<li><img src="images/image_7.jpg" width="200" height="200"><p>7</p></li>
<li><img src="images/image_8.jpg" width="200" height="200"><p>8</p></li>
<li><img src="images/image_9.jpg" width="200" height="398"><p>9</p></li>
<li><img src="images/image_10.jpg" width="200" height="267"><p>10</p></li>
<li><img src="images/image_1.jpg" width="200" height="283"><p>11</p></li>
<li><img src="images/image_2.jpg" width="200" height="300"><p>12</p></li>
<li><img src="images/image_3.jpg" width="200" height="252"><p>13</p></li>
<li><img src="images/image_4.jpg" width="200" height="158"><p>14</p></li>
<li><img src="images/image_5.jpg" width="200" height="300"><p>15</p></li>
<li><img src="images/image_6.jpg" width="200" height="297"><p>16</p></li>
<li><img src="images/image_7.jpg" width="200" height="200"><p>17</p></li>
<li><img src="images/image_8.jpg" width="200" height="200"><p>18</p></li>
<li><img src="images/image_9.jpg" width="200" height="398"><p>19</p></li>
<li><img src="images/image_10.jpg" width="200" height="267"><p>20</p></li>
<li><img src="images/image_1.jpg" width="200" height="283"><p>21</p></li>
<li><img src="images/image_2.jpg" width="200" height="300"><p>22</p></li>
<li><img src="images/image_3.jpg" width="200" height="252"><p>23</p></li>
<li><img src="images/image_4.jpg" width="200" height="158"><p>24</p></li>
<li><img src="images/image_5.jpg" width="200" height="300"><p>25</p></li>
<li><img src="images/image_6.jpg" width="200" height="297"><p>26</p></li>
<li><img src="images/image_7.jpg" width="200" height="200"><p>27</p></li>
<li><img src="images/image_8.jpg" width="200" height="200"><p>28</p></li>
<li><img src="images/image_9.jpg" width="200" height="398"><p>29</p></li>
<li><img src="images/image_10.jpg" width="200" height="267"><p>30</p></li>
</ul>

</div>
<footer>

</footer>
</div>

<!-- include jQuery -->
<script src="js/jquery.js"></script>

<!-- Include the plug-in -->
<script src="js/jquery.wookmark.js"></script>

<!-- Once the page is loaded, initalize the plug-in. -->
<script type="text/javascript">
$(document).ready(new function() {
// Prepare layout options.
var options = {
autoResize: true, // 当浏览器窗口改变大小时自动更新布局
container: $(‘#main‘), // 父容器
offset: 2, // 每个网格之间的距离
itemWidth: 210// 网格之间的宽度
};
// Get a reference to your grid items.
var handler = $(‘#tiles li‘);

// Call the layout function.
handler.wookmark(options);

// Capture clicks on grid items.
handler.click(function(){
// Randomize the height of the clicked item.
var newHeight = $(‘img‘, this).height() + Math.round(Math.random()*300+30);
$(this).css(‘height‘, newHeight+‘px‘);

// Update the layout.
handler.wookmark();
});
});
</script>

</body>

图片自动排列

标签:http   this   rip   prepare   插件   plug-in   footer   log   宽度   

原文地址:http://www.cnblogs.com/xiaoyangtian/p/7040637.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!