纯CSS如何实现3D书本效果?(代码示例)


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

本篇文章给大家通过代码示例介绍CSS实现3D书本效果,代码简单易懂。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

话不多说,先来看一下效果图

在这里插入图片描述

源代码如下

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

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

<style>

    *{

        margin: 0;

        padding: 0;

    }

    body{

        display: flex;

        align-items: center;

        justify-content: center;

        width: 100%;

        min-height: 100vh;

        background: #333333;

        background-size: cover;

    }

    .book{

        width: 400px;

        height: 600px;

        position: relative;

        background-color: #ffffff;

        transform: rotate(-37.5deg) skewX(10deg);

        box-shadow: -35px 35px 50px rgb(0,0, 0, 1);

        transition: 0.5s;

        /* 光标呈现为指示链接的指针(一只手) */

        cursor: pointer;

    }

    .book:hover{

        /* rotate 定义 2D 旋转,在参数中规定角度。 */

        /* skewX()定义沿着 X 轴的 2D 倾斜转换。

            translate(x,y) 定义 2D 转换。

          */

        transform: rotate(-37.5deg) skewX(10deg) translate(20px,-20px);

        /* box-shadow 向框添加一个或多个阴影 */

        box-shadow: -50px 50px 100px rgba(0,0,0,1);

    }

    /* 伪元素必须配合content进行使用,至少为空 */

    .book::before{

        content:'';

        height:100%;

        width:30px;

        background: red;

        position: absolute;

        top: 0;

        left: 0;

        transform: skewY(-45deg) translate(-30px,-15px);

        box-shadow: inset -10px 0 20px raba(0,0,0,0,2);

        background: url(cofe.jpg);

    }

    .book::after{

            content: '';

            height: 30px;

            width: 100%;

            background: #fff;

            position: absolute;

            bottom: 0;

            left: 0;

            transform: skewX(-45deg) translate(15px,30px);

            background: url(cofe.jpg);

  

    }

    .book h2{

        position: absolute;

        bottom: 100px;

        left: 10px;

        font-size: 5em;

        line-height: 1em;

        color: rgb(110, 21, 21);

    }

    .book h2 span{

        background-image: url(cofe.jpg);

        background-attachment: fixed;

        -webkit-background-clip: text;

        -webkit-text-fill-color: transparent;

    }

    .book .write i{

        font-weight: 700;

    }

    .book .cover{

        position: absolute;

        top: 0;

        left: 0;

        width: 100%;

        height: 70%;

        background-image: url(cofe.jpg);

        background-size: cover;

    }

  

  

</style>

  

  

<body>

    <div>

        <div></div>

        <h2>Book <span>javascript</span></h2>

        <span> written by fans</span>

    </div>

</body>

</html>

ok,效果还是相对可以得哦,如果喜欢得话,请点个赞吧!!!

相关教程推荐:CSS视频教程

更多炫酷CSS3、html5、javascript特效代码,尽在:js特效大全!

以上就是纯CSS如何实现3D书本效果?(代码示例)的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

css操作控件实现disable效果

css link与import的区别是什么

怎么创建css文件

css中的类选择器有什么用

css里面怎么注释

css的优势是什么

邮件不支持css怎么办

如何清除css缓存

css中tag是什么意思

css鼠标样式

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




打赏

取消

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

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

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

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

评论

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