【css3技巧(二)】之图片列表瀑布流(超简单css3实现瀑布流)

小程序列表图片瀑布流

样板是小程序。其他各种框架,技术都能实现,纯css.

1、view

主要是图片的widthFix属性,宽度固定,高度自适应比例。

<view class="falls">
		<image class="img" src="https://t.7wpp.com/static/imgs/img%20(7).jpg" mode="widthFix"></image>
		<image class="img" src="https://t.7wpp.com/static/imgs/img%20(5).jpg" mode="widthFix"></image>
		<image class="img" src="https://t.7wpp.com/static/imgs/img%20(6).jpg" mode="widthFix"></image>
		<image class="img" src="https://t.7wpp.com/static/imgs/img%20(11).jpg" mode="widthFix"></image>
</view>

2、css

基于uni-app的单位,其他小程序请自己改,主要用到css3的column-count属性;
可以说是文档流,刚好结合图片的widthFix,数字代表几列。

.falls{
		width: 100%;
		-moz-column-count: 2;
		-webkit-column-count: 2;
		column-count: 2;
		.img{
			margin-bottom: 20upx;
			border-radius: 10upx;
			}
		}

3、遇到的问题

单张图片还好,上面的实现方式,放入其他内容,有可能被切割到另一列。

column分割

解决方法:在子列表中加入,height:100%;overflow:auto;

.list{
		height:100%;
		overflow: auto;
		border-radius:20upx;
		margin-bottom:30upx;
		box-shadow:0px 6upx 13upx 1upx rgba(51,51,51,0.1);
		.l_img{
			border-radius:20upx 20upx 0px 0px;
	}
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值