css实现简单瀑布流以及存在的问题
2017-10-10 10:04
525 查看
最近有个页面布局需要改为瀑布流的形式,就只单纯显示并没做上拉加载更多的。
先给张效果图,不是很好只是有瀑布流的效果而已:
css内容:
1.利用 column-count:属性来分多少列。
2.把所有内容往子盒子里填充就好。它会自动排列,这里每个盒子的高度是我自己写死的,你们也可以用random产生随机高度,但效果会每次进页面瀑布流布局都不一样。或者你可以获取图片的高度属性(这个有哪位大神能教下)。
我这里每个子盒子的背景以及图标、文字都是单独的,所以要拼装。把共同属性抽出来单独一个class样式。
写到这里会出现一个问题:列表的内容跨列,破坏整体的布局。
要解决这问题只要在每个子盒子的div样式上加上
这两个样式属性一般都没问题。
http://blog.csdn.net/luviawu/article/details/70313096 论别人家的实现。
先给张效果图,不是很好只是有瀑布流的效果而已:
<div id="content"> <div id="imgM" class="trip-bg" ng-click="openModal(businessTypeList[2])"> <i class="icon img trip-png"></i> <p class="light">出差申请</p> </div> <div id="imgM" class="attendance-bg" ng-click="openModal(businessTypeList[6])"> <i class="icon img attendance-png"></i> <p class="light">考勤补登记</p> </div> <!-- 下面省略多个div盒子 --> </div>
css内容:
#content{ -webkit-column-count: 3; -moz-column-count: 3; column-count: 3; -moz-column-gap:5px; -webkit-column-gap:5px; column-gap:5px; padding: 10px; } .img{ background-size:100% 100%; display: inline-block; position: relative; height: 50px; width: 50px; margin: 10px 0px 0px 0px; } #imgM { position: relative; padding: 5px; text-align: center; margin: 5px; border: solid 2px #eeeeee; border-radius: 4px; cursor: pointer; width: 100%; break-inside:avoid; box-sizing: border-box; } #imgM p{ position: relative; display: inline-block; width: 100%; text-align: center; /*margin: 0px 20px 0px 20px;*/ font-size:medium; } .trip-bg{ background: url(../img/operationCenter/trip_bg.jpg) no-repeat center; height: 130px; } .trip-png{ background-image: url(../img/operationCenter/trip_img.png); } .attendance-bg{ background: url(../img/operationCenter/attendance_bg.jpg) no-repeat center; height: 130px; } .attendance-png{ background-image: url(../img/operationCenter/attendance_img.png); }
1.利用 column-count:属性来分多少列。
2.把所有内容往子盒子里填充就好。它会自动排列,这里每个盒子的高度是我自己写死的,你们也可以用random产生随机高度,但效果会每次进页面瀑布流布局都不一样。或者你可以获取图片的高度属性(这个有哪位大神能教下)。
我这里每个子盒子的背景以及图标、文字都是单独的,所以要拼装。把共同属性抽出来单独一个class样式。
写到这里会出现一个问题:列表的内容跨列,破坏整体的布局。
要解决这问题只要在每个子盒子的div样式上加上
break-inside:avoid; box-sizing: border-box;
这两个样式属性一般都没问题。
http://blog.csdn.net/luviawu/article/details/70313096 论别人家的实现。
相关文章推荐
- Android批量加载网络图片存在的问题及简单实现
- csshover.htc 以及简单使用方法(解决IE6下 :hover 在其他标签下无效问题)
- c++22、string虚假泄露问题,以及简单string类实现
- RecyclerView的简单使用以及实现瀑布流效果
- Android中Recyclerview使用13----实现瀑布流遇到的各种问题(item移动,加载更多图片闪烁,以及定制各种类型Header和Footer)
- C++ — 智能指针的简单实现以及循环引用问题
- MyBatis学习笔记-01.MyBatis简单入门_实现MyBatis对数据库的查询操作以及IllegalArgumentException异常问题
- tomcat服务器下使用nginx实现最简单的动静分离--解决css、js不加载的问题
- Java发送邮件简单实现以及问题的解决
- html,css,js实现老虎机游戏以及出现的问题
- MyBatis学习笔记-04.MyBatis实现简单的增删改查以及事务的问题
- C++ — 智能指针的简单实现以及循环引用问题
- 可变参数问题以及实现简单的myprintf
- 使用div+css制作简单导航 以及要注意问题
- RecyclerView实现瀑布流遇到的各种问题(item移动,加载更多图片闪烁,以及定制各种类型Header和Footer)
- 关于jsonp实现跨域访问,以及存在的安全问题
- C++ 智能指针——简单实现以及循环引用问题
- String 类的实现(1)浅拷贝存在的问题以及深拷贝实现
- 问题:关于贴友的一个书本页面简单布局(html+css)的实现
- tomcat服务器下使用nginx实现最简单的动静分离--解决css、js不加载的问题