瀑布流布局:从上往下布局方式(——)往同级元素中高度最低的元素后面排列
html:
<div class="col-responsive-5">
<a href="javascript:void(0)" class="hy_hover"><img
src="image/index_page/hy002.png"><span
class="hy_info">重庆·22岁·160CM</span></a>
</div>
<div class="col-responsive-5">
<a href="javascript:void(0)" class="hy_hover"><img
src="image/index_page/hy004.png"><span
class="hy_info">重庆 · 25岁 · 160CM</span></a>
</div>
<div class="col-responsive-5">
<a href="javascript:void(0)" class="hy_hover"><img
src="image/index_page/hy006.png"><span
class="hy_info">重庆 · 23岁 · 160CM</span></a>
</div>
<div class="col-responsive-5">
<a href="javascript:void(0)" class="hy_hover"><img
src="image/index_page/hy007.png"><span
class="hy_info">重庆 · 25岁 · 180CM</span></a>
</div>
<div class="col-responsive-5">
<a href="javascript:void(0)" class="hy_hover"><img
src="image/index_page/hy009.png"><span
class="hy_info">重庆 · 29岁 · 160CM</span></a>
</div>
<div class="col-responsive-5">
<a href="javascript:void(0)" class="hy_hover"><img
src="image/index_page/hy004.png"><span
class="hy_info">重庆 · 25岁 · 160CM</span></a>
</div>
<div class="col-responsive-5">
<a href="javascript:void(0)" class="hy_hover"><img
src="image/index_page/hy006.png"><span
class="hy_info">重庆 · 23岁 · 160CM</span></a>
</div>
<div class="col-responsive-5">
<a href="javascript:void(0)" class="hy_hover"><img
src="image/index_page/hy007.png"><span
class="hy_info">重庆 · 25岁 · 180CM</span></a>
</div>
<div class="col-responsive-5">
<a href="javascript:void(0)" class="hy_hover"><img
src="image/index_page/hy009.png"><span
class="hy_info">重庆 · 29岁 · 160CM</span></a>
</div>
css:
.col-responsive-5 {
padding: 0;
margin-bottom: 10px;
-moz-page-break-inside: avoid;
-webkit-column-break-inside: avoid;
break-inside: avoid;
overflow: hidden; // 必须,否则ios页面上,元素会有一小部分露出来
& a {
position: relative;
display: block;
overflow: hidden;
height: inherit;
}
& .hy_info {
font-size: .8rem;
position: absolute;
left: 0;
bottom: 0;
width: 11rem;
background: rgba(156, 142, 240, 0.6);
text-align: center;
height: 0;
line-height: 2rem;
border-radius: 0 0 8px 8px;
color: #fff;
width: 100%;
}
& img {
border-radius: 8px;
//height: auto;
height: inherit;
width: 100%;
display: block;
}
&:nth-child(1) {
height: 17rem;
}
&:nth-child(6) {
height: 17rem;
}
&:nth-child(2) {
height: 11rem;
}
&:nth-child(7) {
height: 21rem;
}
&:nth-child(3) {
height: 12rem;
}
&:nth-child(8) {
height: 11rem;
}
&:nth-child(4) {
height: 14rem;
}
&:nth-child(9) {
height: 16rem;
}
&:nth-child(5) {
height: 14rem;
}
&:nth-child(10) {
height: 17rem;
}
}
真正实现效果:
本文来自博客园,作者:小虾米吖~,转载请注明原文链接:https://www.cnblogs.com/LindaBlog/p/13850948.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」