[css]我要用css画幅画(七)

接着之前的[css]我要用css画幅画(六),今天画的有所不同,画的是哆啦A梦,我们小时候对他的称呼其实是小叮当机器猫。

(PS:这次我要做的事情,很多人已经做过,这并不是什么创新,我只是在学习并记录下学习的过程)

这次就不多说CSS属性的基础概念了。 说说我画的过程吧, 好,进入正题。

因为和之前的瞎画不同,这次是画现有的东西。我认为临摹是比较简单的。 我先上网找了下要临摹的对象,找了个最中规中矩的图片,如下:

这对我来说不是一个简单的任务, 而我处理不简单的任务的解决方案,就是把他拆分再拆分,一直拆到问题无法再拆且可以解决为止。

拆分结果如下:

1. 头

  1.1 眼睛

  1.2 脸廓

  1.3 鼻子

  1.4 胡须

  1.5 嘴唇

  1.6 嘴巴

    1.6.1 口腔

    1.6.2 舌头 

2. 身子

  2.1 项圈

  2.2 铃铛

  2.3 躯干

  2.4 肚兜

  2.5 百宝袋

  2.6 双手

    2.6.1 手臂

    2.6.2 拳头

  2.7 双脚

    2.7.1 腿

    2.7.2 脚掌

这个画我无法一次性完成,最新的效果可以在这里看到: Demo

代码在这: https://github.com/bee0060/Css-Paint   

(请根据关键字carton、doraemon找相应的文件)

之后我会陆续更新这幅画,有些进展之后会记录在该篇博客中。

--------------------------------------------------------------------------   2015.12.24 start   --------------------------------------------------------------------------

到目前为止, 完成了小叮当的头部。 看了效果的会发现,下巴处看起来不对, 没关系,等我加上他的围脖后,就能遮挡住这块不对劲的地方了。

先上代码:

 1 <div class="doraemon">
 2             <div class="circle border-black-1 head">
 3                 <div class="eyes">
 4                     <div class="circle pos-a bacc-white eye eye-left">
 5                         <div class="circle pos-r top-30 eye-pupil eye-pupil-left"></div>
 6                     </div>
 7                     <div class="circle pos-a bacc-white eye eye-right">
 8                         <div class="circle pos-r top-30 eye-pupil eye-pupil-right"></div>
 9                     </div>
10                 </div>
11                 <div class="border-black-2 bacc-white face">
12                     <div class="circle pos-r border-black-2 bacc-brown-red nose">
13                         <div class="circle pos-a bacc-white nose-light"></div>
14                     </div>
15                     <div class="m-hoz-auto pos-r bacc-white bread-field">
16 
17                     <div class="m-hoz-auto bacc-black nasal-groove"></div>
18                         <div class="pos-a bacc-black bread bread-left bread-left-1"></div>
19                         <div class="pos-a bacc-black bread bread-left bread-left-2"></div>
20                         <div class="pos-a bacc-black bread bread-left bread-left-3"></div>
21                         <div class="pos-a bacc-black bread bread-right bread-right-1"></div>
22                         <div class="pos-a bacc-black bread bread-right bread-right-2"></div>
23                         <div class="pos-a bacc-black bread bread-right bread-right-3"></div>
24                     </div>
25 
26                     
27                     <div class="pos-r m-hoz-auto lips">
28                         <div class="pos-a bacc-white border-black-2 lips-left"></div>
29                         <div class="lips-center-left pull-left">
30                             <div class="lips-center-left-inside circle border-black-2 bacc-white"></div>
31                         </div>
32                         <div class="lips-center pull-left bacc-white">
33                             <div class="lips-center-inside pos-r m-hoz-auto border-black-2 bacc-mouse-red"></div>
34                         </div>
35                         <div class="lips-center-right pull-left">
36                             <div class="lips-center-right-inside border-black-2 bacc-white">                            </div>
37                         </div>
38                         <div class="pos-a border-black-2 bacc-white lips-right"></div>
39                     </div>
40                     
41                     <div class="mouth border-black-2 m-hoz-auto bacc-mouse-red">
42                         <div class="tongue pos-r m-hoz-auto bacc-mouse-red">
43                             <div class="tongue-left pos-r pull-left">
44                                 <div class="tongue-left-inside border-black-2 bacc-mouse-orange"></div>
45                             </div>
46                             <div class="tongue-right pos-r pull-left">
47                                 <div class="tongue-right-inside border-black-2 bacc-mouse-orange"></div>
48                             </div>
49                         </div>
50                     </div>
51                 </div>
52             </div>
53         </div>
head-html
  1 div {
  2     /*border: 1px solid #000;*/
  3 }
  4 
  5 
  6 /*位置选择器*/
  7 .pos-a {
  8     position: absolute;
  9 }
 10 
 11 .pos-r {
 12     position: relative;
 13 }
 14 
 15 .pull-left {
 16     float: left;
 17 }
 18 
 19 .pull-right {
 20     float: right;
 21 }
 22 
 23 .m-hoz-auto {
 24     margin-left: auto;
 25     margin-right: auto;
 26 }
 27 
 28 .left-32 {
 29     left: 32px;
 30 }
 31 
 32 .left-5 {
 33     left: 5px;
 34 }
 35 
 36 .top-30 {
 37     top: 30px;
 38 }
 39 
 40 /*形状选择器*/
 41 .circle {
 42     border-radius: 50%;
 43 }
 44 
 45 
 46 /*样式选择器*/
 47 .bacc-white {
 48     background-color: white;
 49 }
 50 
 51 .bacc-black {
 52     background-color: black;
 53 }
 54 
 55 .bacc-brown-red {
 56     background-color: rgb(216, 5, 23);
 57 }
 58 
 59 .bacc-mouse-red {
 60     background-color: #E80115;
 61 }
 62 
 63 .bacc-mouse-orange {
 64     background-color: #EF6C1C;
 65 }
 66 
 67 .border-black-1 {
 68     border: 1px solid black;
 69 }
 70 
 71 .border-black-2 {
 72     border: 2px solid black;
 73 }
 74 
 75 .border-black-3 {
 76     border: 3px solid black;
 77 }
 78 
 79 /*卡通组件*/
 80 .doraemon {
 81     height: 500px;
 82     width: 500px;
 83 }
 84 
 85 .head {
 86     background-color: rgb(2, 159, 227);
 87     height: 300px;
 88     margin: 0px auto;
 89     overflow: hidden;
 90     width: 310px;
 91 }
 92 
 93 .eyes {
 94     height: 80px;
 95     margin: -5px auto 0;
 96     padding-top: 10px;
 97     width: 120px;
 98 }
 99 
100 .eye {
101     border: 2px solid #000;
102     box-sizing: border-box;
103     height: 80px;
104     width: 60px;
105 }
106 
107 .eye-left {
108     float: left;
109     margin-left: 2px;
110 }
111 
112 .eye-right {
113     float: right;
114     margin-left: 58px;
115 }
116 
117 .eye-pupil {
118     background-color: black;
119     height: 18px;
120     width: 18px;
121 }
122 
123 .eye-pupil-left {
124      left: 32px;
125 }
126 
127 .eye-pupil-right {
128      left: 5px;
129 }
130 
131 .face {
132     border-top-left-radius: 45% 60%;
133     border-top-right-radius: 45% 60%;    
134     border-bottom-left-radius: 60% 85%;
135     border-bottom-right-radius: 60% 85%;
136     height: 230px;
137     margin: -30px auto;
138     width: 270px;
139 
140     z-index: 5;
141 }
142 
143 .nose {
144     height: 38px;
145     margin: 16px auto 0;
146     width: 38px;
147 }
148 
149 .nose-light {
150     height: 10px;
151     right: 10px;
152     top: 8px;
153     width: 10px;
154 }
155 
156 .nasal-groove{
157     height: 45px;
158     width: 2px;
159     z-index: 12;
160 }
161 
162 .bread-field {
163     height: 44px;
164     width: 240px;
165     z-index: 10;
166 }
167 
168 .bread {
169     height: 2px;
170     width: 80px;
171 }
172 
173 .bread-left {
174     left: 10px;
175     -webkit-transform-origin: right top;
176 }
177 
178 .bread-left-1 {
179     
180     top: -5px;
181     -webkit-transform: rotate(20deg);
182 }
183 
184 .bread-left-2 {
185     top: 10px;
186     -webkit-transform: rotate(5deg);
187 }
188 
189 .bread-left-3 {
190     top: 20px;
191     -webkit-transform: rotate(-15deg);
192 }
193 
194 .bread-right {
195     right: 10px;
196     -webkit-transform-origin: left top;
197 }
198 
199 .bread-right-1 {
200     top: -5px;
201     -webkit-transform: rotate(-20deg);
202 }
203 
204 .bread-right-2 {
205     top: 10px;
206     -webkit-transform: rotate(-5deg);
207 }
208 
209 .bread-right-3 {
210     top: 20px;
211     -webkit-transform: rotate(15deg);
212 }
213 
214 .lips {
215     height: 10px;
216     width: 250px;
217 }
218 
219 .lips-center {    
220     height: 75px;
221     overflow: hidden;
222     width: 145px;
223 }
224 
225 .lips-center-inside {
226     border-top-left-radius: 65%;
227     border-top-right-radius: 65%;
228     border-style: none;
229     border-top-style: solid;
230 
231     height: 75px;
232     margin-left: -50px;
233     width: 250px;
234 }
235 
236 .lips-center-left {    
237     height: 40px;
238     margin-left: 10px;
239     overflow: hidden;
240     width: 40px;
241 }
242 
243 .lips-center-left-inside {
244     border-bottom-left-radius: 50% 50%;
245     border-bottom-right-radius: 50% 50%;
246     border-top:none;
247     border-left:none;
248     border-right:none;
249     content: " ";
250     display: block;
251     height: 45px;
252     margin-left: -30px;
253     margin-top: -36px;
254     width: 100px;
255 }
256 
257 .lips-center-right {
258     height: 40px;
259     overflow: hidden;
260     width: 40px;
261 }
262 
263 .lips-center-right-inside {
264     border-bottom-left-radius: 50%;
265     border-bottom-right-radius: 50%;
266     border-top:none;
267     border-left:none;
268     border-right:none;
269     content: " ";
270     display: block;
271     height: 45px;
272     margin-left: -34px;
273     margin-top: -37px;
274     width: 100px;
275 }
276 
277 .lips-left {
278     border-top-left-radius: 60% 50%;
279     border-top-right-radius: 0%;
280     border-bottom-left-radius: 75% 50%;
281     border-bottom-right-radius: 0%;
282     border-right: none;
283     height: 60px;
284     left: -22px;
285     top: -59px;
286     width: 40px;
287 
288     -webkit-transform: rotate(15deg) ;
289 }
290 
291 .lips-right {
292     border-top-right-radius: 55% 50%;
293     border-top-left-radius: 0%;
294     border-bottom-right-radius: 80% 50%;
295     border-bottom-left-radius: 0%;
296     border-left: none;
297     height: 60px;
298     right: -22px;
299     top: -59px;
300     width: 40px;
301 
302     -webkit-transform: rotate(-9deg) ;
303 }
304 
305 .mouth {
306     border-bottom-left-radius: 50% 100%;
307     border-bottom-right-radius: 50% 100%;
308     border-top: none;
309     height: 150px;
310     margin-top:-50px;
311     width: 240px;
312 }
313 
314 .tongue {
315     border-bottom-left-radius: 50% 100%;
316     border-bottom-right-radius: 50% 100%;
317     border-top: none;
318     height: 65px;
319     top: -30px;
320     overflow: hidden;
321     width: 170px;
322 }
323 
324 .tongue-left {
325     height: 65px;
326     margin-top: 20px;
327     margin-left: 15px;
328     overflow: hidden;
329     width: 80px;
330     z-index: 2;
331 }
332 
333 .tongue-left-inside {
334     border-top-left-radius: 50% 80%;
335     border-top-right-radius: 50% 80%;    
336     border-bottom: none;
337 
338     height: 65px;
339     width: 80px;
340     z-index: 2;
341 
342     -webkit-transform: rotate(-45deg);
343 }
344 
345 .tongue-right {    
346     height: 60px;
347     margin-top: -67px;
348     margin-left: 83px;
349     overflow: hidden;
350     width: 80px;
351     z-index: 3;
352 }
353 
354 .tongue-right-inside {
355     border-top-left-radius: 50% 80%;
356     border-top-right-radius: 50% 80%;    
357     border-bottom: none;
358     margin-top: 2px;
359     margin-left: -11px;
360     height: 60px;
361     width: 80px;
362     z-index: 3;
363 
364     -webkit-transform: rotate(45deg);
365 }
common&head-css

codepen效果: https://codepen.io/bee0060/pen/gjpYLX

这个画画了快一个月,才把头画完,主要是因为懒,三天打鱼两天晒网,其次也在中途遇到几个难点,差点因为这些难点放弃了。

其中最难的要数嘴唇和嘴唇两边的类似半圆形(我叫它们做“嘴唇左边”和“嘴唇右边”), 其中需要曲线、半圆、倾斜、遮盖来完成。其中最难处理的是曲线,解决了曲线问题后,就比较顺利的完成了后续的画。

嘴唇左边: 这里用了一个半圆加上一定的倾斜实现。但实现之初,半圆会突出到胡子的区域,我就给胡子的容器设置白色背景色,将突出到胡子区域的嘴唇左边部分遮盖。

嘴唇:     因为嘴唇是先向下凸,再向上,又向下的曲线,这里由3个圆角来拼接成这样的曲线,这里做曲线的时间是最长的,遇到的问题和解决方案在下面细说。

嘴唇右边:这里和嘴唇左边采取相同的方法。 只是圆角的角度不相同。

曲线:    我是用圆角来实现曲线的,相信很多人都是这么处理的。但是圆角有个问题,如果只有一面有边框(例如left),且设置圆角,这个边框会在末端慢慢变细,这会影响呈现效果。

    我的解决方案是,增加一层容器, 再给容器设置overflow:none, 然后真正拥有圆角边框的对象在容器内, 然后调整容器和圆角对象的大小,让边框变细的部分超出容器,以此隐藏掉变细的部分。

画这幅画的过程一点也不优雅, 我无法通过数学的方式优雅的计算出每个对象的位置,每个圆角的弧度,每个倾斜的角度。 我采用最低级的方法, 在chrome中,选中元素并不断调整各种css属性,最终实现现在的效果。 所以这么做非常低效。 如果各位有什么好的工具或方法, 请不吝赐教。 在此先谢过。

到目前为止,只完成了头部, 之后(应该)会陆续完善直至完成。

谢谢观看。另外,圣诞快乐。

--------------------------------------------------------------------------   2015.12.24 end   --------------------------------------------------------------------------

  

--------------------------------------------------------------------------   2015.12.27 start   --------------------------------------------------------------------------

今天的更新不说功能, 只说一说这幅画的CSS规范和策略。

本画尽量遵照OOCSS的建议:http://www.w3cplus.com/css/oocss-concept

看了本画代码的同学可能会觉得很多html对象都用了一大串的class,但是细心的可能会发现有些类选择器出现过多次。 

我这么写的目的是,在css的不同选择器中,尽量减少同名且同值的css属性代码。

在html上,可以像组件一样引用各种需要的选择器来实现效果。

这样可以让css尽量短小,且不重复。 虽然html对象的class属性很长,但是可以像组件一样更灵活的变换组合出需要的效果。

在本画中,只使用类选择器,即class选择器。

类选择器的种类主要分为4种:

1. 组件 - 用于描述哆啦A梦的各组成部分,如头(.head)、脸(.face)、眼睛(.eyes)等, 其中包含的css属性为以下3种不包含的,其实就是那些不知道怎么放进以下三种选择器中的css属性。

2. 形状 - 用于描述对象形状的,如正圆形, 暂时只有.circle类, 其中只有一个属性: border-radius: 50%;

3. 位置 - 这里不包括left、top等直接描述位置的,因为各组件的具体位置基本不可重用。这里描述的位置是:position、float,还有特殊的如margin纵向居中的类。

4. 样式 - 如背景色类、边框颜色类、边框宽度类等。 例如看原图可以看出, 这画其实主要就那么3、4种颜色, 所以我把颜色抽出来,就不需要在一大堆类中写重复的颜色css了。

类选择器的命名:

我用的编辑器是Sublime Text 2, 有一个非常好用也很常用的组件是Emmet,Emmet其中一个功能是可以打很少的字符来输入css,于是我的类选择器,如果其中只设置一个属性的话,一般就用这个属性和值在Emmet中的简写来表示,还有些用属性名的简写加上对应值的名称,用横杠链接来表示。如:

 1 /*
 2   左边为Emmet 中的简写,右边为表示的css属性 
 3   pos ==> position
 4   bacc ==> background-color 
 5   于是我有如下类选择器:
 6 */
 7 
 8 .pos-a {
 9     position: absolute;
10 }
11 
12 
13 .bacc-white {
14     background-color: white;
15 }

在html中使用选择器时, 也按照选择器类别的顺序: 组件->形状->位置->样式, 如下:

 1 <div class="eye eye-left circle pos-a bacc-white"> 2 </div> 

其中组件有可能有扩展和子组件的关系,就根据组件选择器的辈份从前到后排列。

好了,我的html和css书写规范说完了。 下次更新应该至少会画个围脖(或叫项圈)吧。

谢谢观看。

--------------------------------------------------------------------------   2015.12.27 end   --------------------------------------------------------------------------

--------------------------------------------------------------------------   2016.01.04 end   --------------------------------------------------------------------------

经过几天断断续续的努力, 终于把这个画给完成了。 掌握了基本技巧之后,要完成这幅画的难度就降低很多了。最基本的技巧不外乎:

· 圆角

· 遮盖

· overflow hidden

· 倾斜

这次更新完成的内容较多, 包括如下:

1. 项圈 - 用一个较宽的椭圆实现, 只显示下半圆的大部分,用容器把不需要的超出部分隐藏。 铃铛里的曲线也是用会超出容器的两个上下并排的圆实现

2. 身体 - 用不规则的椭圆实现

3. 百宝袋 - 用两个不规则椭圆实现上边和下边

4. 双手 - 用椭圆和倾斜实现手臂,再用正圆的手掌遮盖不需要的部分

5. 双脚 - 用两个不规则椭圆实现左右两腿, 用一个白底黑边的椭圆实现裤裆(~。~),并遮盖在两腿之间,实现最终效果。 用椭圆和倾斜实现双脚。

大体上已经完成, 细节还是看得出差异,不过我个人已经比较满意这个效果了。 之后可能只会花一点点时间去微调一下细节部分。

所以, 这幅画到此结束。 谢谢观看。

--------------------------------------------------------------------------   2016.01.04 end   --------------------------------------------------------------------------

完.....

最终效果:  Demo

Code pen效果: http://codepen.io/bee0060/pen/rxjKxP

关键html: 

 1 <div class="doraemon pull-left">
 2             <div class="head pos-r m-hoz-auto circle border-black-1 bacc-blue">
 3                 <div class="eyes">
 4                     <div class="eye eye-left circle pos-a bacc-white">
 5                         <div class="eye-pupil eye-pupil-left circle pos-r top-30"></div>
 6                     </div>
 7                     <div class="eye eye-right circle pos-a bacc-white">
 8                         <div class="eye-pupil eye-pupil-right circle pos-r top-30"></div>
 9                     </div>
10                 </div>
11                 <div class="face border-black-2 bacc-white">
12                     <div class="nose circle pos-r border-black-2 bacc-brown-red">
13                         <div class="nose-light circle pos-a bacc-white"></div>
14                     </div>
15                     <div class="bread-field m-hoz-auto pos-r bacc-white">
16 
17                     <div class="nasal-groove m-hoz-auto bacc-black"></div>
18                         <div class="bread bread-left bread-left-1 pos-a bacc-black"></div>
19                         <div class="bread bread-left bread-left-2 pos-a bacc-black"></div>
20                         <div class="bread bread-left bread-left-3 pos-a bacc-black"></div>
21                         <div class="bread bread-right bread-right-1 pos-a bacc-black"></div>
22                         <div class="bread bread-right bread-right-2 pos-a bacc-black"></div>
23                         <div class="bread bread-right bread-right-3 pos-a bacc-black"></div>
24                     </div>
25 
26                     
27                     <div class="lips pos-r m-hoz-auto">
28                         <div class="lips-left pos-a bacc-white border-black-2"></div>
29                         <div class="lips-center-left pull-left">
30                             <div class="lips-center-left-inside circle border-black-2 bacc-white"></div>
31                         </div>
32                         <div class="lips-center pull-left bacc-white">
33                             <div class="lips-center-inside pos-r m-hoz-auto border-black-2 bacc-mouse-red"></div>
34                         </div>
35                         <div class="lips-center-right pull-left">
36                             <div class="lips-center-right-inside border-black-2 bacc-white">                            </div>
37                         </div>
38                         <div class="lips-right pos-a border-black-2 bacc-white"></div>
39                     </div>
40                     
41                     <div class="mouth m-hoz-auto border-black-2 bacc-mouse-red">
42                         <div class="tongue pos-r m-hoz-auto bacc-mouse-red">
43                             <div class="tongue-left pos-r pull-left">
44                                 <div class="tongue-left-inside border-black-2 bacc-mouse-orange"></div>
45                             </div>
46                             <div class="tongue-right pos-r pull-left">
47                                 <div class="tongue-right-inside border-black-2 bacc-mouse-orange"></div>
48                             </div>
49                         </div>
50                     </div>
51                 </div>
52             </div>
53             
54             <div class="collar pos-r m-hoz-auto oh">
55                 <div class="collor-border-top pos-a circle border-black-2"></div>
56                  <div class="collar-inside circle"></div>
57                  <div class="collor-border-bottom pos-a circle border-black-2"></div>
58             </div>
59             <div class="bell pos-r m-hoz-auto oh circle bacc-bell-yellow border-black-2">
60                 <div class="bell-middle-curve bell-middle-curve-1 circle border-black-2"></div>
61                 <div class="bell-middle-curve bell-middle-curve-2 circle border-black-2"></div>
62                 <div class="bell-hole circle bacc-white border-black-2"></div>
63                 <div class="bell-gap m-hoz-auto border-black-1"></div>
64             </div>
65             <div class="body pos-r m-hoz-auto">
66                 <div class="body-inside pos-r m-hoz-auto border-black-2 bacc-blue"></div>
67                 <div class="belly pos-r m-hoz-auto border-black-2 bacc-white">
68                     <div class="bag pos-r m-hoz-auto oh">
69                         <div class="bag-top pos-a border-black-2"></div>
70                         <div class="bag-bottom pos-r border-black-2"></div>
71                     </div>
72                 </div>
73                 <div class="left-hand pos-r">
74                     <div class="left-arm pos-r border-black-2 bacc-blue"></div>
75                     <div class="left-palm pos-a    circle border-black-2 bacc-white"></div>
76                 </div>
77                 <div class="right-hand pos-r">
78                     <div class="right-arm pos-r border-black-2 bacc-blue"></div>
79                     <div class="right-palm pos-a circle border-black-2 bacc-white"></div>
80                 </div>
81                 <div class="left-leg pos-r oh">
82                     <div class="left-leg-inside pos-r border-black-2 bacc-blue"></div>
83                 </div>
84                 <div class="crotch pos-a m-hoz-auto oh">
85                     <div class="crotch-inside border-black-2 bacc-white">                        
86                     </div>
87                 </div>
88                 <div class="right-leg pos-r oh">
89                     <div class="right-leg-inside pos-r border-black-2 bacc-blue"></div>
90                 </div>
91 
92                 <div class="left-foot pos-a border-black-2 bacc-white"></div>
93                 <div class="right-foot pos-a border-black-2 bacc-white"></div>
94             </div>
95         </div>
View Code

完整css:

  1 div {
  2     /*border: 1px solid #000;*/
  3 }
  4 
  5 
  6 /*位置选择器*/
  7 .pos-a {
  8     position: absolute;
  9 }
 10 
 11 .pos-r {
 12     position: relative;
 13 }
 14 
 15 .pull-left {
 16     float: left;
 17 }
 18 
 19 .pull-right {
 20     float: right;
 21 }
 22 
 23 .m-hoz-auto {
 24     margin-left: auto;
 25     margin-right: auto;
 26 }
 27 
 28 .left-32 {
 29     left: 32px;
 30 }
 31 
 32 .left-5 {
 33     left: 5px;
 34 }
 35 
 36 .top-30 {
 37     top: 30px;
 38 }
 39 
 40 /*形状选择器*/
 41 .circle {
 42     border-radius: 50%;
 43 }
 44 
 45 
 46 /*样式选择器*/
 47 .bacc-white {
 48     background-color: white;
 49 }
 50 
 51 .bacc-black {
 52     background-color: black;
 53 }
 54 
 55 .bacc-blue {
 56     background-color: rgb(2, 159, 227);
 57 }
 58 
 59 .bacc-brown-red {
 60     background-color: rgb(216, 5, 23);
 61 }
 62 
 63 .bacc-mouse-red {
 64     background-color: #E80115;
 65 }
 66 
 67 .bacc-mouse-orange {
 68     background-color: #EF6C1C;
 69 }
 70 
 71 .bacc-bell-yellow {
 72     background-color: #F5D600;
 73 }
 74 
 75 .border-black-1 {
 76     border: 1px solid black;
 77 }
 78 
 79 .border-black-2 {
 80     border: 2px solid black;
 81 }
 82 
 83 .border-black-3 {
 84     border: 3px solid black;
 85 }
 86 
 87 .oh {
 88     overflow: hidden;
 89 }
 90 
 91 /*卡通组件*/
 92 .doraemon {
 93     height: 500px;
 94     width: 500px;
 95 }
 96 
 97 .head {    
 98     height: 300px;
 99     overflow: hidden;
100     width: 310px;
101     z-index: 2;
102 }
103 
104 .eyes {
105     height: 80px;
106     margin: -5px auto 0;
107     padding-top: 10px;
108     width: 120px;
109 }
110 
111 .eye {
112     border: 2px solid #000;
113     box-sizing: border-box;
114     height: 80px;
115     width: 60px;
116 }
117 
118 .eye-left {
119     float: left;
120     margin-left: 2px;
121 }
122 
123 .eye-right {
124     float: right;
125     margin-left: 58px;
126 }
127 
128 .eye-pupil {
129     background-color: black;
130     height: 18px;
131     width: 18px;
132 }
133 
134 .eye-pupil-left {
135      left: 32px;
136 }
137 
138 .eye-pupil-right {
139      left: 5px;
140 }
141 
142 .face {
143     border-top-left-radius: 45% 60%;
144     border-top-right-radius: 45% 60%;    
145     border-bottom-left-radius: 60% 85%;
146     border-bottom-right-radius: 60% 85%;
147     height: 230px;
148     margin: -30px auto;
149     width: 270px;
150 
151     z-index: 5;
152 }
153 
154 .nose {
155     height: 38px;
156     margin: 16px auto 0;
157     width: 38px;
158 }
159 
160 .nose-light {
161     height: 10px;
162     right: 10px;
163     top: 8px;
164     width: 10px;
165 }
166 
167 .nasal-groove{
168     height: 45px;
169     width: 2px;
170     z-index: 12;
171 }
172 
173 .bread-field {
174     height: 44px;
175     width: 240px;
176     z-index: 10;
177 }
178 
179 .bread {
180     height: 2px;
181     width: 80px;
182 }
183 
184 .bread-left {
185     left: 10px;
186     -webkit-transform-origin: right top;
187 }
188 
189 .bread-left-1 {
190     
191     top: -5px;
192     -webkit-transform: rotate(20deg);
193 }
194 
195 .bread-left-2 {
196     top: 10px;
197     -webkit-transform: rotate(5deg);
198 }
199 
200 .bread-left-3 {
201     top: 20px;
202     -webkit-transform: rotate(-15deg);
203 }
204 
205 .bread-right {
206     right: 10px;
207     -webkit-transform-origin: left top;
208 }
209 
210 .bread-right-1 {
211     top: -5px;
212     -webkit-transform: rotate(-20deg);
213 }
214 
215 .bread-right-2 {
216     top: 10px;
217     -webkit-transform: rotate(-5deg);
218 }
219 
220 .bread-right-3 {
221     top: 20px;
222     -webkit-transform: rotate(15deg);
223 }
224 
225 .lips {
226     height: 10px;
227     width: 250px;
228 }
229 
230 .lips-center {    
231     height: 75px;
232     overflow: hidden;
233     width: 145px;
234 }
235 
236 .lips-center-inside {
237     border-top-left-radius: 65%;
238     border-top-right-radius: 65%;
239     border-style: none;
240     border-top-style: solid;
241 
242     height: 75px;
243     margin-left: -50px;
244     width: 250px;
245 }
246 
247 .lips-center-left {    
248     height: 40px;
249     margin-left: 10px;
250     overflow: hidden;
251     width: 40px;
252 }
253 
254 .lips-center-left-inside {
255     border-bottom-left-radius: 50% 50%;
256     border-bottom-right-radius: 50% 50%;
257     border-top:none;
258     border-left:none;
259     border-right:none;
260     content: " ";
261     display: block;
262     height: 45px;
263     margin-left: -30px;
264     margin-top: -36px;
265     width: 100px;
266 }
267 
268 .lips-center-right {
269     height: 40px;
270     overflow: hidden;
271     width: 40px;
272 }
273 
274 .lips-center-right-inside {
275     border-bottom-left-radius: 50%;
276     border-bottom-right-radius: 50%;
277     border-top:none;
278     border-left:none;
279     border-right:none;
280     content: " ";
281     display: block;
282     height: 45px;
283     margin-left: -34px;
284     margin-top: -37px;
285     width: 100px;
286 }
287 
288 .lips-left {
289     border-top-left-radius: 60% 50%;
290     border-top-right-radius: 0%;
291     border-bottom-left-radius: 75% 50%;
292     border-bottom-right-radius: 0%;
293     border-right: none;
294     height: 60px;
295     left: -22px;
296     top: -59px;
297     width: 40px;
298 
299     -webkit-transform: rotate(15deg) ;
300 }
301 
302 .lips-right {
303     border-top-right-radius: 55% 50%;
304     border-top-left-radius: 0%;
305     border-bottom-right-radius: 80% 50%;
306     border-bottom-left-radius: 0%;
307     border-left: none;
308     height: 60px;
309     right: -22px;
310     top: -59px;
311     width: 40px;
312 
313     -webkit-transform: rotate(-9deg) ;
314 }
315 
316 .mouth {
317     border-bottom-left-radius: 50% 100%;
318     border-bottom-right-radius: 50% 100%;
319     border-top: none;
320     height: 150px;
321     margin-top:-50px;
322     width: 240px;
323 }
324 
325 .tongue {
326     border-bottom-left-radius: 50% 100%;
327     border-bottom-right-radius: 50% 100%;
328     border-top: none;
329     height: 65px;
330     margin-left: 35px;
331     top: -30px;
332     overflow: hidden;
333     width: 170px;
334 }
335 
336 .tongue-left {
337     height: 65px;
338     margin-top: 20px;
339     margin-left: 15px;
340     overflow: hidden;
341     width: 80px;
342     z-index: 2;
343 }
344 
345 .tongue-left-inside {
346     border-top-left-radius: 50% 80%;
347     border-top-right-radius: 50% 80%;    
348     border-bottom: none;
349 
350     height: 65px;
351     width: 80px;
352     z-index: 2;
353 
354     -webkit-transform: rotate(-45deg);
355 }
356 
357 .tongue-right {    
358     height: 60px;
359     margin-top: -67px;
360     margin-left: 83px;
361     overflow: hidden;
362     width: 80px;
363     z-index: 3;
364 }
365 
366 .tongue-right-inside {
367     border-top-left-radius: 50% 80%;
368     border-top-right-radius: 50% 80%;    
369     border-bottom: none;
370     margin-top: 2px;
371     margin-left: -11px;
372     height: 60px;
373     width: 80px;
374     z-index: 3;
375 
376     -webkit-transform: rotate(45deg);
377 }
378 
379 .collar {
380     margin-top:-40px;
381     height: 40px;
382     width: 220px;
383     z-index: 3;
384 }
385 
386 .collar-inside {    
387     border: 20px solid rgb(216, 5, 23);
388     height: 50px;
389     margin-top: -50px;
390     margin-left: -19px;
391     width: 220px;
392 }
393 
394 .collor-border-top {
395     height: 55px;
396     margin-top: -38px;
397     margin-left: 0px;
398     width: 220px;
399 }
400 
401 .collor-border-bottom {
402     height: 73px;
403     margin-top: -75px;
404     margin-left: -17px;
405     width: 250px;
406 }
407 
408 .bell {
409     height: 53px;
410     margin-top: -15px;
411     width: 53px;
412     z-index: 5;
413 }
414 
415 .bell-middle-curve {
416     height: 50px;
417     width: 100px;
418 }
419 
420 .bell-middle-curve-1 {
421     margin-top: 12px;
422     margin-left:-27px;
423 }
424 
425 .bell-middle-curve-2 {
426     margin-top: -48px;
427     margin-left:-27px;
428 }
429 
430 .bell-hole {
431     height: 8px;
432     margin-top: -46px;
433     margin-left: 21px;
434     width: 8px;
435 }
436 
437 .bell-gap {
438     height: 16px;
439     margin-left: 26px;
440     width: 0px;
441 }
442 
443 .body {
444     height: 162px;
445     top: -65px;
446     width: 430px;
447     z-index: 1;
448 }
449 
450 .body-inside {
451     border-top-left-radius: 15% 75%;
452     border-top-right-radius: 12% 75%;
453     border-bottom-left-radius: 15% 50%;
454     border-bottom-right-radius: 25% 50%;
455     height: 180px;
456     margin-top: -5px;
457     width: 220px;
458     z-index: 2;
459 }
460 
461 .belly {
462     border-top-left-radius: 37% 50%;
463     border-top-right-radius: 37% 50%;
464     border-bottom-left-radius: 50% 50%;
465     border-bottom-right-radius: 50% 50%;
466     height: 125px;
467     margin-top: -165px;
468     width: 175px;
469     z-index: 10;
470 }
471 
472 .bag {
473     height: 75px;
474     margin-top: 50px;
475     padding-top: 5px;
476     width: 146px;
477 }
478 
479 .bag-top {
480     border-radius: 40%;
481     height: 40px;
482     margin-top: -42px;
483     margin-left: -20px;
484     width: 180px;
485 }
486 
487 .bag-bottom {
488     border-bottom-left-radius: 50% 32%;
489     border-bottom-right-radius: 50% 32%;
490     height: 140px;
491     margin-top: -83px;
492     margin-left: 0px;
493     width: 142px;
494 }
495 
496 .left-hand {
497     height: 80px;
498     margin-top: -139px;
499     margin-left: 25px;
500     width: 80px;
501     z-index: 0;
502 }
503 
504 .left-arm {
505     border-top-left-radius: 45% 40%;
506     border-bottom-left-radius: 45% 30%;
507     height: 45px;
508     margin-top: 33px;
509     margin-left: 40px;
510     width: 95px;
511     
512     -webkit-transform: rotate(-30deg);
513     -webkit-transform-origin: left bottom;
514 }
515 
516 .left-palm {
517     height: 45px;
518     margin-top: -50px;
519     margin-left: 10px;
520     width: 45px;
521 }
522 
523 .right-hand {
524     height: 80px;
525     margin-top: -115px;
526     margin-left: 225px;
527     width: 80px;
528     z-index: 0;
529 }
530 
531 .right-arm {
532     border-top-right-radius: 45% 40%;
533     border-bottom-right-radius: 45% 30%;
534     height: 45px;
535     margin-top: 33px;
536     margin-left: 40px;
537     width: 95px;
538     
539     -webkit-transform: rotate(30deg);
540     -webkit-transform-origin: right bottom;
541 }
542 
543 .right-palm {
544     height: 45px;
545     margin-top: -52px;
546     margin-left: 120px;
547     width: 45px;
548 }
549 
550 .left-leg {
551     height: 63px;
552     margin-top: 25px;
553     margin-left: 101px;
554     width: 120px;
555     z-index: 3;
556 }
557 
558 .left-leg-inside {
559     border-top-left-radius: 35% 100%;
560     border-bottom-left-radius: 25% 55%;
561     border-bottom-right-radius: 100% 20%;
562     border-right: none;
563     height: 55px;
564     margin-top: -16px;
565     width: 120px;
566 }
567 
568 .crotch {
569     height: 15px;
570     margin-top: -37px;
571     margin-left: 192px;
572     width: 40px;
573     z-index: 5;
574 }
575 
576 .crotch-inside {
577     border-top-left-radius: 50% 60%;
578     border-top-right-radius: 50% 60%;
579     border-bottom: none;
580     height: 50px;
581     width: 40px;
582 }
583 
584 .right-leg {
585     height: 63px;
586     margin-top: -62px;
587     margin-left: 209px;
588     width: 120px;
589     z-index: 3;
590 }
591 
592 .right-leg-inside {
593     border-top-right-radius: 35% 100%;
594     border-bottom-right-radius: 25% 55%;
595     border-bottom-left-radius: 100% 20%;
596     border-left: none;
597     height: 55px;
598     margin-top: -17px;
599     margin-left: -4px;
600     width: 120px;
601 }
602 
603 .left-foot {
604     border-top-left-radius: 60% 60%;
605     border-top-right-radius: 50% 85%;
606     border-bottom-left-radius: 43% 75%;    
607     border-bottom-right-radius: 50% 55%;
608     height: 50px;
609     margin-top: -32px;
610     margin-left: 72px;
611     width: 133px;
612 
613     -webkit-transform: rotate(-5deg);
614 }
615 
616 .right-foot {
617     border-top-left-radius: 50% 85%;
618     border-top-right-radius: 60% 60%;
619     border-bottom-left-radius: 50% 55%;
620     border-bottom-right-radius: 43% 75%;
621     height: 50px;
622     margin-top: -30px;
623     margin-left: 218px;
624     width: 133px;
625 
626     -webkit-transform: rotate(5deg);
627 }
View Code

(在这里再发一次demo链接, 希望可以省去你滚动回本文顶部的时间)

(至于画完这个接着做什么, 现在有几个想法可以做, 也可能做其他东西, 管他呢,随心而至就是了)

有任何问题或意见,欢迎交流。

如果发现本文有什么问题(如错别字),请不吝告知,谢谢。

转载请注明出处:[css]我要用css画幅画(七) - 哆啦A梦

原文地址:https://www.cnblogs.com/bee0060/p/5022302.html