HTML5实践-使用css装饰图片画廊的代码分享(二)


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<ul class="gallery tape">

    <li>

        <figure>

            <img src="http://webdesignerwall.com/wp-content/uploads/2012/09/sample-4.jpg" alt="image">

            <figcaption>Image Caption</figcaption>

        </figure>

    </li>

    <li>

        <figure>

            <img src="http://webdesignerwall.com/wp-content/uploads/2012/09/sample-5.jpg" alt="image">

            <figcaption>Image Caption</figcaption>

        </figure>

    </li>

    <li>

        <figure> <img src="http://webdesignerwall.com/wp-content/uploads/2012/09/sample-6.jpg" alt="image">

            <figcaption>Image Caption</figcaption>

        </figure>

    </li></ul>

  CSS

  css中我添加了两个:before,一个针对<figure>元素,另一个针对<li>元素。遮罩图片overlay.png被用在了figure:before上面,胶带图片用在了 a:before上面。


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

.tape li {

    width: 170px;

    padding: 5px;

    margin: 15px 10px;

    border: solid 1px #cac09f;

    background: #fdf8e4;

    text-align: center;

    box-shadow: inset 0 1px rgba(255,255,255,.8), 0 1px 2px rgba(0,0,0,.2);

}.tape figure {

    position: relative;

    margin: 0;

}.tape a:before {

    position: absolute;

    content: ' ';

    top: 0;

    left: 0;

    width: 100%;

    height: 100%;

    background: url(http://webdesignerwall.com/wp-content/uploads/2012/09/overlay.png) no-repeat;

}.tape figcaption {

    font: 100%/120% Handlee, Arial, Helvetica, sans-serif;

    color: #787568;

}.tape a:before {

    position: absolute;

    z-index: 2;

    content: ' ';

    top: -12px;

    left: 50%;

    width: 115px;

    height: 32px;

    margin-left: -57px;

    background: url(http://webdesignerwall.com/wp-content/uploads/2012/09/tape.png) no-repeat;

}

  CSS3 Transform

  在这个例子中,我使用了软木纹饰背景,并使用transform属性转变图片。

1

2

3

4

5

6

7

8

.transform {

    background: url(http://webdesignerwall.com/wp-content/uploads/2012/09/cork-bg.png);

    padding: 25px;

    border-radius: 10px;

    box-shadow: inset 0 1px 5px rgba(0,0,0,.4);

}.transform li {

    border: none;

}

  Nth-of-Type

  为了让图片旋转的更随机和自然,我使用nth-of-type去筛选图片,为不同图片设置不同的旋转角度。


1

2

3

4

5

6

7

.transform li:nth-of-type(4n+1) {

    -webkit-transform: rotate(2deg);

}.transform li:nth-of-type(2n) {

    -webkit-transform: rotate(-1deg);

}.transform li:nth-of-type(4n+3) {

    -webkit-transform: rotate(2deg);

}

  好了,今天的教程到此为止。

以上就是HTML5实践-使用css装饰图片画廊的代码分享(二)的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

怎样用h5计算手机摇动次数

css改变滚动条样式

css实现页面底部固定的方法介绍(附代码)

网页设计中,css一般是指?

css如何实现表单label的两端对齐(代码示例)

通过HTML5的getusermedia实现拍照功能示例

使用css样式制作单选框

css如何改变鼠标样式

css如何实现表单验证功能

css如何让块无间隙

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




打赏

取消

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

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

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

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

评论

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