CSS3教程

当前位置: HTML5技术网 > CSS3教程 > 超可爱 纯CSS3实现的小猪、小老鼠、小牛

超可爱 纯CSS3实现的小猪、小老鼠、小牛

       利用纯CSS3绘制一些人物、动物、风景已经不是一件新鲜的事情了,主要是利用CSS3可以让直线变成任意的曲线,于是简单的矢量图形绘制对CSS3来说就小菜一碟了。今天要分享一下超级可爱的纯CSS3实现的小猪、小老鼠、小牛,先看靓照:



我们可以在这里查看这三个小动物的DEMO演示。



接下来我们逐个来贴出实现这三个小动物的CSS代码

一、小猪

HTML代码:

  1. <div id="pig">
  2.     <div id="pig_head"></div>

  3.     <div id="pig_ear_left"></div>
  4.     <div id="pig_ear_right"></div>

  5.     <div id="pig_eye_left"></div>
  6.     <div id="pig_eye_right"></div>

  7.     <div id="pig_snout"></div>
  8.     <div id="pig_snout_hole_left"></div>
  9.     <div id="pig_snout_hole_right"></div>
  10.   </div>
复制代码CSS代码:

  1. #pig{
  2.   position: absolute;
  3.   top: 40px;
  4. }

  5. #pig_head {
  6.   width: 200px;
  7.   height: 200px;
  8.   background-color: #FA8CC8;
  9.   border-radius: 100px;
  10. }

  11. #pig_ear_left {
  12.       width: 0;
  13.       height: 0;
  14.   position: absolute;
  15.   top: 15px;
  16.   left: 18px;
  17.            border-left: 20px solid transparent;
  18.       border-right: 20px solid transparent;
  19.       border-bottom: 28px solid #D30073;
  20.   -webkit-transform: rotate(-25deg);
  21. }

  22. #pig_ear_right {
  23.       width: 0;
  24.       height: 0;
  25.   position: absolute;
  26.   top: 15px;
  27.   left: 145px;
  28.       border-left: 20px solid transparent;
  29.       border-right: 20px solid transparent;
  30.       border-bottom: 28px solid #D30073;
  31.   -webkit-transform: rotate(25deg);
  32. }

  33. #pig_eye_left {
  34.   position: absolute;
  35.   top: 50px;
  36.   left: 70px;
  37.   width: 12px;
  38.   height: 20px;
  39.       background: black;
  40.       -webkit-border-radius: 50px/100px;
  41. }

  42. #pig_eye_right {
  43.   position: absolute;
  44.   top: 50px;
  45.   left: 125px;
  46.   width: 12px;
  47.   height: 20px;
  48.       background: black;
  49.       -webkit-border-radius: 50px/100px;
  50. }

  51. #pig_snout {
  52.   position: absolute;
  53.   top: 90px;
  54.   left: 62px;
  55.   width: 80px;
  56.       height: 55px;
  57.       background: #FA4EAC;
  58.       -webkit-border-radius: 90px/60px;
  59. }

  60. #pig_snout_hole_left {
  61. position: absolute;
  62.   top: 100px;
  63.   left: 80px;
  64.   width: 17px;
  65.   height: 35px;
  66.       background: #E01B87;
  67.       -webkit-border-radius: 60px/100px;
  68. }

  69. #pig_snout_hole_right {
  70. position: absolute;
  71. top: 100px;
  72. left: 111px;
  73. width: 17px;
  74. height: 35px;
  75.      background: #E01B87;
  76.      -webkit-border-radius: 60px/100px;
  77. }
复制代码二、小老鼠

HTML代码:

  1. <div id="mouse">
  2.     <div id="mouse_head"></div>

  3.     <div id="mouse_ear_left"></div>
  4.     <div id="mouse_ear_right"></div>

  5.     <div id="mouse_eye_left_outer"></div>
  6.     <div id="mouse_eye_right_outer"></div>
  7.     <div id="mouse_eye_left_inner"></div>
  8.     <div id="mouse_eye_right_inner"></div>

  9.     <div id="mouse_nose"></div>

  10.     <div id="mouse_whisker_left_1"></div>
  11.     <div id="mouse_whisker_left_2"></div>
  12.     <div id="mouse_whisker_left_3"></div>
  13.     <div id="mouse_whisker_right_1"></div>
  14.     <div id="mouse_whisker_right_2"></div>
  15.     <div id="mouse_whisker_right_3"></div>

  16.     <div id="mouse_tooth_left"></div>
  17.     <div id="mouse_tooth_right"></div>

  18.   </div>
复制代码
CSS代码:
  1. #mouse{
  2.   position: absolute;
  3.   top: 40px;
  4.   left: 280px;
  5. }

  6. #mouse_head {
  7.   width: 200px;
  8.   height: 200px;
  9.   background-color: #8F9595;
  10.   border-radius: 100px;
  11. }

  12. #mouse_ear_left {
  13.   display: inline-block;
  14.   position: relative;
  15.   top: -230px;
  16.   left: -25px;
  17.   border: 12px solid #6E6E6E;
  18.   width: 75px;
  19.       height: 75px;
  20.   background: #E5A95F;
  21.       border-radius: 50%;
  22. }

  23. #mouse_ear_right {
  24.   display: inline-block;
  25.   position: relative;
  26.   top: -230px;
  27.   left: 25px;
  28.   border: 12px solid #6E6E6E;
  29.   width: 75px;
  30.       height: 75px;
  31.   background: #E5A95F;
  32.       border-radius: 50%;
  33. }

  34. #mouse_eye_left_outer {
  35.   width: 40px;
  36.       height: 40px;
  37.   position: absolute;
  38.   top: 55px;
  39.   left: 50px;
  40.       background: white;
  41.       -webkit-border-radius: 50px;
  42.       border-radius: 50px;
  43. }

  44. #mouse_eye_right_outer {
  45.   width: 40px;
  46.       height: 40px;
  47.   position: absolute;
  48.   top: 55px;
  49.   left: 110px;
  50.       background: white;
  51.       -webkit-border-radius: 50px;
  52.       border-radius: 50px;
  53. }

  54. #mouse_eye_left_inner {
  55.   width: 15px;
  56.       height: 15px;
  57.   position: absolute;
  58.   top: 75px;
  59.   left: 63px;
  60.       background: black;
  61.       -webkit-border-radius: 50px;
  62.       border-radius: 50px;
  63. }

  64. #mouse_eye_right_inner {
  65.   width: 15px;
  66.       height: 15px;
  67.   position: absolute;
  68.   top: 75px;
  69.   left: 122px;
  70.       background: black;
  71.       -webkit-border-radius: 50px;
  72.       border-radius: 50px;
  73. }

  74. #mouse_nose {
  75.   width: 0;
  76.       height: 0;
  77.   position: absolute;
  78.   top: 110px;
  79.   left: 75px;
  80.       border-left: 25px solid transparent;
  81.       border-right: 25px solid transparent;
  82.       border-top: 50px solid #6E6E6E;
  83.   z-index: 1;
  84. }

  85. #mouse_whisker_left_1 {
  86.   width: 80px;
  87.   height: 1.5px;
  88.   border-radius: 2px;
  89.   background-color: black;
  90.   position: absolute;
  91.   top: 115px;
  92.   left: 25px;
  93.   -webkit-transform: rotate(10deg);
  94. }

  95. #mouse_whisker_left_2 {
  96.   width: 80px;
  97.   height: 1.5px;
  98.   border-radius: 2px;
  99.   background-color: black;
  100.   position: absolute;
  101.   top: 118px;
  102.   left: 28px;
  103.   }

  104. #mouse_whisker_left_3 {
  105.   width: 80px;
  106.   height: 1.5px;
  107.   border-radius: 2px;
  108.   background-color: black;
  109.   position: absolute;
  110.   top: 120px;
  111.   left: 25px;
  112.   -webkit-transform: rotate(-10deg);
  113. }

  114. #mouse_whisker_right_1 {
  115.   width: 80px;
  116.   height: 1.5px;
  117.   border-radius: 2px;
  118.   background-color: black;
  119.   position: absolute;
  120.   top: 115px;
  121.   left: 90px;
  122.   -webkit-transform: rotate(-10deg);
  123. }

  124. #mouse_whisker_right_2 {
  125.   width: 80px;
  126.   height: 1.5px;
  127.   border-radius: 2px;
  128.   background-color: black;
  129.   position: absolute;
  130.   top: 118px;
  131.   left: 90px;
  132.   }

  133. #mouse_whisker_right_3 {
  134.   width: 80px;
  135.   height: 1.5px;
  136.   border-radius: 2px;
  137.   background-color: black;
  138.   position: absolute;
  139.   top: 121px;
  140.   left: 92px;
  141.   -webkit-transform: rotate(10deg);
  142. }

  143. #mouse_tooth_left {
  144.   width: 15px;
  145.   height: 22px;
  146.   background-color: white;
  147.   position: absolute;
  148.   top: 170px;
  149.   left: 84px;
  150.   -webkit-transform: rotate(10deg);
  151. }

  152. #mouse_tooth_right {
  153.   width: 15px;
  154.   height: 22px;
  155.   background-color: white;
  156.   position: absolute;
  157.   top: 170px;
  158.   left: 102px;
  159.   -webkit-transform: rotate(-10deg);
  160. }
复制代码
三、小牛
HTML代码:
  1. <div id="cow">
  2.     <div id="cow_head"></div>
  3.     <div id="cow_horn_left"></div>
  4.     <div id="cow_horn_right"></div>

  5.     <div id="cow_eye_left_outer"></div>
  6.     <div id="cow_eye_right_outer"></div>
  7.     <div id="cow_eye_left_inner"></div>
  8.     <div id="cow_eye_right_inner"></div>

  9.     <div id="cow_snout"></div>
  10.     <div id="cow_snout_hole_left"></div>
  11.     <div id="cow_snout_hole_right"></div>

  12.    <div id="cow_mouth"></div>
  13.    <div id="cow_grass_1"></div>
  14.    <div id="cow_grass_2"></div>
  15.    <div id="cow_grass_3"></div>
  16.    <div id="cow_grass_4"></div>
  17.    <div id="cow_grass_5"></div>
  18.    <div id="cow_grass_6"></div>
  19.    <div id="cow_grass_7"></div>
  20.    <div id="cow_grass_8"></div>
  21.    <div id="cow_grass_9"></div>

  22.     <div id="cow_spot_1"></div>
  23.     <div id="cow_spot_2"></div>
  24.     <div id="cow_spot_3"></div>
  25.     <div id="cow_spot_4"></div>
  26.     <div id="cow_spot_5"></div>
  27.     <div id="cow_spot_6"></div>
  28.   </div>
复制代码CSS代码:


  1. #cow {
  2.   position: absolute;
  3.   top: 40px;
  4.   left: 550px;
  5. }

  6. #cow_head {
  7.   width: 200px;
  8.   height: 200px;
  9.   background-color: white;
  10.   border-radius: 100px;
  11. }

  12. #cow_snout {
  13.   position: absolute;
  14.   top: 90px;
  15.   left: 63px;
  16.   width: 80px;
  17.       height: 55px;
  18.       background: #E5A95F;
  19.       -webkit-border-radius: 90px/60px;
  20. }

  21. #cow_snout_hole_left {
  22. position: absolute;
  23.   top: 100px;
  24.   left: 80px;
  25.   width: 17px;
  26.   height: 35px;
  27.       background: #8C6A3F;
  28.       -webkit-border-radius: 60px/100px;
  29. }

  30. #cow_snout_hole_right {
  31. position: absolute;
  32. top: 100px;
  33. left: 111px;
  34. width: 17px;
  35. height: 35px;
  36.      background: #8C6A3F;
  37.      -webkit-border-radius: 60px/100px;
  38. }

  39. #cow_horn_left {
  40.       width: 20px;
  41.       height: 40px;
  42.   background-color: black;
  43.   border-radius: 8px 8px 2px 2px;
  44.   position: absolute;
  45.   top: 2px;
  46.   left: 18px;
  47.           -webkit-transform: rotate(-35deg);
  48. }

  49. #cow_horn_right {
  50.   width: 20px;
  51.       height: 40px;
  52.   background-color: black;
  53.   border-radius: 8px 8px 2px 2px;
  54.   position: absolute;
  55.   top: 2px;
  56.   left: 162px;
  57.           -webkit-transform: rotate(35deg);
  58. }

  59. #cow_eye_left_outer {
  60.   width: 40px;
  61.       height: 40px;
  62.   position: absolute;
  63.   top: 40px;
  64.   left: 50px;
  65.       background: white;
  66.   border: 1px solid black;
  67.       border-radius: 50px;
  68. }

  69. #cow_eye_right_outer {
  70.   width: 40px;
  71.       height: 40px;
  72.   position: absolute;
  73.   top: 40px;
  74.   left: 110px;
  75.       background: white;
  76.       border: 1px solid black;
  77.       border-radius: 50px;
  78. }

  79. #cow_eye_left_inner {
  80.   width: 15px;
  81.       height: 15px;
  82.   position: absolute;
  83.   top: 60px;
  84.   left: 63px;
  85.       background: black;
  86.       border-radius: 50px;
  87. }

  88. #cow_eye_right_inner {
  89.   width: 15px;
  90.       height: 15px;
  91.   position: absolute;
  92.   top: 60px;
  93.   left: 122px;
  94.       background: black;
  95.           border-radius: 50px;
  96. }

  97. #cow_mouth {
  98.   width: 45px;
  99.       height: 15px;
  100.   position: absolute;
  101.   top: 160px;
  102.   left: 110px;
  103.       background: white;
  104.   border: 1px solid black;
  105.           border-radius: 50px;
  106. }

  107. #cow_grass_1 {
  108.   width: 80px;
  109.   height: 10px;
  110.   position: absolute;
  111.   top: 200px;
  112.   left: 125px;
  113.   border-radius: 3px;
  114.   -webkit-transform: rotate(60deg);
  115.   background-color: #399200;
  116. }

  117. #cow_grass_2 {
  118.   width: 80px;
  119.   height: 10px;
  120.   position: absolute;
  121.   top: 200px;
  122.   left: 105px;
  123.   border-radius: 3px;
  124.   -webkit-transform: rotate(-120deg);
  125.   background-color: #399200;
  126. }

  127. #cow_grass_3 {
  128.   width: 80px;
  129.   height: 10px;
  130.   position: absolute;
  131.   top: 197px;
  132.   left: 85px;
  133.   border-radius: 3px;
  134.   -webkit-transform: rotate(90deg);
  135.   background-color: #399200;
  136. }

  137. #cow_grass_4 {
  138.   width: 80px;
  139.   height: 10px;
  140.   position: absolute;
  141.   top: 197px;
  142.   left: 100px;
  143.   border-radius: 3px;
  144.   -webkit-transform: rotate(80deg);
  145.   background-color: #399200;
  146. }

  147. #cow_grass_5 {
  148.   width: 80px;
  149.   height: 10px;
  150.   position: absolute;
  151.   top: 197px;
  152.   left: 100px;
  153.   border-radius: 3px;
  154.   -webkit-transform: rotate(100deg);
  155.   background-color: #399200;
  156. }

  157. #cow_grass_6 {
  158.   width: 80px;
  159.   height: 10px;
  160.   position: absolute;
  161.   top: 197px;
  162.   left: 70px;
  163.   border-radius: 3px;
  164.   -webkit-transform: rotate(100deg);
  165.   background-color: #399200;
  166. }

  167. #cow_grass_7 {
  168.   width: 40px;
  169.   height: 10px;
  170.   position: absolute;
  171.   top: 180px;
  172.   left: 100px;
  173.   border-radius: 3px;
  174.   -webkit-transform: rotate(100deg);
  175.   background-color: #5CBA20;
  176. }

  177. #cow_grass_8 {
  178.   width: 40px;
  179.   height: 10px;
  180.   position: absolute;
  181.   top: 180px;
  182.   left: 120px;
  183.   border-radius: 3px;
  184.   -webkit-transform: rotate(90deg);
  185.   background-color: #5CBA20;
  186. }

  187. #cow_grass_9 {
  188.   width: 40px;
  189.   height: 10px;
  190.   position: absolute;
  191.   top: 178px;
  192.   left: 120px;
  193.   border-radius: 3px;
  194.   -webkit-transform: rotate(50deg);
  195.   background-color: #5CBA20;
  196. }

  197. #cow_spot_1 {
  198.   width: 35px;
  199.       height: 35px;
  200.   position: absolute;
  201.   top: 1px;
  202.   left: 100px;
  203.       background-color: black;
  204.       border-radius: 50px;
  205. }

  206. #cow_spot_2 {
  207.   width: 20px;
  208.       height: 40px;
  209.   position: absolute;
  210.   top: -11px;
  211.   left: 95px;
  212.       background-color: black;
  213.           border-radius: 50px;
  214.   -webkit-transform: rotate(85deg);
  215. }

  216. #cow_spot_3 {
  217.   width: 50px;
  218.       height: 50px;
  219.   position: absolute;
  220.   top: 75px;
  221.   left: -1px;
  222.       background-color: black;
  223.       border-radius: 50px;
  224. }

  225. #cow_spot_4 {
  226.   width: 15px;
  227.       height: 15px;
  228.   position: absolute;
  229.   top: 81px;
  230.       background-color: black;
  231.       -webkit-border-radius: 50px;
  232.       border-radius: 50px;

  233. }

  234. #cow_spot_5 {
  235.   width: 55px;
  236.       height: 35px;
  237.   position: absolute;
  238.   top: 95px;
  239.   left: -10px;
  240.       background-color: black;
  241.       border-radius: 50px;
  242.   -webkit-transform: rotate(80deg);
  243. }

  244. #cow_spot_6 {
  245.   width: 35px;
  246.       height: 25px;
  247.   position: absolute;
  248.   top: 95px;
  249.   left: 170px;
  250.       background-color: black;
  251.           border-radius: 50px;
  252.   -webkit-transform: rotate(-80deg);
  253. }
复制代码




【超可爱 纯CSS3实现的小猪、小老鼠、小牛】相关文章

1. 超可爱 纯CSS3实现的小猪、小老鼠、小牛

2. 效果非常酷!纯CSS3实现的图片滑块程序

3. 纯CSS3实现的顶部社会化分享按钮

4. 7款纯CSS3实现的炫酷动画应用

5. 一款纯css3实现的颜色渐变按钮

6. 用纯CSS3实现图片幻灯片切换效果

7. 纯CSS3实现圆角按钮

8. Cufon, jQuery和CSS3实现的超强飞出菜单

9. CSS3实现的图片加载动画效果

10. CSS3实现的超棒3D Grid效果

本文来源:https://www.51html5.com/a1028.html

点击展开全部

﹝超可爱 纯CSS3实现的小猪、小老鼠、小牛﹞相关内容

「超可爱 纯CSS3实现的小猪、小老鼠、小牛」相关专题

其它栏目

也许您还喜欢