css3九宫格⾃适应布局
之前项⽬中的列表页需要显⽰缩略图,进⽽改成9宫格。在此记录下。
css样式:
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;
css实现三列布局
margin-top: 1px;
}
.video_list>li>img{
width: 100%;
object-fit: cover;
}
html结构:
<ul class="video_list">
<li><img src="img.jspp/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li>
<li><img src="img.jspp/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_14978372405
29.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li>
<li><img src="img.jspp/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li>
<li><img src="img.jspp/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li>
<li><img src="img.jspp/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li>
<li><img src="img.jspp/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li>
<li><img src="img.jspp/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_14978372405
29.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li>
<li><img src="img.jspp/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li>
<li><img src="img.jspp/headPortrait_1BHE2Q7A35GPbb0f13ac00001a560da1_1497837240529.jpeg?imageView2/1/w/300/h/300/q/75" alt=""></li>
</ul>
仅仅是拿到点击的哪⼀张图⽚的下表;为的点击后跳转指定页⾯;
jquery代码:
$(function () {
$('.video_list').on('click','li',function () {
alert($(this).index()+1);
})
})
仅此记录下来,为了以后可以翻来看看。同时也希望对⼤家有⽤。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论