web CSS3 实现3D旋转木马

<!DOCTYPE html>

2 <html lang="en">

3

4 <head>

5    <meta charset="UTF-8">

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

7    <title>Document</title>

8    <style>

9        body {

10            perspective: 1000px;

11        }

12       

13        section {

14            position: relative;

15            width: 300px;

16            height: 200px;

17            margin: 150px auto;

18            transform-style: preserve-3d;

19            animation: roate 10s linear infinite;

20        }

21       

22        section div {

23            position: absolute;

24            top: 0;

25            left: 0;

26            width: 100%;

27            height: 100%;

28            /* background: url(media/dog.jpg) no-repeat; */

29            background-color: yellow;

30        }

31       

32        section:hover {

33            animation-play-state: paused;

34        }

35       

36        @keyframes roate {

37            0% {

38                transform: rotateY(0);

39            }

40            100% {

41                transform: rotateY(360deg);

42            }

43        }

44       

45        section div:nth-child(1) {

46            transform: rotateY(0) translateZ(300px);

47            /* 可以添加自己想添加的图片 这里用背景色pink代替 下面都一样*/

48            background-color: pink;

49        }

50       

51        section div:nth-child(2) {

52            transform: rotateY(60deg) translateZ(300px);

53        }

54       

55        section div:nth-child(3) {

56            transform: rotateY(120deg) translateZ(300px);

57        }

58       

59        section div:nth-child(4) {

60            transform: rotateY(180deg) translateZ(300px);

61        }

62       

63        section div:nth-child(5) {

64            transform: rotateY(240deg) translateZ(300px);

65        }

66       

67        section div:nth-child(6) {

68            transform: rotateY(300deg) translateZ(300px);

69        }

70    </style>

71 </head>

72

73 <body>

74    <section>

75        <div></div>

76        <div></div>

77        <div></div>

78        <div></div>

79        <div></div>

80        <div></div>

81    </section>

82 </body>

83

84 </html>

龙华大道1号www.kinghill.cn/LongHuaDaDao1Hao/index.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容