详解Bootstrap中的缩略图


本文摘自PHP中文网,作者青灯夜游,侵删。

缩略图在网站中最常用的地方就是产品列表页面,一行显示几张图片,有的在图片底部(左侧或右侧)带有标题、描述等信息。Bootstrap框架将这一部独立成一个模块组件,本文将详细介绍Bootstrap缩略图

概述

  Boostrap 缩略图的默认设计仅需最少的标签就能展示带链接的图片,通过“thumbnail”样式配合bootstrap的网格系统来实现缩略图

  thumbnail中文翻译是拇指指甲,确实有些像缩略图,中间是图片,图片周围是一小圈空白,外面是边框和圆角,下面是文字

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

.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;

}

1.png

自定义内容

  在仅有缩略图的基础上,添加了一个p名为“caption“的容器,在这个容器中放置其他内容,比如标题,文本描述,按钮等

1

2

3

4

.thumbnail .caption {

  padding: 9px;

  color: #333;

}

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

<div class="container">

    <div class="row">

        <div class="col-xs-6 col-md-3">

            <a href="#" class="thumbnail">

                <img src="http://via.placeholder.com/100x100"" alt="#">

            </a>

            <div class="caption">

                <h3>小火柴的蓝色理想</h3>

                <p>好的代码像粥一样,都是用时间熬出来的</p>

                <p>

                    <a href="##" class="btn btn-primary">确认</a>

                    <a href="##" class="btn btn-info">取消</a>

                </p>

            </div>

        </div>

        <div class="col-xs-6 col-md-3">

            <a href="#" class="thumbnail">

                <img src="http://via.placeholder.com/100x100"" alt="#">

            </a>

            <div class="caption">

                <h3>小火柴的蓝色理想</h3>

                <p>好的代码像粥一样,都是用时间熬出来的</p>

                <p>

                    <a href="##" class="btn btn-primary">确认</a>

                    <a href="##" class="btn btn-info">取消</a>

                </p>

            </div>

        </div>

        <div class="col-xs-6 col-md-3">

            <a href="#" class="thumbnail">

                <img src="http://via.placeholder.com/100x100"" alt="#">

            </a>

            <div class="caption">

                <h3>小火柴的蓝色理想</h3>

                <p>好的代码像粥一样,都是用时间熬出来的</p>

                <p>

                    <a href="##" class="btn btn-primary">确认</a>

                    <a href="##" class="btn btn-info">取消</a>

                </p>

            </div>

        </div>

        <div class="col-xs-6 col-md-3">

            <a href="#" class="thumbnail">

                <img src="http://via.placeholder.com/100x100"" alt="#">

            </a>

            <div class="caption">

                <h3>小火柴的蓝色理想</h3>

                <p>好的代码像粥一样,都是用时间熬出来的</p>

                <p>

                    <a href="##" class="btn btn-primary">确认</a>

                    <a href="##" class="btn btn-info">取消</a>

                </p>

            </div>

        </div>               

    </div>

</div>

2.png

更多编程相关知识,请访问:编程视频!!

以上就是详解Bootstrap中的缩略图的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

bootstrap的栅格系统是什么?栅格系统详解

bootstrap模态框如何提交表单

bootstrap开头的那些文件怎么引入的

bootstrap中如何设置表单的宽高

spss可以做bootstrap

bootstrap能用来干什么

bootstrap里面都有什么类

bootstrap有哪几种导航

bootstrap 不支持ie怎么办

bootstrap怎么适配手机屏幕

更多相关阅读请进入《bootstrap》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...