码迷,mamicode.com
首页 > Web开发 > 详细

【01】CSS制作的图形

时间:2015-11-17 12:53:45      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

【01】CSS制作的图形
技术分享

绘制五角星:

技术分享
通过border绘制三角形。然后通过transfrom来旋转35度。
绘制对称的图形,最后绘制顶部的三角形即可。

元素本身,加上:before和:after。


绘制爱心:

技术分享



矩形,加圆角,加旋转。

绘制倒8:


技术分享


显然是:三个角是圆角。然后旋转。


绘制开心笑:
技术分享

四个角圆角。然后右border-right为透明即可。


代码如下:

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>测试</title>
  6. <style type="text/css">
  7. * {
  8. margin: 0;
  9. padding: 0;
  10. border: 0;
  11. }
  12. .wrap {
  13. position: absolute;
  14. }
  15. .arrow {
  16. position: relative;
  17. width: 0;
  18. height: 0;
  19. border-top: 9px solid transparent;
  20. border-right: 9px solid #000;
  21. -webkit-transform: rotate(10deg);
  22. -moz-transform: rotate(10deg);
  23. -ms-transform: rotate(10deg);
  24. -o-transform: rotate(10deg);
  25. }
  26. .arrow:after {
  27. content: "";
  28. position: absolute;
  29. border: 0 solid transparent;
  30. border-top: 3px solid #000;
  31. border-radius: 20px 0 0 0;
  32. top: -12px;
  33. left: -9px;
  34. width: 12px;
  35. height: 12px;
  36. -webkit-transform: rotate(45deg);
  37. -moz-transform: rotate(45deg);
  38. -ms-transform: rotate(45deg);
  39. -o-transform: rotate(45deg);
  40. }
  41. .star-six {
  42. width: 0;
  43. height: 0;
  44. border-left: 50px solid transparent;
  45. border-right: 50px solid transparent;
  46. border-bottom: 100px solid #99CC33;
  47. position: relative;
  48. }
  49. .star-six:after {
  50. width: 0;
  51. height: 0;
  52. border-left: 50px solid transparent;
  53. border-right: 50px solid transparent;
  54. border-top: 100px solid #99CC33;
  55. position: absolute;
  56. content: "";
  57. top: 30px;
  58. left: -50px;
  59. }
  60. .star-five {
  61. margin: 50px 0;
  62. position: relative;
  63. display: block;
  64. color: #0066CC;
  65. width: 0px;
  66. height: 0px;
  67. border-right: 100px solid transparent;
  68. border-bottom: 70px solid #0066CC;
  69. border-left: 100px solid transparent;
  70. -moz-transform: rotate(35deg);
  71. -webkit-transform: rotate(35deg);
  72. -ms-transform: rotate(35deg);
  73. -o-transform: rotate(35deg);
  74. }
  75. .star-five:before {
  76. border-bottom: 80px solid #0066CC;
  77. border-left: 30px solid transparent;
  78. border-right: 30px solid transparent;
  79. position: absolute;
  80. height: 0;
  81. width: 0;
  82. top: -45px;
  83. left: -65px;
  84. display: block;
  85. content: ‘‘;
  86. -webkit-transform: rotate(-35deg);
  87. -moz-transform: rotate(-35deg);
  88. -ms-transform: rotate(-35deg);
  89. -o-transform: rotate(-35deg);
  90. }
  91. .star-five:after {
  92. position: absolute;
  93. display: block;
  94. color: #0066CC;
  95. top: 3px;
  96. left: -105px;
  97. width: 0px;
  98. height: 0px;
  99. border-right: 100px solid transparent;
  100. border-bottom: 70px solid #0066CC;
  101. border-left: 100px solid transparent;
  102. -webkit-transform: rotate(-70deg);
  103. -moz-transform: rotate(-70deg);
  104. -ms-transform: rotate(-70deg);
  105. -o-transform: rotate(-70deg);
  106. content: ‘‘;
  107. }
  108. .heart {
  109. position: relative;
  110. width: 100px;
  111. height: 90px;
  112. }
  113. .heart:before,
  114. .heart:after {
  115. position: absolute;
  116. content: "";
  117. left: 50px;
  118. top: 0;
  119. width: 50px;
  120. height: 80px;
  121. background: red;
  122. -moz-border-radius: 50px 50px 0 0;
  123. border-radius: 50px 50px 0 0;
  124. -webkit-transform: rotate(-45deg);
  125. -moz-transform: rotate(-45deg);
  126. -ms-transform: rotate(-45deg);
  127. -o-transform: rotate(-45deg);
  128. transform: rotate(-45deg);
  129. -webkit-transform-origin: 0 100%;
  130. -moz-transform-origin: 0 100%;
  131. -ms-transform-origin: 0 100%;
  132. -o-transform-origin: 0 100%;
  133. transform-origin: 0 100%;
  134. }
  135. .heart:after {
  136. left: 0;
  137. -webkit-transform: rotate(45deg);
  138. -moz-transform: rotate(45deg);
  139. -ms-transform: rotate(45deg);
  140. -o-transform: rotate(45deg);
  141. transform: rotate(45deg);
  142. -webkit-transform-origin: 100% 100%;
  143. -moz-transform-origin: 100% 100%;
  144. -ms-transform-origin: 100% 100%;
  145. -o-transform-origin: 100% 100%;
  146. transform-origin: 100% 100%;
  147. }
  148. .infinity {
  149. position: relative;
  150. width: 212px;
  151. height: 100px;
  152. }
  153. .infinity:before,
  154. .infinity:after {
  155. content: "";
  156. position: absolute;
  157. top: 0;
  158. left: 0;
  159. width: 60px;
  160. height: 60px;
  161. border: 20px solid #FF33CC;
  162. -moz-border-radius: 50px 50px 0 50px;
  163. border-radius: 50px 50px 0 50px;
  164. -webkit-transform: rotate(-45deg);
  165. -moz-transform: rotate(-45deg);
  166. -ms-transform: rotate(-45deg);
  167. -o-transform: rotate(-45deg);
  168. transform: rotate(-45deg);
  169. }
  170. .infinity:after {
  171. left: auto;
  172. right: 0;
  173. -moz-border-radius: 50px 50px 50px 0;
  174. border-radius: 50px 50px 50px 0;
  175. -webkit-transform: rotate(45deg);
  176. -moz-transform: rotate(45deg);
  177. -ms-transform: rotate(45deg);
  178. -o-transform: rotate(45deg);
  179. transform: rotate(45deg);
  180. }
  181. .pacman {
  182. width: 0px;
  183. height: 0px;
  184. border-right: 60px solid transparent;
  185. border-top: 60px solid #FFCC00;
  186. border-left: 60px solid #FFCC00;
  187. border-bottom: 60px solid #FFCC00;
  188. border-top-left-radius: 60px;
  189. border-top-right-radius: 60px;
  190. border-bottom-left-radius: 60px;
  191. border-bottom-right-radius: 60px;
  192. }
  193. .yin-yang {
  194. width: 96px;
  195. height: 48px;
  196. background: #fff;
  197. border-color: #000;
  198. border-style: solid;
  199. border-width: 2px 2px 50px 2px;
  200. border-radius: 100%;
  201. position: relative;
  202. }
  203. .yin-yang:before {
  204. content: "";
  205. position: absolute;
  206. top: 50%;
  207. left: 0;
  208. background: #fff;
  209. border: 18px solid #000;
  210. border-radius: 100%;
  211. width: 12px;
  212. height: 12px;
  213. }
  214. .yin-yang:after {
  215. content: "";
  216. position: absolute;
  217. top: 50%;
  218. left: 50%;
  219. background: #000;
  220. border: 18px solid #fff;
  221. border-radius: 100%;
  222. width: 12px;
  223. height: 12px;
  224. }
  225. </style>
  226. </head>
  227. <body>
  228. <div class="wrap" style="top:30px; left:40px;">
  229. <div class="arrow"></div>
  230. </div>
  231. <div class="wrap" style="top:20px; left:100px;">
  232. <div class="star-six"></div>
  233. </div>
  234. <div class="wrap" style="top:20px; left:200px;">
  235. <div class="star-five"></div>
  236. </div>
  237. <div class="wrap" style="top:20px; left:400px;">
  238. <div class="heart"></div>
  239. </div>
  240. <div class="wrap" style="top:220px; left:100px;">
  241. <div class="infinity"></div>
  242. </div>
  243. <div class="wrap" style="top:220px; left:400px;">
  244. <div class="pacman"></div>
  245. </div>
  246. <div class="wrap" style="top:340px; left:200px;">
  247. <div class="yin-yang"></div>
  248. </div>
  249. </body>
  250. </html>






附件列表

     

    【01】CSS制作的图形

    标签:

    原文地址:http://www.cnblogs.com/moyuling/p/4971108.html

    (0)
    (0)
       
    举报
    评论 一句话评论(0
    登录后才能评论!
    © 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
    迷上了代码!