• 【01】CSS制作的图形


    【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:20px000;
    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:50px0;
    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:50px50px00;
    123. border-radius:50px50px00;
    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:0100%;
    130. -moz-transform-origin:0100%;
    131. -ms-transform-origin:0100%;
    132. -o-transform-origin:0100%;
    133. transform-origin:0100%;
    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:50px50px050px;
    163. border-radius:50px50px050px;
    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:50px50px50px0;
    174. border-radius:50px50px50px0;
    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:2px2px50px2px;
    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>
     
     





     

  • 相关阅读:
    20.12.21 leetcode316
    20.12.18 leetcode389
    NOIP2017退役记
    DNA序列 LOJ NOIP模拟赛 D1T1 字符串哈希
    解药还是毒药 codevs2594 状态压缩 BFS
    换教室 vijos2005 NOIP2016 D1T3 期望DP 图论最短路(雾)
    都市大飙车 UESTC 1652 概率DP
    添加括号 vijos1038 动态规划 区间DP
    一道神奇的并查集
    还有一道神奇的暴力(正解是要旋转坐标轴的)
  • 原文地址:https://www.cnblogs.com/moyuling/p/4971108.html
Copyright © 2020-2023  润新知