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

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

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

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

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

.wrapper{

margin: 50px 0 0 500px;

}

.doraemon{

position: relative;

}

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

.doraemon .head {

position:relative;

width: 320px;

height: 300px;

border-radius: 150px;

background: #07bbee;

background: -webkit-radial-gradient(right top,#fff 10%,#07bbee 20%,#10a6ce 75%,#000);

background: -moz-radial-gradient(right top,#fff 10%,#07bbee 20%,#10a6ce 75%,#000);

background: -ms-radial-gradient(right top,#fff 10%,#07bbee 20%,#10a6ce 75%,#000);

border:2px solid #555;

box-shadow:-5px 10px 15px rgba(0,0,0,0.45);

}

看看效果到底怎么样:

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

/*脸部*/

.doraemon .face {

position: relative; /*让所有脸部元素可自由定位*/

z-index: 2; /*脸在头部背景上面*/

}

/*白色脸底*/

.doraemon .face .white {

width: 265px; /*设置宽高*/

height: 195px;

border-radius: 150px;

position: absolute; /*进行绝对定位*/

top: 75px;

left: 25px;

background: #fff;

/*此放射渐变也是使脸的左下角暗一些,看上去更真实*/

background: -webkit-radial-gradient(right top,#fff 75%,#eee 80%,#999 90%,#444);

background: -moz-radial-gradient(right top,#fff 75%,#eee 80%,#999 90%,#444);

background: –ms-radial-gradient(right top,#fff 75%,#eee 80%,#999 90%,#444);

}

/*鼻子*/

.doraemon .face .nose{

width:30px;

height:30px;

border-radius:15px;

background:#c93300;

border:2px solid #000;

position:absolute;

top:110px;

left:140px;

z-index:3; /*鼻子在白色脸底下面*/

}

/*鼻子上的高光*/

.doraemon .face .nose .light {

width:10px;

height:10px;

border-radius: 5px;

box-shadow: 19px 8px 5px #fff; /*通过阴影实现高光*/

}

/*鼻子下的线*/

.doraemon .face .nose_line{

width:3px;

height:100px;

background:#333;

position:absolute;

top:143px;

left:155px;

z-index:3;

}

/*嘴巴*/

.doraemon .face .mouth{

width:220px;

height:400px;

/*通过底边框加上圆角模拟微笑嘴巴*/

border-bottom:3px solid #333;

border-radius:120px;

position:absolute;

top:-160px;

left:45px;

}

/*眼睛*/

.doraemon .eyes {

position: relative;

z-index: 3; /*眼睛在白色脸底下面*/

}

/*眼睛共同的样式*/

.doraemon .eyes .eye{

width:72px;

height:82px;

background:#fff;

border:2px solid #000;

border-radius:35px 35px;

position:absolute;

top:40px;

}

/*眼珠*/

.doraemon .eyes .eye .black{

width:14px;

height:14px;

background:#000;

border-radius:7px;

position:absolute;

top:40px;

}

.doraemon .eyes .left{

left:82px;

}

.doraemon .eyes .right {

left: 156px;

}

.doraemon .eyes .eye .bleft {

left: 50px;

}

.doraemon .eyes .eye .bright {

left: 7px;

}

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

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

/*胡须背景,主要用于挡住嘴巴的一部分,不要显得太长*/

.doraemon .whiskers{

width:220px;

height:80px;

background:#fff;

border-radius:15px;

position:absolute;

top:120px;

left:45px;

z-index:2; /*在鼻子和眼睛下面*/

}

/*所有胡子的公用样式*/

.doraemon .whiskers .whisker {

width: 60px;

height: 2px;

background: #333;

position: absolute;

z-index: 2;

}

/*右上胡子*/

.doraemon .whiskers .rTop {

left: 165px;

top: 25px;

}

/*右中胡子*/

.doraemon .whiskers .rMiddle {

left: 167px;

top: 45px;

}

/*右下胡子*/

.doraemon .whiskers .rBottom {

left: 165px;

top: 65px;

}

/*左上胡子*/

.doraemon .whiskers .lTop {

left: 0;

top: 25px;

}

/*左中胡子*/

.doraemon .whiskers .lMiddle {

left: -2px;

top: 45px;

}

/*左下胡子*/

.doraemon .whiskers .lBottom {

left: 0;

top: 65px;

}

/*胡子旋转角度*/

.doraemon .whiskers .r160 {

-webkit-transform: rotate(160deg);

-moz-transform: rotate(160deg);

-ms-transform: rotate(160deg);

-o-transform: rotate(160deg);

transform: rotate(160deg);

}

.doraemon .whiskers .r20 {

-webkit-transform: rotate(200deg);

-moz-transform: rotate(200deg);

-ms-transform: rotate(200deg);

-o-transform: rotate(200deg);

transform: rotate(200deg);

}

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

/*围脖*/

.doraemon .choker {

width: 230px;

height: 20px;

background: #c40;

/*线性渐变 让围巾看上去更自然*/

background: -webkit-gradient(linear,left top,left bottom,from(#c40),to(#800400));

background: -moz-linear-gradient(center top,#c40,#800400);

background: -ms-linear-gradient(center top,#c40,#800400);

border: 2px solid #000;

border-radius: 10px;

position: relative;

top: -40px;

left: 45px;

z-index: 4;

}

/*铃铛*/

.doraemon .choker .bell {

width: 40px;

height: 40px;

_overflow: hidden; /*IE6 hack*/

border: 2px solid #000;

border-radius: 50px;

background: #f9f12a;

background: -webkit-gradient(linear, left top, left bottom, from(#f9f12a),color-stop(0.5, #e9e11a), to(#a9a100));

background: -moz-linear-gradient(top, #f9f12a, #e9e11a 75%,#a9a100);

background: -ms-linear-gradient(top, #f9f12a, #e9e11a 75%,#a9a100);

box-shadow: -5px 5px 10px rgba(0,0,0,0.25);

position: absolute;

top: 5px;

left: 90px;

}

/*双横线*/

.doraemon .choker .bell_line {

width: 36px;

height: 2px;

background: #f9f12a;

border: 2px solid #333;

border-radius: 3px 3px 0 0;

position: absolute;

top: 10px;

}

/*黑点*/

.doraemon .choker .bell_circle{

width:12px;

height:10px;

background:#000;

border-radius:5px;

position:absolute;

top:20px;

left:14px;

}

/*黑点下的线*/

.doraemon .choker .bell_under{

width: 3px;

height:15px;

background:#000;

position:absolute;

left: 18px;

top:27px;

}

/*铃铛高光*/

.doraemon .choker .bell_light{

width:12px;

height:12px;

border-radius:10px;

box-shadow:19px 8px 5px #fff;

position:absolute;

top:-5px;

left:5px;

opacity:0.7;

}

/*身子*/

.doraemon .bodys {

position: relative;

top: -310px;

}

/*肚子*/

.doraemon .bodys .body {

width: 220px;

height: 165px;

background: #07beea;

background: -webkit-gradient(linear,right top,left top,from(#07beea),color-stop(0.5, #0073b3),color-stop(0.75,#00b0e0), to(#0096be));

background: -moz-linear-gradient(right center,#07beea,#0073b3 50%,#00b0e0 75%,#0096be 100%);

background: -ms-linear-gradient(right center,#07beea,#0073b3 50%,#00b0e0 75%,#0096be 100%);

border:2px solid #333;

position:absolute;

top:265px;

left:50px;

}

/*白色肚兜*/

.doraemon .bodys .wraps {

width: 170px;

height: 170px;

background: #fff;

background: -webkit-gradient(linear, right top, left bottom, from(#fff),color-stop(0.75,#fff),color-stop(0.83,#eee),color-stop(0.90,#999),color-stop(0.95,#444), to(#000));

background: -moz-linear-gradient(right top,#fff,#fff 75%,#eee 83%,#999 90%,#444 95%,#000);

background: -ms-linear-gradient(right top,#fff,#fff 75%,#eee 83%,#999 90%,#444 95%,#000);

border: 2px solid #000;

border-radius: 85px;

position: absolute;

left: 72px;

top: 230px;

}

/*口袋*/

.doraemon .bodys .pocket {

width: 130px;

height: 130px;

border-radius: 65px;

background: #fff;

background: -webkit-gradient(linear, right top, left bottom, from(#fff),color-stop(0.70,#fff),color-stop(0.75,#f8f8f8),color-stop(0.80,#eee),color-stop(0.88,#ddd), to(#fff));

background: -moz-linear-gradient(right top, #fff, #fff 70%,#f8f8f8 75%,#eee 80%,#ddd 88%, #fff);

background: -ms-linear-gradient(right top, #fff, #fff 70%,#f8f8f8 75%,#eee 80%,#ddd 88%, #fff);

border: 2px solid #000;

position:absolute;

top: 250px;

left: 92px;

}

/*挡住口袋一半*/

.doraemon .bodys .pocket_mask {

width: 134px;

height: 60px;

background:#fff;

border-bottom: 2px solid #000;

position:absolute;

top: 259px;

left: 92px;

}

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

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

/

*左右手*/

.doraemon .hand_right, .doraemon .hand_left {

height: 100px;

width: 100px;

position: absolute;

top: 272px;

left: 248px;

}

/*左手*/

.doraemon .hand_left {

left: -10px;

}

/*手臂公共部分*/

.doraemon .arm {

width:80px;

height:50px;

background: #07beea;

background: -webkit-gradient(linear, left top, left bottom, from(#07beea),color-stop(0.85,#07beea), to(#555));

background: -moz-linear-gradient(center top, #07BEEA, #07BEEA 85%, #555);

background: -ms-linear-gradient(center top, #07BEEA, #07BEEA 85%, #555);

border: 1px solid #000000;

box-shadow: -10px 7px 10px rgba(0, 0, 0, 0.35);

z-index: -1;

position: relative;

}

/*右手手臂*/

.doraemon .hand_right .arm {

top: 17px;

-webkit-transform: rotate(35deg);

-moz-transform: rotate(35deg);

-ms-transform: rotate(35deg);

-o-transform: rotate(35deg);

transform: rotate(35deg);

}

/*左手手臂*/

.doraemon .hand_left .arm {

top: 17px;

background: #0096be; /*背光一面使用纯色,使其有立体感*/

box-shadow: 5px -7px 10px rgba(0, 0, 0, 0.25);

-webkit-transform: rotate(145deg);

-moz-transform: rotate(145deg);

-ms-transform: rotate(145deg);

-o-transform: rotate(145deg);

transform: rotate(145deg);

}

/*圆形手掌公共部分*/

.doraemon .circle {

width: 60px;

height: 60px;

border-radius: 30px;

border: 2px solid #000;

background: #fff;

background: -webkit-gradient(linear, right top, left bottom, from(#fff),color-stop(0.5,#fff),color-stop(0.70,#eee),color-stop(0.8,#ddd), to(#999));

background: -moz-linear-gradient(right top, #fff, #fff 50%, #eee 70%, #ddd 80%,#999);

background: -ms-linear-gradient(right top, #fff, #fff 50%, #eee 70%, #ddd 80%,#999);

position: absolute;

}

/*右手手掌*/

.doraemon .hand_right .circle {

left: 40px;

top: 32px;

}

/*左手手掌*/

.doraemon .hand_left .circle {

left: -20px;

top: 32px;

}

/*手臂和身体结合处,使用背景遮住边框*/

.doraemon .arm_rewrite {

height: 45px;

width: 5px;

background: #07beea;

position: relative;

}

/*右手结合处*/

.doraemon .hand_right .arm_rewrite {

top: -45px;

left: 22px;

}

/*左手结合处*/

.doraemon .hand_left .arm_rewrite {

top: -45px;

left: 60px;

background: #0096be; /*同理,背光一面使用纯色,使其有立体感*/

}

/*脚部*/

.doraemon .foot {

width: 280px;

height: 40px;

position: relative;

top: 55px;

left: 20px;

}

/*左右脚共同样式*/

.doraemon .foot .left, .doraemon .foot .right {

width: 125px;

height: 30px;

background: #fff;

background: -webkit-gradient(linear, right top, left bottom, from(#fff),color-stop(0.75,#fff),color-stop(0.85,#eee), to(#999));

background: -moz-linear-gradient(right top, #fff, #fff 75%, #eee 85%, #999);

background: -ms-linear-gradient(right top, #fff, #fff 75%, #eee 85%, #999);

border: 2px solid #333;

border-radius: 80px 60px 60px 40px;

box-shadow: -6px 0 10px rgba(0, 0, 0, 0.35);

position: relative;

}

.doraemon .foot .left {

left: 8px;

top: 65px;

}

.doraemon .foot .right {

top: 31px;

left: 141px;

}

/*双脚之间的缝隙,加阴影使用立体感*/

.doraemon .foot .foot_rewrite {

width: 20px;

height: 10px;

background: #fff;

background: -webkit-gradient(linear, right top, left bottom, from(#666),color-stop(0.83,#fff), to(#fff));

background: -moz-linear-gradient(right top, #666, #fff 83%, #fff);

background: -ms-linear-gradient(right top, #666, #fff 83%, #fff);

/*制作半圆效果*/

border: 2px solid #000;

border-bottom: none;

border-radius: 40px 40px 0 0;

position: relative;

top: -11px;

left: 130px;

_left: 127px;

}

好了,最后完整结果:

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

/*眼珠*/

.doraemon .eyes .eye .black {

width: 14px;

height: 14px;

background: #000;

border-radius: 7px;

position: absolute;

top: 40px;

-webkit-animation: eyemove 3s linear infinite;

-moz-animation: eyemove 3s linear infinite;

-ms-animation: eyemove 3s linear infinite;

-o-animation: eyemove 3s linear infinite;

animation: eyemove 3s linear infinite;

}

/*让眼睛动起来*/

@-webkit-keyframes eyemove {

70%{

margin:0 0 0 0;

}

80% {

margin: -22px 0 0 0;

}

85% {

margin: -22px 0 0 5px;

}

90% {

margin: -22px 10px 0 0;

}

93% {

margin: -22px 0 0 0;

}

96% {

margin: 0 0 0 0;

}

}

@-moz-keyframes eyemove {

70% {

margin: 0 0 0 0;

}

80% {

margin: -22px 0 0 0;

}

85% {

margin: -22px 0 0 5px;

}

90% {

margin: -22px 10px 0 0;

}

93% {

margin: -22px 0 0 0;

}

96% {

margin: 0 0 0 0;

}

}

@-o-keyframes eyemove {

70% {

margin: 0 0 0 0;

}

80% {

margin: -22px 0 0 0;

}

85% {

margin: -22px 0 0 5px;

}

90% {

margin: -22px 10px 0 0;

}

93% {

margin: -22px 0 0 0;

}

96% {

margin: 0 0 0 0;

}

}

@keyframes eyemove {

70% {

margin: 0 0 0 0;

}

80% {

margin: -22px 0 0 0;

}

85% {

margin: -22px 0 0 5px;

}

90% {

margin: -22px 10px 0 0;

}

93% {

margin: -22px 0 0 0;

}

96% {

margin: 0 0 0 0;

}

}

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

PS:虽然这只是一个案例,不过确实帮助我开阔思维,而且其实做一个这样的效果,可能会花费很多时间,至少对我来说目前确实是这样子,主要难点还是布局定位和颜色的合理搭配,才能使形象更加逼真生动!可能也有人对PS或者Flash等图形处理软件不是很熟,对用CSS3画出一些人物或者其他效果比较没有头绪,那么就可以去一些网站参考设计师们的设计构图,图形分解等相关设计知识,帮助我们更好地理解。

以上是本文的全部内容,希望大家可以喜欢,动手去实践一下。

如何用c语言画个叮当猫,如何使用CSS3画出一个叮当猫相关推荐

  1. css 画小黄人,纯CSS3画出小黄人并实现动画效果

    前言 前两天我刚发布了一篇CSS3实现小黄人动画的博客,但是实现的CSS3动画是基于我在站酷网找到的一张小黄人的jpg格式图片,并自己用PS抠出需要实现动画的部分,最后才完成的动画效果.但是,其实我的 ...

  2. 用c语言复制程序,怎么用C程序写出一个能复制自己的程序?

    发信人: crazywill (开始努力学习啦), 信区: Programming 标 题: 输出为本身的c程序 发信站: 华南网木棉站 (Thu Dec 12 09:41:48 2002), 转信 ...

  3. css画钟表_如何使用css3绘制出圆形动态时钟

    使用css3绘制出圆形动态时钟的原理 众所周知的是div形状是方形的,那么我们首先需要使用border-radius属性将其变换成圆形. 为了使指针转动起来,我们需要使用-webkit-transfo ...

  4. c语言字符的计数器,如何用C语言编写计数器.docx

    如何用C语言编写计数器 难怪很多前辈说调试是一个程序员最基本的技能,其重要性甚至超过学习一门语言.不会调试的程序员就意味着他即使会一门语言,却不能编制出任何好的软件.?我以前接触的程序大多是有比较成形 ...

  5. css3画一个三角形,css3 画三角形

    /*箭头向上*/ .arrow-up { width:0; height:0; border-left:20px solid transparent; border-right:20px solid ...

  6. c语言字母圣诞树,如何用C语言画一个“圣诞树”.pdf

    如如何何用用C语语言言画画一一个个"圣圣诞诞树树" 如何用C语言画一个"圣诞树",我使用了左右镜像的Sierpinski triangle,每层减去上方一小块, ...

  7. 如何用Python语言编写源程序,读取Excel中数据,并画出柱状图?

    现在,随着计算机的普及,以及数据量的增多,对大型数据的分析已经是我们手算不能解决的了,必须借助计算机:那么,学习计算机其实也和我们学习中文.英文一样,要学习他们的写作规则,掌握其中原理.所以,我们首先 ...

  8. 用C语言制作爱心,如何用C语言画一个“心形”

    程序yuan眼中的浪漫如何用C语言画一个"心形"? 在你们的世界里,是不是觉得程序员一点浪漫都不懂?其实不是的,程序yuan的世界也是很浪漫滴. 看 这个图片是不是很浪漫,有木有很 ...

  9. c 语言画图片,如何用 C 语言画「心形」?

    原标题:如何用 C 语言画「心形」? 在我们IT行业每天面对的就是敲代码,所以很多人无法接受这份工作,因为很无聊也很枯燥,长期工作会使人情绪低落,其实我们编程很多时候也有有趣的地方,接下来我就用一个简 ...

最新文章

  1. [转]C#网络编程(异步传输字符串) - Part.3
  2. bert+crf可以做NER,那么为什么还有bert+bi-lstm+crf ?
  3. LeetCode-1.Two Sum
  4. 知识图谱(四)——实体识别和扩展
  5. 与您相约.NET Conf China 2020! 新进2位重磅嘉宾
  6. Getmemory函数详解--内存操作的理解
  7. MyCat分布式数据库集群架构工作笔记0004---Mycat的实现原理
  8. java内存溢出模拟_模拟实战排查堆内存溢出(java.lang.OutOfMemoryError: Java heap space)问题...
  9. 一个简单例子理解连表查询
  10. 信息学奥赛一本通 提高篇
  11. Android 获取文件后缀名
  12. 如何查看Spark日志与排查报错问题
  13. 微信小程序rich-text图片不显示及图片过大问题解决办法
  14. 关于Burp Suite不能抓包的解决方法
  15. 谷歌浏览器中文乱码问题
  16. 大年初五,2017年数据科学圈哪件事最令你激动?
  17. 项目使用第三方插件发送短信-------建周短信SDK(Software Development Kit)
  18. ZOJ 3494 BCD code
  19. 校友录php源代码,php校友录网站系统
  20. 20亿美元宝马激光雷达订单?Innoviz上市披露哪些风险

热门文章

  1. 什么是 CSRF 攻击?
  2. 连接IBM MQ原因码报2537的错误解决记录
  3. 下个月去北京了,心如一团乱麻好多事情要解决,但是不知道从哪里开始,还是顺其自然吧,一件件的解决...
  4. 【目标检测】YOLOv5针对小目标检测的改进模型/添加帧率检测
  5. 考研数二第十一讲 罗尔中值和拉格朗日定理与柯西中值定理
  6. 如何从“豌豆荚”下载APP的历史版本?
  7. javaWeb基础二:Servlet(java前后端交互的技术)
  8. 前端诡异参数start
  9. 小学计算机网络教室上机制度,网络教室上机登记制度
  10. Spark RDD的宽依赖和窄依赖