以前項目中的列表頁須要顯示縮略圖,進而改爲9宮格。在此記錄下。css
css樣式:html
a, body, center, cite, code, dd, del, div, dl, dt, em, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hr, html, img, input, label, legend, li, mark, ol, p, section, span, strong, textarea, time, ul, var input{ margin: 0; border: 0; padding: 0; font-style: normal; color: #fff; box-sizing: border-box; -moz-box-sizing:border-box; /* Firefox */ -webkit-box-sizing:border-box; /* Safari */ } ul{ text-decoration: none; list-style-type: none; } .video_list>li{ float: left; width: 33%; font-size: 0; margin-left: 1px; margin-top: 1px; } .video_list>li>img{ width: 100%; object-fit: cover; }
html結構:jquery
<ul class="video_list"> <li><img src="http://img.jspp.cn/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li> <li><img src="http://img.jspp.cn/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li> <li><img src="http://img.jspp.cn/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li> <li><img src="http://img.jspp.cn/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li> <li><img src="http://img.jspp.cn/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li> <li><img src="http://img.jspp.cn/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li> <li><img src="http://img.jspp.cn/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li> <li><img src="http://img.jspp.cn/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li> <li><img src="http://img.jspp.cn/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li> </ul>
僅僅是拿到點擊的哪一張圖片的下表;爲的點擊後跳轉指定頁面;web
jquery代碼:jsp
$(function () { $('.video_list').on('click','li',function () { alert($(this).index()+1); }) })
僅此記錄下來,爲了之後能夠翻來看看。同時也但願對你們有用。ide