缩略图(一)
缩略图在网站中最常用的地方就是产品列表页面,一行显示几张图片,有的在图片底下(左侧或右侧)带有标题、描述等信息。Bootstrap框架将这一部独立成一个模块组件。并通过“thumbnail”样式配合bootstrap的网格系统来实现。可以将产品列表页变得更好看。
源码文件:
☑ LESS版本:对应文件thumbnails.less
☑ Sass版本:对应文件_thumbnails.scss
☑ 编译后版本:bootstrap.css文件第4402行~第4426行
使用方法:
通过“thumbnail”样式配合bootstrap的网格系统来实现。
前面也说过了,缩略图的实现是配合网格系统一起使用,假设我们一个产品列表,如下图所示:
555
先来看结构:
上面的结构表示的是在宽屏幕(可视区域大于768px)的时候,一行显示四个缩略图: 在窄屏(可视区域小于768px)的时候,一行只显示两个缩略图: 实现原理: 布局实现的主要是依靠于Bootstrap框架的网格系统,而缩略图对应的样式代码: /bootstrap.css文件第4402行~第4426行/ .thumbnail { display: block; padding: 4px; margin-bottom: 20px; line-height: 1.42857143; background-color: #fff; border: 1px solid #ddd; border-radius: 4px; -webkit-transition: all .2s ease-in-out; transition: all .2s ease-in-out; } .thumbnail > img, .thumbnail a > img { margin-right: auto; margin-left: auto; } a.thumbnail:hover, a.thumbnail:focus, a.thumbnail.active { border-color: #428bca; } .thumbnail .caption { padding: 9px; color: #333; } 在仅有缩略图的基础上,添加了一个div名为“caption“的容器,在这个容器中放置其他内容,比如说标题,文本描述,按钮等:有疑问加站长微信联系(非本文作者)
![](https://static.golangjob.cn/static/img/footer.png?imageView2/2/w/280)