如何使用HTML和CSS3绘制基本卡通图案的示例分享

我们孩还发多夫道知道了,就得看不我们后心回的 "家 ",不是起用看把一个有邮递区号邮差找得到的家,后心天能们后心回的 "家 ",不是空于而,风每都到小是一段时光。

纯HTML+CSS实现阿童木头像
先上最终效果图:

在里面主要用的了CSS中的几个属性:position—定位;border-radius—圆角;box-shadow—阴 影;background(linear-gradient)—渐变;transform—旋转和变换;animation —动画,技术点不是很多,主要是细心和耐心。还是直接上最终源码吧。由于考虑浏览器的CSS兼容性,代码比较多。

CSS Code复制内容到剪贴板
  1. <!DOCTYPEhtml>
  2. <htmlxmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <metacontent="text/html;charset=utf-8"http-equiv="Content-Type"/>
  5. <title>纯CSS漫画</title>
  6. <styletype="text/css">
  7. *{
  8. margin:0;
  9. padding:0;
  10. }
  11. .outer-circle{
  12. position:absolute;
  13. top:32px;
  14. left:44px;
  15. width:289px;
  16. height:289px;
  17. border:4pxsolid#75BD4F;
  18. -moz-border-radius:50%;
  19. -webkit-border-radius:50%;
  20. border-radius:50%;
  21. }
  22. .inner-circle{
  23. position:relative;
  24. width:269px;
  25. height:269px;
  26. border:10pxsolid#F5F910;
  27. -moz-border-radius:50%;
  28. -webkit-border-radius:50%;
  29. border-radius:50%;
  30. background-color:#73BF43;
  31. }
  32. .inner-circlediv{
  33. position:absolute;
  34. }
  35. .inner-circle-light{
  36. top:41px;
  37. left:35px;
  38. -moz-box-shadow:26px26px29px37px#fff;
  39. -webkit-box-shadow:26px26px29px37px#fff;
  40. box-shadow:26px26px29px37px#fff;
  41. }
  42. .header-top{
  43. top:11px;
  44. rightright:2px;
  45. z-index:100;
  46. width:180px;
  47. height:90px;
  48. -moz-border-radius:90px90px00;
  49. -webkit-border-radius:90px90px00;
  50. border-radius:90px90px00;
  51. background-color:#000;
  52. -moz-transform:rotate(32deg);
  53. -ms-transform:rotate(32deg);
  54. -o-transform:rotate(32deg);
  55. -webkit-transform:rotate(32deg);
  56. transform:rotate(32deg);
  57. }
  58. .header-left{
  59. top:-20px;
  60. left:37px;
  61. width:114px;
  62. height:228px;
  63. -moz-border-radius:228px00228px;
  64. -webkit-border-radius:228px00228px;
  65. border-radius:228px00228px;
  66. background-color:#000;
  67. -moz-transform:rotate(26deg);
  68. -ms-transform:rotate(26deg);
  69. -o-transform:rotate(26deg);
  70. -webkit-transform:rotate(26deg);
  71. transform:rotate(26deg);
  72. }
  73. .hair-left-1{
  74. top:15px;
  75. left:53px;
  76. z-index:55;
  77. width:85px;
  78. height:23px;
  79. -webkit-border-top-left-radius:30px180px;
  80. border-top-left-radius:30px180px;
  81. -webkit-border-bottom-left-radius:30px80px;
  82. border-bottom-left-radius:30px80px;
  83. background-color:#000;
  84. -moz-transform:rotate(-74deg)skew(-42deg,23deg);
  85. -ms-transform:rotate(-74deg)skew(-42deg,23deg);
  86. -o-transform:rotate(-74deg)skew(-42deg,23deg);
  87. -webkit-transform:rotate(-74deg)skew(-42deg,23deg);
  88. transform:rotate(-74deg)skew(-42deg,23deg);
  89. }
  90. .hair-left-2{
  91. top:-20px;
  92. left:99px;
  93. z-index:60;
  94. width:49px;
  95. height:37px;
  96. background-color:#000;
  97. -moz-transform:rotate(-51deg)skew(-43deg,0deg);
  98. -ms-transform:rotate(-51deg)skew(-43deg,0deg);
  99. -o-transform:rotate(-51deg)skew(-43deg,0deg);
  100. -webkit-transform:rotate(-51deg)skew(-43deg,0deg);
  101. transform:rotate(-51deg)skew(-43deg,0deg);
  102. }
  103. .hair-rightright-1{
  104. top:70px;
  105. rightright:1px;
  106. z-index:60;
  107. width:81px;
  108. height:85px;
  109. -webkit-border-top-rightright-radius:26px120px;
  110. border-top-rightright-radius:26px120px;
  111. background-color:black;
  112. -moz-transform:rotate(1deg)skew(-51deg,0deg);
  113. -ms-transform:rotate(1deg)skew(-51deg,0deg);
  114. -o-transform:rotate(1deg)skew(-51deg,0deg);
  115. -webkit-transform:rotate(1deg)skew(-51deg,0deg);
  116. transform:rotate(1deg)skew(-51deg,0deg);
  117. }
  118. .hair-rightright-2{
  119. width:60px;
  120. height:10px;
  121. -webkit-border-bottom-left-radius:100%;
  122. border-bottom-left-radius:100%;
  123. background-color:rgba(0,0,0,0.2);
  124. }
  125. .hair-light-1{
  126. top:30px;
  127. rightright:45px;
  128. z-index:105;
  129. width:57px;
  130. height:17px;
  131. -moz-border-radius:100%;
  132. -webkit-border-radius:100%;
  133. border-radius:100%;
  134. background-color:white;
  135. -moz-transform:rotate(39deg);
  136. -ms-transform:rotate(39deg);
  137. -o-transform:rotate(39deg);
  138. -webkit-transform:rotate(39deg);
  139. transform:rotate(39deg);
  140. }
  141. .hair-light-1-over{
  142. top:32px;
  143. rightright:38px;
  144. z-index:105;
  145. width:83px;
  146. height:21px;
  147. -moz-border-radius:100%;
  148. -webkit-border-radius:100%;
  149. border-radius:100%;
  150. background-color:black;
  151. -moz-transform:rotate(41deg);
  152. -ms-transform:rotate(41deg);
  153. -o-transform:rotate(41deg);
  154. -webkit-transform:rotate(41deg);
  155. transform:rotate(41deg);
  156. }
  157. .hair-light-2{
  158. top:16px;
  159. rightright:104px;
  160. z-index:105;
  161. width:4px;
  162. height:2px;
  163. -moz-border-radius:2px;
  164. -webkit-border-radius:2px;
  165. border-radius:2px;
  166. background-color:white;
  167. -moz-transform:rotate(10deg);
  168. -ms-transform:rotate(10deg);
  169. -o-transform:rotate(10deg);
  170. -webkit-transform:rotate(10deg);
  171. transform:rotate(10deg);
  172. }
  173. .ear{
  174. top:141px;
  175. rightright:36px;
  176. z-index:110;
  177. width:49px;
  178. height:48px;
  179. border:2pxsolid#000;
  180. border-bottom-width:1px;
  181. -moz-border-radius:50%;
  182. -webkit-border-radius:50%;
  183. border-radius:50%;
  184. background-color:#F6C6B0;
  185. -moz-box-shadow:-4px000#de9876inset;
  186. -webkit-box-shadow:-4px000#de9876inset;
  187. box-shadow:-4px000#de9876inset;
  188. -moz-transform:rotate(56deg)scaleY(1.4);
  189. -ms-transform:rotate(56deg)scaleY(1.4);
  190. -o-transform:rotate(56deg)scaleY(1.4);
  191. -webkit-transform:rotate(56deg)scaleY(1.4);
  192. transform:rotate(56deg)scaleY(1.4);
  193. }
  194. .ear-inner-1{
  195. top:22px;
  196. left:22px;
  197. z-index:70;
  198. width:9px;
  199. height:5px;
  200. border-top:1pxsolid#110b00;
  201. -moz-border-radius:50%;
  202. -webkit-border-radius:50%;
  203. border-radius:50%;
  204. -moz-transform:rotate(-6deg);
  205. -ms-transform:rotate(-6deg);
  206. -o-transform:rotate(-6deg);
  207. -webkit-transform:rotate(-6deg);
  208. transform:rotate(-6deg);
  209. }
  210. .ear-inner-2{
  211. top:19px;
  212. left:18px;
  213. width:14px;
  214. height:7px;
  215. border-top:2pxsolid#110b00;
  216. -moz-border-radius:50%;
  217. -webkit-border-radius:50%;
  218. border-radius:50%;
  219. -moz-box-shadow:0px2px00#de9876inset;
  220. -webkit-box-shadow:0px2px00#de9876inset;
  221. box-shadow:0px2px00#de9876inset;
  222. -moz-transform:rotate(-91deg);
  223. -ms-transform:rotate(-91deg);
  224. -o-transform:rotate(-91deg);
  225. -webkit-transform:rotate(-91deg);
  226. transform:rotate(-91deg);
  227. }
  228. .ear-light{
  229. top:21px;
  230. rightright:34px;
  231. z-index:105;
  232. width:17px;
  233. height:6px;
  234. -moz-border-radius:100%;
  235. -webkit-border-radius:100%;
  236. border-radius:100%;
  237. background-color:#FFF;
  238. -moz-transform:rotate(89deg);
  239. -ms-transform:rotate(89deg);
  240. -o-transform:rotate(89deg);
  241. -webkit-transform:rotate(89deg);
  242. transform:rotate(89deg);
  243. }
  244. .ear-over{
  245. bottombottom:-44px;
  246. left:-33px;
  247. z-index:55;
  248. width:69px;
  249. height:59px;
  250. -moz-border-radius:50%;
  251. -webkit-border-radius:50%;
  252. border-radius:50%;
  253. background-color:#f6c6b0;
  254. -moz-transform:rotate(26deg);
  255. -ms-transform:rotate(26deg);
  256. -o-transform:rotate(26deg);
  257. -webkit-transform:rotate(26deg);
  258. transform:rotate(26deg);
  259. }
  260. .face-main{
  261. top:30px;
  262. left:35px;
  263. z-index:50;
  264. width:180px;
  265. height:188px;
  266. -moz-border-radius:90px;
  267. -webkit-border-radius:90px;
  268. border-radius:90px;
  269. background-color:#F6C6B0;
  270. -moz-box-shadow:3px-3px00#fffinset;
  271. -webkit-box-shadow:3px-3px00#fffinset;
  272. box-shadow:3px-3px00#fffinset;
  273. }
  274. .face-top{
  275. top:61px;
  276. rightright:75px;
  277. z-index:105;
  278. width:111px;
  279. height:46px;
  280. -moz-border-radius:50%50%26px0;
  281. -webkit-border-radius:50%50%26px0;
  282. border-radius:50%50%26px0;
  283. background-color:#f6c6b0;
  284. -moz-transform:rotate(37deg);
  285. -ms-transform:rotate(37deg);
  286. -o-transform:rotate(37deg);
  287. -webkit-transform:rotate(37deg);
  288. transform:rotate(37deg);
  289. }
  290. .face-rightright-1{
  291. top:115px;
  292. rightright:71px;
  293. z-index:105;
  294. width:68px;
  295. height:62px;
  296. -moz-border-radius:100%00;
  297. -webkit-border-radius:100%00;
  298. border-radius:100%00;
  299. background-color:#f6c6b0;
  300. -moz-transform:rotate(99deg);
  301. -ms-transform:rotate(99deg);
  302. -o-transform:rotate(99deg);
  303. -webkit-transform:rotate(99deg);
  304. transform:rotate(99deg);
  305. }
  306. .face-bottombottom-1{
  307. bottombottom:42px;
  308. left:45px;
  309. z-index:40;
  310. width:72px;
  311. height:52px;
  312. -webkit-border-bottom-left-radius:70px40px;
  313. -webkit-border-top-left-radius:14px11px;
  314. border-top-left-radius:14px11px;
  315. border-bottom-left-radius:70px40px;
  316. background-color:#000;
  317. }
  318. .face-bottombottom-1-over{
  319. bottombottom:45px;
  320. left:48px;
  321. z-index:55;
  322. width:69px;
  323. height:47px;
  324. -webkit-border-bottom-left-radius:70px40px;
  325. -webkit-border-top-left-radius:14px11px;
  326. border-top-left-radius:14px11px;
  327. border-bottom-left-radius:70px40px;
  328. background-color:#f6c6b0;
  329. -moz-box-shadow:3px0px00#fffinset;
  330. -webkit-box-shadow:3px0px00#fffinset;
  331. box-shadow:3px0px00#fffinset;
  332. }
  333. .face-bottombottom-2{
  334. rightright:97px;
  335. bottombottom:44px;
  336. z-index:55;
  337. width:43px;
  338. height:31px;
  339. -webkit-border-bottom-rightright-radius:70px40px;
  340. border-bottom-rightright-radius:70px40px;
  341. background-color:#000;
  342. -moz-transform:rotate(-4deg)skew(-49deg,0deg);
  343. -ms-transform:rotate(-4deg)skew(-49deg,0deg);
  344. -o-transform:rotate(-4deg)skew(-49deg,0deg);
  345. -webkit-transform:rotate(-4deg)skew(-49deg,0deg);
  346. transform:rotate(-4deg)skew(-49deg,0deg);
  347. }
  348. .face-bottombottom-2-over{
  349. rightright:99px;
  350. bottombottom:46px;
  351. z-index:56;
  352. width:43px;
  353. height:31px;
  354. -webkit-border-bottom-rightright-radius:70px40px;
  355. border-bottom-rightright-radius:70px40px;
  356. background-color:#f6c6b0;
  357. -moz-box-shadow:-6px2px00#de9876inset;
  358. -webkit-box-shadow:-6px2px00#de9876inset;
  359. box-shadow:-6px2px00#de9876inset;
  360. -moz-transform:rotate(-3deg)skew(-49deg,0deg);
  361. -ms-transform:rotate(-3deg)skew(-49deg,0deg);
  362. -o-transform:rotate(-3deg)skew(-49deg,0deg);
  363. -webkit-transform:rotate(-3deg)skew(-49deg,0deg);
  364. transform:rotate(-3deg)skew(-49deg,0deg);
  365. }
  366. .face-light-1{
  367. rightright:127px;
  368. bottombottom:95px;
  369. z-index:150;
  370. width:6px;
  371. height:6px;
  372. -moz-border-radius:50%;
  373. -webkit-border-radius:50%;
  374. border-radius:50%;
  375. background-color:#fff;
  376. }
  377. .face-light-2{
  378. bottombottom:82px;
  379. left:58px;
  380. z-index:150;
  381. width:4px;
  382. height:4px;
  383. -moz-border-radius:50%;
  384. -webkit-border-radius:50%;
  385. border-radius:50%;
  386. background-color:#fff;
  387. }
  388. .chin{
  389. bottombottom:39px;
  390. left:111px;
  391. z-index:70;
  392. width:11px;
  393. height:12px;
  394. border:2pxsolid#000;
  395. border-top-color:#f6c6b0;
  396. border-left-color:#f6c6b0;
  397. -webkit-border-bottom-rightright-radius:6px;
  398. border-bottom-rightright-radius:6px;
  399. background-color:#f6c6b0;
  400. -moz-transform:rotate(34deg)skew(-9deg,0deg);
  401. -ms-transform:rotate(34deg)skew(-9deg,0deg);
  402. -o-transform:rotate(34deg)skew(-9deg,0deg);
  403. -webkit-transform:rotate(34deg)skew(-9deg,0deg);
  404. transform:rotate(34deg)skew(-9deg,0deg);
  405. }
  406. .eye-rightright{
  407. top:97px;
  408. left:103px;
  409. z-index:110;
  410. width:39px;
  411. height:67px;
  412. border:1pxsolid#000;
  413. border-top-width:2px;
  414. -moz-border-radius:24px43px34px28px/34px71px34px81px;
  415. -webkit-border-radius:24px43px34px28px/34px71px34px81px;
  416. border-radius:24px43px34px28px/34px71px34px81px;
  417. background-color:#F8FAF7;
  418. -moz-box-shadow:0px5px00#d5d9e2inset;
  419. -webkit-box-shadow:0px5px00#d5d9e2inset;
  420. box-shadow:0px5px00#d5d9e2inset;
  421. }
  422. .eye-rightright-inner{
  423. rightright:0;
  424. bottombottom:3px;
  425. z-index:115;
  426. width:30px;
  427. height:52px;
  428. -moz-border-radius:32px43px28px48px/47px55px45px75px;
  429. -webkit-border-radius:32px43px28px48px/47px55px45px75px;
  430. border-radius:32px43px28px48px/47px55px45px75px;
  431. background-color:#000;
  432. }
  433. .eye-rightright-light1{
  434. top:19px;
  435. rightright:0;
  436. z-index:120;
  437. width:19px;
  438. height:10px;
  439. -moz-border-radius:100%;
  440. -webkit-border-radius:100%;
  441. border-radius:100%;
  442. background-color:#FFF;
  443. -moz-animation:eye-flash0.2slinear0.1sinfinitenormal;
  444. -o-animation:eye-flash0.2slinear0.1sinfinitenormal;
  445. -webkit-animation:eye-flash0.2slinear0.1sinfinitenormal;
  446. -moz-transform:rotate(41deg);
  447. -ms-transform:rotate(41deg);
  448. -o-transform:rotate(41deg);
  449. -webkit-transform:rotate(41deg);
  450. transform:rotate(41deg);
  451. animation:eye-flash0.2slinear0.1sinfinitenormal;
  452. }
  453. @-webkit-keyframeseye-flash{
  454. 0%{
  455. top:19px;
  456. }
  457. 100%{
  458. top:21px;
  459. }
  460. }
  461. @-moz-keyframeseye-flash{
  462. 0%{
  463. top:19px;
  464. }
  465. 100%{
  466. top:20px;
  467. }
  468. }
  469. @-ms-keyframeseye-flash{
  470. 0%{
  471. top:19px;
  472. }
  473. 100%{
  474. top:20px;
  475. }
  476. }
  477. @keyframeseye-flash{
  478. 0%{
  479. top:19px;
  480. }
  481. 100%{
  482. top:20px;
  483. }
  484. }
  485. .eye-rightright-light2{
  486. bottombottom:8px;
  487. left:9px;
  488. z-index:120;
  489. width:14px;
  490. height:7px;
  491. -webkit-border-bottom-rightright-radius:100%;
  492. border-bottom-rightright-radius:100%;
  493. background-color:#FFF;
  494. -moz-transform:rotate(-39deg);
  495. -ms-transform:rotate(-39deg);
  496. -o-transform:rotate(-39deg);
  497. -webkit-transform:rotate(-39deg);
  498. transform:rotate(-39deg);
  499. }
  500. .eye-rightright-eyelash1{
  501. top:9px;
  502. left:-3px;
  503. width:2px;
  504. height:4px;
  505. background-color:#000;
  506. -moz-transform:rotate(-54deg);
  507. -ms-transform:rotate(-54deg);
  508. -o-transform:rotate(-54deg);
  509. -webkit-transform:rotate(-54deg);
  510. transform:rotate(-54deg);
  511. }
  512. .eye-rightright-eyelash2{
  513. top:1px;
  514. left:1px;
  515. width:2px;
  516. height:5px;
  517. background-color:#000;
  518. -moz-transform:rotate(-33deg);
  519. -ms-transform:rotate(-33deg);
  520. -o-transform:rotate(-33deg);
  521. -webkit-transform:rotate(-33deg);
  522. transform:rotate(-33deg);
  523. }
  524. .eye-rightright-eyelash3{
  525. top:-8px;
  526. left:8px;
  527. width:2px;
  528. height:7px;
  529. background-color:#000;
  530. -moz-transform:rotate(-21deg);
  531. -ms-transform:rotate(-21deg);
  532. -o-transform:rotate(-21deg);
  533. -webkit-transform:rotate(-21deg);
  534. transform:rotate(-21deg);
  535. }
  536. .eye-rightright-eyelash4{
  537. top:-6px;
  538. left:21px;
  539. width:2px;
  540. height:6px;
  541. background-color:#000;
  542. -moz-transform:rotate(11deg);
  543. -ms-transform:rotate(11deg);
  544. -o-transform:rotate(11deg);
  545. -webkit-transform:rotate(11deg);
  546. transform:rotate(11deg);
  547. }
  548. .eye-rightright-eyelash5{
  549. top:1px;
  550. rightright:8px;
  551. width:2px;
  552. height:6px;
  553. background-color:#000;
  554. -moz-transform:rotate(14deg);
  555. -ms-transform:rotate(14deg);
  556. -o-transform:rotate(14deg);
  557. -webkit-transform:rotate(14deg);
  558. transform:rotate(14deg);
  559. }
  560. .eye-left{
  561. top:114px;
  562. left:45px;
  563. z-index:110;
  564. width:19px;
  565. height:63px;
  566. border:1pxsolid#000;
  567. border-top-width:2px;
  568. -moz-border-radius:29px28px33px/97px111px40px90px;
  569. -webkit-border-radius:29px28px33px/97px111px40px90px;
  570. border-radius:29px28px33px/97px111px40px90px;
  571. background-color:#F8FAF7;
  572. -moz-box-shadow:0px6px00#d5d9e2inset;
  573. -webkit-box-shadow:0px6px00#d5d9e2inset;
  574. box-shadow:0px6px00#d5d9e2inset;
  575. -moz-transform:rotate(-9deg);
  576. -ms-transform:rotate(-9deg);
  577. -o-transform:rotate(-9deg);
  578. -webkit-transform:rotate(-9deg);
  579. transform:rotate(-9deg);
  580. }
  581. .eye-left-inner{
  582. rightright:0;
  583. bottombottom:1px;
  584. z-index:115;
  585. width:15px;
  586. height:46px;
  587. -moz-border-radius:49px44px29px58px/143px83px45px122px;
  588. -webkit-border-radius:49px44px29px58px/143px83px45px122px;
  589. border-radius:49px44px29px58px/143px83px45px122px;
  590. background-color:#000;
  591. }
  592. .eye-left-light1{
  593. top:19px;
  594. rightright:1px;
  595. z-index:120;
  596. width:7px;
  597. height:18px;
  598. -moz-border-radius:100%;
  599. -webkit-border-radius:100%;
  600. border-radius:100%;
  601. background-color:#FFF;
  602. -moz-animation:eye-flash0.2slinear0.1sinfinitenormal;
  603. -o-animation:eye-flash0.2slinear0.1sinfinitenormal;
  604. -webkit-animation:eye-flash0.2slinear0.1sinfinitenormal;
  605. -moz-transform:rotate(-9deg);
  606. -ms-transform:rotate(-9deg);
  607. -o-transform:rotate(-9deg);
  608. -webkit-transform:rotate(-9deg);
  609. transform:rotate(-9deg);
  610. animation:eye-flash0.2slinear0.1sinfinitenormal;
  611. }
  612. .eye-left-light2{
  613. bottombottom:6px;
  614. left:4px;
  615. z-index:120;
  616. width:11px;
  617. height:4px;
  618. -webkit-border-bottom-rightright-radius:100%;
  619. border-bottom-rightright-radius:100%;
  620. background-color:#FFF;
  621. -moz-transform:rotate(-45deg);
  622. -ms-transform:rotate(-45deg);
  623. -o-transform:rotate(-45deg);
  624. -webkit-transform:rotate(-45deg);
  625. transform:rotate(-45deg);
  626. }
  627. .eye-left-eyelash1{
  628. top:7px;
  629. left:-1px;
  630. width:2px;
  631. height:4px;
  632. background-color:#000;
  633. -moz-transform:rotate(-49deg);
  634. -ms-transform:rotate(-49deg);
  635. -o-transform:rotate(-49deg);
  636. -webkit-transform:rotate(-49deg);
  637. transform:rotate(-49deg);
  638. }
  639. .eye-left-eyelash2{
  640. top:-1px;
  641. left:2px;
  642. width:2px;
  643. height:5px;
  644. background-color:#000;
  645. -moz-transform:rotate(-28deg);
  646. -ms-transform:rotate(-28deg);
  647. -o-transform:rotate(-28deg);
  648. -webkit-transform:rotate(-28deg);
  649. transform:rotate(-28deg);
  650. }
  651. .eye-left-eyelash3{
  652. top:-6px;
  653. left:7px;
  654. width:2px;
  655. height:5px;
  656. background-color:#000;
  657. -moz-transform:rotate(-4deg);
  658. -ms-transform:rotate(-4deg);
  659. -o-transform:rotate(-4deg);
  660. -webkit-transform:rotate(-4deg);
  661. transform:rotate(-4deg);
  662. }
  663. .eye-left-eyelash4{
  664. top:-4px;
  665. left:13px;
  666. width:2px;
  667. height:4px;
  668. background-color:#000;
  669. -moz-transform:rotate(25deg);
  670. -ms-transform:rotate(25deg);
  671. -o-transform:rotate(25deg);
  672. -webkit-transform:rotate(25deg);
  673. transform:rotate(25deg);
  674. }
  675. .eye-left-eyelash5{
  676. top:3px;
  677. rightright:0;
  678. width:2px;
  679. height:4px;
  680. background-color:#000;
  681. -moz-transform:rotate(41deg);
  682. -ms-transform:rotate(41deg);
  683. -o-transform:rotate(41deg);
  684. -webkit-transform:rotate(41deg);
  685. transform:rotate(41deg);
  686. }
  687. .rightright-eyebrow{
  688. top:68px;
  689. left:92px;
  690. z-index:110;
  691. width:66px;
  692. height:36px;
  693. border:2pxsolid#000;
  694. border-width:2px1px0px1px;
  695. -moz-border-radius:45px51px00;
  696. -webkit-border-radius:45px51px00;
  697. border-radius:45px51px00;
  698. background-color:transparent;
  699. -moz-transform:skew(-6deg,16deg);
  700. -ms-transform:skew(-6deg,16deg);
  701. -o-transform:skew(-6deg,16deg);
  702. -webkit-transform:skew(-6deg,16deg);
  703. transform:skew(-6deg,16deg);
  704. }
  705. .rightright-eyebrow-over{
  706. top:21px;
  707. rightright:-5px;
  708. z-index:115;
  709. width:13px;
  710. height:20px;
  711. background-color:#f6c6b0;
  712. }
  713. .left-eyebrow{
  714. top:89px;
  715. left:36px;
  716. z-index:100;
  717. width:30px;
  718. height:68px;
  719. border:2pxsolid#000;
  720. border-width:2px1px0px1px;
  721. -moz-border-radius:100%;
  722. -webkit-border-radius:100%;
  723. border-radius:100%;
  724. background-color:transparent;
  725. -moz-transform:rotate(-2deg);
  726. -ms-transform:rotate(-2deg);
  727. -o-transform:rotate(-2deg);
  728. -webkit-transform:rotate(-2deg);
  729. transform:rotate(-2deg);
  730. }
  731. .left-eyebrow-over{
  732. top:17px;
  733. rightright:-9px;
  734. z-index:105;
  735. width:39px;
  736. height:55px;
  737. -moz-border-radius:21px12px017px;
  738. -webkit-border-radius:21px12px017px;
  739. border-radius:21px12px017px;
  740. background-color:#f6c6b0;
  741. -moz-transform:rotate(-13deg);
  742. -ms-transform:rotate(-13deg);
  743. -o-transform:rotate(-13deg);
  744. -webkit-transform:rotate(-13deg);
  745. transform:rotate(-13deg);
  746. }
  747. .nose{
  748. top:172px;
  749. left:63px;
  750. z-index:115;
  751. width:21px;
  752. height:16px;
  753. border:2pxsolid#000;
  754. -moz-border-radius:50%;
  755. -webkit-border-radius:50%;
  756. border-radius:50%;
  757. -moz-box-shadow:3px1px00#fffinset;
  758. -webkit-box-shadow:3px1px00#fffinset;
  759. box-shadow:3px1px00#fffinset;
  760. }
  761. .nose-over{
  762. top:-1px;
  763. rightright:-11px;
  764. z-index:115;
  765. width:19px;
  766. height:14px;
  767. background-color:#f6c6b0;
  768. -moz-transform:rotate(31deg);
  769. -ms-transform:rotate(31deg);
  770. -o-transform:rotate(31deg);
  771. -webkit-transform:rotate(31deg);
  772. transform:rotate(31deg);
  773. }
  774. .nose-tip{
  775. top:-7px;
  776. left:13px;
  777. width:2px;
  778. height:6px;
  779. background-color:#000;
  780. -moz-transform:rotate(14deg);
  781. -ms-transform:rotate(14deg);
  782. -o-transform:rotate(14deg);
  783. -webkit-transform:rotate(14deg);
  784. transform:rotate(14deg);
  785. }
  786. .mouth{
  787. bottombottom:61px;
  788. left:72px;
  789. z-index:110;
  790. width:46px;
  791. height:47px;
  792. border:2pxsolid#000;
  793. border-width:01px2px0;
  794. -moz-border-radius:32px29px23px48px/47px82px52px75px;
  795. -webkit-border-radius:32px29px23px48px/47px82px52px75px;
  796. border-radius:32px29px23px48px/47px82px52px75px;
  797. background-color:#92222E;
  798. -moz-transform:rotate(1deg)skew(0deg,39deg);
  799. -ms-transform:rotate(1deg)skew(0deg,39deg);
  800. -o-transform:rotate(1deg)skew(0deg,39deg);
  801. -webkit-transform:rotate(1deg)skew(0deg,39deg);
  802. transform:rotate(1deg)skew(0deg,39deg);
  803. }
  804. .mouth-over-1{
  805. bottombottom:0;
  806. left:-4px;
  807. z-index:115;
  808. width:37px;
  809. height:58px;
  810. border-right:1pxsolid#000;
  811. -moz-border-radius:38px13px10px77px/47px82px52px73px;
  812. -webkit-border-radius:38px13px10px77px/47px82px52px73px;
  813. border-radius:38px13px10px77px/47px82px52px73px;
  814. background-color:#f6c6b0;
  815. -moz-transform:rotate(38deg)skew(0deg,6deg);
  816. -ms-transform:rotate(38deg)skew(0deg,6deg);
  817. -o-transform:rotate(38deg)skew(0deg,6deg);
  818. -webkit-transform:rotate(38deg)skew(0deg,6deg);
  819. transform:rotate(38deg)skew(0deg,6deg);
  820. }
  821. .mouth-over-2{
  822. bottombottom:38px;
  823. left:30px;
  824. z-index:150;
  825. width:7px;
  826. height:19px;
  827. background-color:#f6c6b0;
  828. -moz-transform:rotate(-233deg);
  829. -ms-transform:rotate(-233deg);
  830. -o-transform:rotate(-233deg);
  831. -webkit-transform:rotate(-233deg);
  832. transform:rotate(-233deg);
  833. }
  834. .mouth-over-3{
  835. bottombottom:-9px;
  836. left:11px;
  837. z-index:115;
  838. width:27px;
  839. height:9px;
  840. border-top:2pxsolid#000;
  841. -moz-border-radius:100%;
  842. -webkit-border-radius:100%;
  843. border-radius:100%;
  844. background-color:#f6c6b0;
  845. -moz-transform:rotate(-4deg);
  846. -ms-transform:rotate(-4deg);
  847. -o-transform:rotate(-4deg);
  848. -webkit-transform:rotate(-4deg);
  849. transform:rotate(-4deg);
  850. }
  851. .mouth-over-4{
  852. bottombottom:-6px;
  853. left:-1px;
  854. z-index:150;
  855. width:7px;
  856. height:15px;
  857. background-color:#f6c6b0;
  858. -moz-transform:rotate(-226deg);
  859. -ms-transform:rotate(-226deg);
  860. -o-transform:rotate(-226deg);
  861. -webkit-transform:rotate(-226deg);
  862. transform:rotate(-226deg);
  863. }
  864. .mouth-tip{
  865. bottombottom:39px;
  866. left:41px;
  867. z-index:120;
  868. width:2px;
  869. height:3px;
  870. background-color:#000;
  871. -moz-transform:rotate(-51deg);
  872. -ms-transform:rotate(-51deg);
  873. -o-transform:rotate(-51deg);
  874. -webkit-transform:rotate(-51deg);
  875. transform:rotate(-51deg);
  876. }
  877. .mouth-inner{
  878. bottombottom:50px;
  879. left:107px;
  880. z-index:115;
  881. width:10px;
  882. height:18px;
  883. -moz-border-radius:10px04px6px/8px2px8px9px;
  884. -webkit-border-radius:10px04px6px/8px2px8px9px;
  885. border-radius:10px04px6px/8px2px8px9px;
  886. background-color:#ed675c;
  887. -moz-transform:rotate(6deg);
  888. -ms-transform:rotate(6deg);
  889. -o-transform:rotate(6deg);
  890. -webkit-transform:rotate(6deg);
  891. transform:rotate(6deg);
  892. }
  893. .name-lable{
  894. bottombottom:-9px;
  895. left:-8px;
  896. z-index:150;
  897. width:280px;
  898. color:#005aa9;
  899. text-align:center;
  900. font-weight:bold;
  901. font-style:italic;
  902. font-size:50px;
  903. font-family:TimesNewRoman;
  904. }
  905. .name-lable-light{
  906. top:30px;
  907. width:100%;
  908. height:0;
  909. -moz-box-shadow:003px3px#fff;
  910. -webkit-box-shadow:003px3px#fff;
  911. box-shadow:003px3px#fff;
  912. }
  913. @-webkit-keyframesinput-flash{
  914. 0%{
  915. border-color:#ccc;
  916. -moz-box-shadow:inset01px1pxrgba(0,0,0,0.075);
  917. -webkit-box-shadow:inset01px1pxrgba(0,0,0,0.075);
  918. box-shadow:inset01px1pxrgba(0,0,0,0.075);
  919. }
  920. 100%{
  921. border-color:rgba(82,168,236,0.8);
  922. -moz-box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  923. -webkit-box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  924. box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  925. }
  926. }
  927. @-moz-keyframesinput-flash{
  928. 0%{
  929. border-color:#ccc;
  930. -moz-box-shadow:inset01px1pxrgba(0,0,0,0.075);
  931. -webkit-box-shadow:inset01px1pxrgba(0,0,0,0.075);
  932. box-shadow:inset01px1pxrgba(0,0,0,0.075);
  933. }
  934. 100%{
  935. border-color:rgba(82,168,236,0.8);
  936. -moz-box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  937. -webkit-box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  938. box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  939. }
  940. }
  941. @-ms-keyframesinput-flash{
  942. 0%{
  943. border-color:#ccc;
  944. -moz-box-shadow:inset01px1pxrgba(0,0,0,0.075);
  945. -webkit-box-shadow:inset01px1pxrgba(0,0,0,0.075);
  946. box-shadow:inset01px1pxrgba(0,0,0,0.075);
  947. }
  948. 100%{
  949. border-color:rgba(82,168,236,0.8);
  950. -moz-box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  951. -webkit-box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  952. box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  953. }
  954. }
  955. @keyframesinput-flash{
  956. 0%{
  957. border-color:#ccc;
  958. -moz-box-shadow:inset01px1pxrgba(0,0,0,0.075);
  959. -webkit-box-shadow:inset01px1pxrgba(0,0,0,0.075);
  960. box-shadow:inset01px1pxrgba(0,0,0,0.075);
  961. }
  962. 100%{
  963. border-color:rgba(82,168,236,0.8);
  964. -moz-box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  965. -webkit-box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  966. box-shadow:inset01px1pxrgba(0,0,0,0.075),0010pxrgba(82,168,236,0.6);
  967. }
  968. }
  969. </style>
  970. </head>
  971. <body>
  972. <divstyle="width:400px;height:359px;position:relative;margin:50pxauto;">
  973. <divclass="outer-circle">
  974. <!--外圆-->
  975. <divclass="inner-circle">
  976. <!--内圆-->
  977. <divclass="inner-circle-light"></div>
  978. <divclass="header-top"></div>
  979. <!--头发-->
  980. <divclass="hair-left-1"></div>
  981. <divclass="hair-left-2"></div>
  982. <divclass="hair-light-1"></div>
  983. <divclass="hair-light-1-over"></div>
  984. <divclass="hair-light-2"></div>
  985. <divclass="hair-right-1">
  986. <divclass="hair-right-2">
  987. </div>
  988. </div>
  989. <divclass="header-left"></div>
  990. <!--脸部-->
  991. <divclass="face-main"></div>
  992. <divclass="face-light-1"></div>
  993. <divclass="face-light-2"></div>
  994. <divclass="face-top"></div>
  995. <divclass="face-right-1"></div>
  996. <divclass="face-bottom-1"></div>
  997. <divclass="face-bottom-1-over"></div>
  998. <divclass="face-bottom-2"></div>
  999. <divclass="face-bottom-2-over"></div>
  1000. <divclass="chin"></div>
  1001. <divclass="ear">
  1002. <!--耳朵-->
  1003. <divclass="ear-inner-1"></div>
  1004. <divclass="ear-inner-2"></div>
  1005. <divclass="ear-over"></div>
  1006. <divclass="ear-light"></div>
  1007. </div>
  1008. <divclass="eye-left">
  1009. <!--左眼-->
  1010. <divclass="eye-left-inner"></div>
  1011. <divclass="eye-left-light1"></div>
  1012. <divclass="eye-left-light2"></div>
  1013. <divclass="eye-left-eyelash1"></div>
  1014. <divclass="eye-left-eyelash2"></div>
  1015. <divclass="eye-left-eyelash3"></div>
  1016. <divclass="eye-left-eyelash4"></div>
  1017. <divclass="eye-left-eyelash5"></div>
  1018. </div>
  1019. <divclass="eye-right">
  1020. <!--右眼-->
  1021. <divclass="eye-right-inner"></div>
  1022. <divclass="eye-right-light1"></div>
  1023. <divclass="eye-right-light2"></div>
  1024. <divclass="eye-right-eyelash1"></div>
  1025. <divclass="eye-right-eyelash2"></div>
  1026. <divclass="eye-right-eyelash3"></div>
  1027. <divclass="eye-right-eyelash4"></div>
  1028. <divclass="eye-right-eyelash5"></div>
  1029. </div>
  1030. <divclass="right-eyebrow">
  1031. <!--右眼眉毛-->
  1032. <divclass="right-eyebrow-over"></div>
  1033. </div>
  1034. <divclass="left-eyebrow">
  1035. <!--左眼眉毛-->
  1036. <divclass="left-eyebrow-over"></div>
  1037. </div>
  1038. <divclass="nose">
  1039. <!--鼻子-->
  1040. <divclass="nose-tip"></div>
  1041. <divclass="nose-over"></div>
  1042. </div>
  1043. <divclass="mouth">
  1044. <!--嘴巴-->
  1045. <divclass="mouth-over-1"></div>
  1046. <divclass="mouth-over-2"></div>
  1047. <divclass="mouth-over-3"></div>
  1048. <divclass="mouth-over-4"></div>
  1049. <divclass="mouth-tip"></div>
  1050. </div>
  1051. <divclass="mouth-inner"></div>
  1052. <divclass="name-lable">
  1053. ASTROBOY
  1054. <divclass="name-lable-light"></div>
  1055. </div>
  1056. </div>
  1057. </div>
  1058. </div>
  1059. </body>
  1060. </html>

使用CSS3画出一个叮当猫
如果你经常使用PS或者Flash的话,应该就会知道画个叮当猫是很容易 的事,至少我是这么觉得。但是,用CSS3画出来确实是第一次接触,所以很乐意去尝试一下,对于我这种菜鸟,确实是帮助不少,至少懂得如何去画一个简单的 人物形象出来,再加上一些动画效果,就活了,那就更好玩了!OK,开始之前,先把效果图晒一下:

PS:说实话,我觉得挺可爱的,小时候经常看多啦A梦,突然感觉很亲切,很童真,瞬间年轻了好多,哈哈!热烈的笑脸

首先,先把HTML结构搭建好:

XML/HTML Code复制内容到剪贴板
  1. <divclass="wrapper">
  2. <!--叮当猫整体-->
  3. <divclass="doraemon">
  4. <!--头部-->
  5. <divclass="head">
  6. <!--眼睛-->
  7. <divclass="eyes">
  8. <divclass="eyeleft">
  9. <!--眼珠-->
  10. <divclass="blackbleft"></div>
  11. </div>
  12. <divclass="eyeright">
  13. <divclass="blackbright"></div>
  14. </div>
  15. </div>
  16. <!--脸部-->
  17. <divclass="face">
  18. <!--白色脸底-->
  19. <divclass="white"></div>
  20. <!--鼻子-->
  21. <divclass="nose">
  22. <!--鼻子高光部分-->
  23. <divclass="light"></div>
  24. </div>
  25. <!--鼻子的竖线-->
  26. <divclass="nose_line"></div>
  27. <!--嘴巴-->
  28. <divclass="mouth"></div>
  29. <!--胡须-->
  30. <divclass="whiskers">
  31. <divclass="whiskerrTopr160"></div>
  32. <divclass="whiskerrMiddle"></div>
  33. <divclass="whiskerrBottomr20"></div>
  34. <divclass="whiskerlTopr20"></div>
  35. <divclass="whiskerlMiddle"></div>
  36. <divclass="whiskerlBottomr160"></div>
  37. </div>
  38. </div>
  39. </div>
  40. <!--脖子和铃铛-->
  41. <divclass="choker">
  42. <!--铃铛-->
  43. <divclass="bell">
  44. <divclass="bell_line"></div>
  45. <divclass="bell_circle"></div>
  46. <divclass="bell_under"></div>
  47. <divclass="bell_light"></div>
  48. </div>
  49. </div>
  50. <!--身体-->
  51. <divclass="bodys">
  52. <!--肚子-->
  53. <divclass="body"></div>
  54. <!--肚兜-->
  55. <divclass="wraps"></div>
  56. <!--口袋-->
  57. <divclass="pocket"></div>
  58. <!--遮住一半口袋,使其呈现半圆-->
  59. <divclass="pocket_mask"></div>
  60. </div>
  61. <!--右手-->
  62. <divclass="hand_right">
  63. <!--手臂-->
  64. <divclass="arm"></div>
  65. <!--手掌-->
  66. <divclass="circle"></div>
  67. <!--遮住手臂和身子交接处的线-->
  68. <divclass="arm_rewrite"></div>
  69. </div>
  70. <!--左手-->
  71. <divclass="hand_left">
  72. <divclass="arm"></div>
  73. <divclass="circle"></div>
  74. <divclass="arm_rewrite"></div>
  75. </div>
  76. <!--脚-->
  77. <divclass="foot">
  78. <divclass="left"></div>
  79. <divclass="right"></div>
  80. <!--双脚之间的缝隙-->
  81. <divclass="foot_rewrite"></div>
  82. </div>
  83. </div>
  84. </div>

最好先把叮当猫的整体结构仔细研究一下,这对以后想要自己动手画别的人物形象很有帮助,思路会比较明朗。

接下来,我们按照头部,脖子,身体,脚部分别进行演示。首先将容器wrapper和叮当猫整体做一些基本的样式,叮当猫整体doraemon 设置position为relative,主要是为了便于 子元素/后代元素进行定位。

CSS Code复制内容到剪贴板
  1. .wrapper{
  2. margin:50px00500px;
  3. }
  4. .doraemon{
  5. position:relative;
  6. }

头部head的样式,因为叮当猫的头部不是正圆,所以宽高有一点偏差,然后使用border-radius将头部从矩形变成椭圆形,然后再使用径向渐变从右上角给背景来个放射性渐变,然后在加个阴影,使其更有立体感,background:#07bbee;是为了兼容低版本浏览器:

CSS Code复制内容到剪贴板
  1. .doraemon.head{
  2. position:relative;
  3. width:320px;
  4. height:300px;
  5. border-radius:150px;
  6. background:#07bbee;
  7. background:-webkit-radial-gradient(rightrighttop,#fff10%,#07bbee20%,#10a6ce75%,#000);
  8. background:-moz-radial-gradient(rightrighttop,#fff10%,#07bbee20%,#10a6ce75%,#000);
  9. background:-ms-radial-gradient(rightrighttop,#fff10%,#07bbee20%,#10a6ce75%,#000);
  10. border:2pxsolid#555;
  11. box-shadow:-5px10px15pxrgba(0,0,0,0.45);
  12. }

看看效果到底怎么样:

惊讶 shenmgui ,这么丑,别急,慢慢让它活过来:

CSS Code复制内容到剪贴板
  1. /*脸部*/
  2. .doraemon.face{
  3. position:relative;/*让所有脸部元素可自由定位*/
  4. z-index:2;/*脸在头部背景上面*/
  5. }
  6. /*白色脸底*/
  7. .doraemon.face.white{
  8. width:265px;/*设置宽高*/
  9. height:195px;
  10. border-radius:150px;
  11. position:absolute;/*进行绝对定位*/
  12. top:75px;
  13. left:25px;
  14. background:#fff;
  15. /*此放射渐变也是使脸的左下角暗一些,看上去更真实*/
  16. background:-webkit-radial-gradient(rightrighttop,#fff75%,#eee80%,#99990%,#444);
  17. background:-moz-radial-gradient(rightrighttop,#fff75%,#eee80%,#99990%,#444);
  18. background:–ms-radial-gradient(rightrighttop,#fff75%,#eee80%,#99990%,#444);
  19. }
  20. /*鼻子*/
  21. .doraemon.face.nose{
  22. width:30px;
  23. height:30px;
  24. border-radius:15px;
  25. background:#c93300;
  26. border:2pxsolid#000;
  27. position:absolute;
  28. top:110px;
  29. left:140px;
  30. z-index:3;/*鼻子在白色脸底下面*/
  31. }
  32. /*鼻子上的高光*/
  33. .doraemon.face.nose.light{
  34. width:10px;
  35. height:10px;
  36. border-radius:5px;
  37. box-shadow:19px8px5px#fff;/*通过阴影实现高光*/
  38. }
  39. /*鼻子下的线*/
  40. .doraemon.face.nose_line{
  41. width:3px;
  42. height:100px;
  43. background:#333;
  44. position:absolute;
  45. top:143px;
  46. left:155px;
  47. z-index:3;
  48. }
  49. /*嘴巴*/
  50. .doraemon.face.mouth{
  51. width:220px;
  52. height:400px;
  53. /*通过底边框加上圆角模拟微笑嘴巴*/
  54. border-bottom:3pxsolid#333;
  55. border-radius:120px;
  56. position:absolute;
  57. top:-160px;
  58. left:45px;
  59. }
  60. /*眼睛*/
  61. .doraemon.eyes{
  62. position:relative;
  63. z-index:3;/*眼睛在白色脸底下面*/
  64. }
  65. /*眼睛共同的样式*/
  66. .doraemon.eyes.eye{
  67. width:72px;
  68. height:82px;
  69. background:#fff;
  70. border:2pxsolid#000;
  71. border-radius:35px35px;
  72. position:absolute;
  73. top:40px;
  74. }
  75. /*眼珠*/
  76. .doraemon.eyes.eye.black{
  77. width:14px;
  78. height:14px;
  79. background:#000;
  80. border-radius:7px;
  81. position:absolute;
  82. top:40px;
  83. }
  84. .doraemon.eyes.left{
  85. left:82px;
  86. }
  87. .doraemon.eyes.rightright{
  88. left:156px;
  89. }
  90. .doraemon.eyes.eye.bleft{
  91. left:50px;
  92. }
  93. .doraemon.eyes.eye.bright{
  94. left:7px;
  95. }

写了这么多样式,结果是怎么样的呢:

生病 怎么看都觉得别扭,哦!还差胡须须和白色脸底的边框呢,咱给补上:

CSS Code复制内容到剪贴板
  1. /*胡须背景,主要用于挡住嘴巴的一部分,不要显得太长*/
  2. .doraemon.whiskers{
  3. width:220px;
  4. height:80px;
  5. background:#fff;
  6. border-radius:15px;
  7. position:absolute;
  8. top:120px;
  9. left:45px;
  10. z-index:2;/*在鼻子和眼睛下面*/
  11. }
  12. /*所有胡子的公用样式*/
  13. .doraemon.whiskers.whisker{
  14. width:60px;
  15. height:2px;
  16. background:#333;
  17. position:absolute;
  18. z-index:2;
  19. }
  20. /*右上胡子*/
  21. .doraemon.whiskers.rTop{
  22. left:165px;
  23. top:25px;
  24. }
  25. /*右中胡子*/
  26. .doraemon.whiskers.rMiddle{
  27. left:167px;
  28. top:45px;
  29. }
  30. /*右下胡子*/
  31. .doraemon.whiskers.rBottom{
  32. left:165px;
  33. top:65px;
  34. }
  35. /*左上胡子*/
  36. .doraemon.whiskers.lTop{
  37. left:0;
  38. top:25px;
  39. }
  40. /*左中胡子*/
  41. .doraemon.whiskers.lMiddle{
  42. left:-2px;
  43. top:45px;
  44. }
  45. /*左下胡子*/
  46. .doraemon.whiskers.lBottom{
  47. left:0;
  48. top:65px;
  49. }
  50. /*胡子旋转角度*/
  51. .doraemon.whiskers.r160{
  52. -webkit-transform:rotate(160deg);
  53. -moz-transform:rotate(160deg);
  54. -ms-transform:rotate(160deg);
  55. -o-transform:rotate(160deg);
  56. transform:rotate(160deg);
  57. }
  58. .doraemon.whiskers.r20{
  59. -webkit-transform:rotate(200deg);
  60. -moz-transform:rotate(200deg);
  61. -ms-transform:rotate(200deg);
  62. -o-transform:rotate(200deg);
  63. transform:rotate(200deg);
  64. }

微笑 这样就对了,看着多舒服啊!趁热打铁,做脖子和身体:

CSS Code复制内容到剪贴板
  1. /*围脖*/
  2. .doraemon.choker{
  3. width:230px;
  4. height:20px;
  5. background:#c40;
  6. /*线性渐变让围巾看上去更自然*/
  7. background:-webkit-gradient(linear,lefttop,leftbottombottom,from(#c40),to(#800400));
  8. background:-moz-linear-gradient(centertop,#c40,#800400);
  9. background:-ms-linear-gradient(centertop,#c40,#800400);
  10. border:2pxsolid#000;
  11. border-radius:10px;
  12. position:relative;
  13. top:-40px;
  14. left:45px;
  15. z-index:4;
  16. }
  17. /*铃铛*/
  18. .doraemon.choker.bell{
  19. width:40px;
  20. height:40px;
  21. _overflow:hidden;/*IE6hack*/
  22. border:2pxsolid#000;
  23. border-radius:50px;
  24. background:#f9f12a;
  25. background:-webkit-gradient(linear,lefttop,leftbottombottom,from(#f9f12a),color-stop(0.5,#e9e11a),to(#a9a100));
  26. background:-moz-linear-gradient(top,#f9f12a,#e9e11a75%,#a9a100);
  27. background:-ms-linear-gradient(top,#f9f12a,#e9e11a75%,#a9a100);
  28. box-shadow:-5px5px10pxrgba(0,0,0,0.25);
  29. position:absolute;
  30. top:5px;
  31. left:90px;
  32. }
  33. /*双横线*/
  34. .doraemon.choker.bell_line{
  35. width:36px;
  36. height:2px;
  37. background:#f9f12a;
  38. border:2pxsolid#333;
  39. border-radius:3px3px00;
  40. position:absolute;
  41. top:10px;
  42. }
  43. /*黑点*/
  44. .doraemon.choker.bell_circle{
  45. width:12px;
  46. height:10px;
  47. background:#000;
  48. border-radius:5px;
  49. position:absolute;
  50. top:20px;
  51. left:14px;
  52. }
  53. /*黑点下的线*/
  54. .doraemon.choker.bell_under{
  55. width:3px;
  56. height:15px;
  57. background:#000;
  58. position:absolute;
  59. left:18px;
  60. top:27px;
  61. }
  62. /*铃铛高光*/
  63. .doraemon.choker.bell_light{
  64. width:12px;
  65. height:12px;
  66. border-radius:10px;
  67. box-shadow:19px8px5px#fff;
  68. position:absolute;
  69. top:-5px;
  70. left:5px;
  71. opacity:0.7;
  72. }
  73. /*身子*/
  74. .doraemon.bodys{
  75. position:relative;
  76. top:-310px;
  77. }
  78. /*肚子*/
  79. .doraemon.bodys.body{
  80. width:220px;
  81. height:165px;
  82. background:#07beea;
  83. background:-webkit-gradient(linear,rightrighttop,lefttop,from(#07beea),color-stop(0.5,#0073b3),color-stop(0.75,#00b0e0),to(#0096be));
  84. background:-moz-linear-gradient(rightrightcenter,#07beea,#0073b350%,#00b0e075%,#0096be100%);
  85. background:-ms-linear-gradient(rightrightcenter,#07beea,#0073b350%,#00b0e075%,#0096be100%);
  86. border:2pxsolid#333;
  87. position:absolute;
  88. top:265px;
  89. left:50px;
  90. }
  91. /*白色肚兜*/
  92. .doraemon.bodys.wraps{
  93. width:170px;
  94. height:170px;
  95. background:#fff;
  96. background:-webkit-gradient(linear,rightrighttop,leftbottombottom,from(#fff),color-stop(0.75,#fff),color-stop(0.83,#eee),color-stop(0.90,#999),color-stop(0.95,#444),to(#000));
  97. background:-moz-linear-gradient(rightrighttop,#fff,#fff75%,#eee83%,#99990%,#44495%,#000);
  98. background:-ms-linear-gradient(rightrighttop,#fff,#fff75%,#eee83%,#99990%,#44495%,#000);
  99. border:2pxsolid#000;
  100. border-radius:85px;
  101. position:absolute;
  102. left:72px;
  103. top:230px;
  104. }
  105. /*口袋*/
  106. .doraemon.bodys.pocket{
  107. width:130px;
  108. height:130px;
  109. border-radius:65px;
  110. background:#fff;
  111. background:-webkit-gradient(linear,rightrighttop,leftbottombottom,from(#fff),color-stop(0.70,#fff),color-stop(0.75,#f8f8f8),color-stop(0.80,#eee),color-stop(0.88,#ddd),to(#fff));
  112. background:-moz-linear-gradient(rightrighttop,#fff,#fff70%,#f8f8f875%,#eee80%,#ddd88%,#fff);
  113. background:-ms-linear-gradient(rightrighttop,#fff,#fff70%,#f8f8f875%,#eee80%,#ddd88%,#fff);
  114. border:2pxsolid#000;
  115. position:absolute;
  116. top:250px;
  117. left:92px;
  118. }
  119. /*挡住口袋一半*/
  120. .doraemon.bodys.pocket_mask{
  121. width:134px;
  122. height:60px;
  123. background:#fff;
  124. border-bottom:2pxsolid#000;
  125. position:absolute;
  126. top:259px;
  127. left:92px;
  128. }

好吧,脖子和身子都有啦!上图:

现在看起来有点像摆设品,不过笑容还是那么单纯,好了,赶紧把手脚做出来:

CSS Code复制内容到剪贴板
  1. /*左右手*/
  2. .doraemon.hand_right,.doraemon.hand_left{
  3. height:100px;
  4. width:100px;
  5. position:absolute;
  6. top:272px;
  7. left:248px;
  8. }
  9. /*左手*/
  10. .doraemon.hand_left{
  11. left:-10px;
  12. }
  13. /*手臂公共部分*/
  14. .doraemon.arm{
  15. width:80px;
  16. height:50px;
  17. background:#07beea;
  18. background:-webkit-gradient(linear,lefttop,leftbottombottom,from(#07beea),color-stop(0.85,#07beea),to(#555));
  19. background:-moz-linear-gradient(centertop,#07BEEA,#07BEEA85%,#555);
  20. background:-ms-linear-gradient(centertop,#07BEEA,#07BEEA85%,#555);
  21. border:1pxsolid#000000;
  22. box-shadow:-10px7px10pxrgba(0,0,0,0.35);
  23. z-index:-1;
  24. position:relative;
  25. }
  26. /*右手手臂*/
  27. .doraemon.hand_right.arm{
  28. top:17px;
  29. -webkit-transform:rotate(35deg);
  30. -moz-transform:rotate(35deg);
  31. -ms-transform:rotate(35deg);
  32. -o-transform:rotate(35deg);
  33. transform:rotate(35deg);
  34. }
  35. /*左手手臂*/
  36. .doraemon.hand_left.arm{
  37. top:17px;
  38. background:#0096be;/*背光一面使用纯色,使其有立体感*/
  39. box-shadow:5px-7px10pxrgba(0,0,0,0.25);
  40. -webkit-transform:rotate(145deg);
  41. -moz-transform:rotate(145deg);
  42. -ms-transform:rotate(145deg);
  43. -o-transform:rotate(145deg);
  44. transform:rotate(145deg);
  45. }
  46. /*圆形手掌公共部分*/
  47. .doraemon.circle{
  48. width:60px;
  49. height:60px;
  50. border-radius:30px;
  51. border:2pxsolid#000;
  52. background:#fff;
  53. background:-webkit-gradient(linear,rightrighttop,leftbottombottom,from(#fff),color-stop(0.5,#fff),color-stop(0.70,#eee),color-stop(0.8,#ddd),to(#999));
  54. background:-moz-linear-gradient(rightrighttop,#fff,#fff50%,#eee70%,#ddd80%,#999);
  55. background:-ms-linear-gradient(rightrighttop,#fff,#fff50%,#eee70%,#ddd80%,#999);
  56. position:absolute;
  57. }
  58. /*右手手掌*/
  59. .doraemon.hand_right.circle{
  60. left:40px;
  61. top:32px;
  62. }
  63. /*左手手掌*/
  64. .doraemon.hand_left.circle{
  65. left:-20px;
  66. top:32px;
  67. }
  68. /*手臂和身体结合处,使用背景遮住边框*/
  69. .doraemon.arm_rewrite{
  70. height:45px;
  71. width:5px;
  72. background:#07beea;
  73. position:relative;
  74. }
  75. /*右手结合处*/
  76. .doraemon.hand_right.arm_rewrite{
  77. top:-45px;
  78. left:22px;
  79. }
  80. /*左手结合处*/
  81. .doraemon.hand_left.arm_rewrite{
  82. top:-45px;
  83. left:60px;
  84. background:#0096be;/*同理,背光一面使用纯色,使其有立体感*/
  85. }
  86. /*脚部*/
  87. .doraemon.foot{
  88. width:280px;
  89. height:40px;
  90. position:relative;
  91. top:55px;
  92. left:20px;
  93. }
  94. /*左右脚共同样式*/
  95. .doraemon.foot.left,.doraemon.foot.rightright{
  96. width:125px;
  97. height:30px;
  98. background:#fff;
  99. background:-webkit-gradient(linear,rightrighttop,leftbottombottom,from(#fff),color-stop(0.75,#fff),color-stop(0.85,#eee),to(#999));
  100. background:-moz-linear-gradient(rightrighttop,#fff,#fff75%,#eee85%,#999);
  101. background:-ms-linear-gradient(rightrighttop,#fff,#fff75%,#eee85%,#999);
  102. border:2pxsolid#333;
  103. border-radius:80px60px60px40px;
  104. box-shadow:-6px010pxrgba(0,0,0,0.35);
  105. position:relative;
  106. }
  107. .doraemon.foot.left{
  108. left:8px;
  109. top:65px;
  110. }
  111. .doraemon.foot.rightright{
  112. top:31px;
  113. left:141px;
  114. }
  115. /*双脚之间的缝隙,加阴影使用立体感*/
  116. .doraemon.foot.foot_rewrite{
  117. width:20px;
  118. height:10px;
  119. background:#fff;
  120. background:-webkit-gradient(linear,rightrighttop,leftbottombottom,from(#666),color-stop(0.83,#fff),to(#fff));
  121. background:-moz-linear-gradient(rightrighttop,#666,#fff83%,#fff);
  122. background:-ms-linear-gradient(rightrighttop,#666,#fff83%,#fff);
  123. /*制作半圆效果*/
  124. border:2pxsolid#000;
  125. border-bottom:none;
  126. border-radius:40px40px00;
  127. position:relative;
  128. top:-11px;
  129. left:130px;
  130. _left:127px;
  131. }

好了,最后完整结果:

看一下,效果是不是和一开始的一样呢 大笑 ,虽然做好了,但是还是可以让它动起来的,比如眼睛,我们可以给它加个动画效果,让眼睛转动起来:

CSS Code复制内容到剪贴板
  1. /*眼珠*/
  2. .doraemon.eyes.eye.black{
  3. width:14px;
  4. height:14px;
  5. background:#000;
  6. border-radius:7px;
  7. position:absolute;
  8. top:40px;
  9. -webkit-animation:eyemove3slinearinfinite;
  10. -moz-animation:eyemove3slinearinfinite;
  11. -ms-animation:eyemove3slinearinfinite;
  12. -o-animation:eyemove3slinearinfinite;
  13. animation:eyemove3slinearinfinite;
  14. }
  15. /*让眼睛动起来*/
  16. @-webkit-keyframeseyemove{
  17. 70%{
  18. margin:0000;
  19. }
  20. 80%{
  21. margin:-22px000;
  22. }
  23. 85%{
  24. margin:-22px005px;
  25. }
  26. 90%{
  27. margin:-22px10px00;
  28. }
  29. 93%{
  30. margin:-22px000;
  31. }
  32. 96%{
  33. margin:0000;
  34. }
  35. }
  36. @-moz-keyframeseyemove{
  37. 70%{
  38. margin:0000;
  39. }
  40. 80%{
  41. margin:-22px000;
  42. }
  43. 85%{
  44. margin:-22px005px;
  45. }
  46. 90%{
  47. margin:-22px10px00;
  48. }
  49. 93%{
  50. margin:-22px000;
  51. }
  52. 96%{
  53. margin:0000;
  54. }
  55. }
  56. @-o-keyframeseyemove{
  57. 70%{
  58. margin:0000;
  59. }
  60. 80%{
  61. margin:-22px000;
  62. }
  63. 85%{
  64. margin:-22px005px;
  65. }
  66. 90%{
  67. margin:-22px10px00;
  68. }
  69. 93%{
  70. margin:-22px000;
  71. }
  72. 96%{
  73. margin:0000;
  74. }
  75. }
  76. @keyframeseyemove{
  77. 70%{
  78. margin:0000;
  79. }
  80. 80%{
  81. margin:-22px000;
  82. }
  83. 85%{
  84. margin:-22px005px;
  85. }
  86. 90%{
  87. margin:-22px10px00;
  88. }
  89. 93%{
  90. margin:-22px000;
  91. }
  92. 96%{
  93. margin:0000;
  94. }
  95. }

OK,这样,眼睛就会动了,有兴趣的可以试一下,这里就无法展示了。但是如果你有什么更好的动画效果也可以尝试,那么这个案例就结束了。

PS:虽然这只是一个案例,不过确实帮助我开阔思维,而且其实做一个这样的效果,可能会花费很多时间,至少对我来说目前确实是这样子,主要难点还是布局定位和颜色的合理搭配,才能使形象更加逼真生动!

以上就是如何使用HTML和CSS3绘制基本卡通图案的示例分享。除了少许的天份之外,大多是靠努力得来的“三分天才,七分努力。”是成功不变的法则,一个不愿或不肯努力的人,比起原地踏步,还要糟糕,所以要好好把握一分一秒的时刻,作为迈向下一步的准备,如此才能扎实稳固。更多关于如何使用HTML和CSS3绘制基本卡通图案的示例分享请关注haodaima.com其它相关文章!

您可能有感兴趣的文章
css让页脚保持在底部位置的四种方案

CSS如何使用Flex和Grid布局如何实现3D骰子

Flex布局史上最简单使用语法教程

新的CSS 伪类函数 :is() 和 :where()示例详解

纯CSS打字动画的如何实现示例