六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網(wǎng)中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

分享html打造動畫哆啦A夢的示例代碼

[摘要]我相信每個人的童年都有一個哆啦a夢,一個小小的肚皮里裝滿了不可思議的哆啦a夢,一個在你無助傷心的時候陪在你身邊的哆啦a夢,一個陪你胡思亂想陪你吃銅鑼燒的哆啦a夢~今天我們就來畫一個我們心中的哆啦a夢吧~ 定義哆啦a夢的容器千篇一律先定義一個畫哆啦a夢的大容器,確定它的大小和位置。<!-- 哆...
我相信每個人的童年都有一個哆啦a夢,一個小小的肚皮里裝滿了不可思議的哆啦a夢,一個在你無助傷心的時候陪在你身邊的哆啦a夢,一個陪你胡思亂想陪你吃銅鑼燒的哆啦a夢~今天我們就來畫一個我們心中的哆啦a夢吧~

html打造動畫【系列4】哆啦A夢0

定義哆啦a夢的容器

  • 千篇一律先定義一個畫哆啦a夢的大容器,確定它的大小和位置。

    <!-- 哆啦A夢大容器 -->
    <p class="doa"></p>
    /*哆啦A夢*/
     .doa{position: relative;top: 100px;}
  • 畫哆啦a夢的頭部(包括臉,臉部包括眼睛和鼻子)

  • 頭部包含好幾塊部分:哆啦a夢的臉部和鼻子,臉部又包括兩只眼睛,兩只眼睛里面還有眼珠和眼白部分,所以會有好幾層的dom嵌套,當然基本圖形都是由p+border-radius拼湊而成。

  • 將畫好的各個部位品拼湊到相應的位置上即可。

  • 看我前面畫的幾個圖畫就知道border-radius是一個非常常用的屬性,幾乎p的每一次變形都離不開它,其實border-radius的真面目應該是border-radius: 300px 300px 300px 300px/300px 300px 300px 300px;醬紫的,我們一般不寫斜杠后面的內容,斜杠切面是水平長度,斜杠后面是垂直高度,前杠后面默認不寫就是水平和垂直大小是一樣的。我知道我這樣說不夠詳細,可以參考我鑫神的博客秋月何時了,CSS3 border-radius知多少?,保證你分分鐘在老司機的帶領下徹底弄懂border-radius,還不快上車?

    <!-- 頭 -->    
      <p class="head">
     <!-- 存放臉部的容器 -->
     <p class="face">
     <!-- 左眼大圈兒 -->
     <p>
     <!-- 左眼眼珠(黑色部分) -->
     <p>
     <!-- 左眼眼白,黑色里面的白色部分 -->
     <p></p>
     </p>
     </p>
     <!-- 右眼大圈兒 -->
     <p>
     <!--右眼眼珠(黑色部分) -->
     <p>
     <!-- 右眼眼白,黑色里面的白色部分 -->
     <p></p>
     </p>
     </p>
     </p>
     <!-- 紅鼻子部分 -->
     <p class="nose">
     <!-- 紅鼻子里面的白圈兒 -->
     <p></p>
     </p>
     <!-- 紅鼻子下面的那根黑線,也屬于鼻子部分 -->
     <p class="nose1"></p>
     </p>
    .head{
     margin: 0 auto; /*頭部定義大小并居中顯示*/
     width: 400px;
     height: 350px;
     background: #008ee3; /*頭部定義背景顏色*/
     position: relative;
     border-radius: 50% 50% 25% 25% / 55% 55% 45% 45%; /*頭部定義四個方向圓角大小*/
     }
     .face{
     width: 310px; /*臉部定義大小*/
     height: 260px;
     background: snow; /*臉部定義背景顏色*/
     border-radius: 50% 50% 25% 25% / 55% 55% 45% 45%; /*臉部定義四個方向的圓角大小*/
     position: relative; /*臉部定義位置,是相對于head的位置*/
     top: 90px;
     left: 45px;
     }
     /*左眼眶*/
     .face>p:first-child{
     width: 80px; /*左眼框定義大小*/
     height: 100px;
     border-radius: 50%; /*左眼框定義與圓角大小*/
     border:2px #000 solid; /*定義外邊框*/
     background: snow;
     float: left; /*為了使左右兩個眼睛能在一排顯示*/
     position: relative; /*位置是相對于face的位置*/
     top:-40px;
     left: 71px;
     z-index: 50;
     }
     /*右眼眶,畫法跟左眼一樣*/
     .face>p:last-child{
     width: 80px;
     height: 100px;
     border-radius: 50%;
     border:2px #000 solid;
     background: snow;
     float: left;
     position: relative;
     top:-40px;
     left: 71px;
     z-index: 50;
     }
     /*左眼珠1*/
     .face>p:first-child p{
     width: 20px; /*定義眼珠的大小*/
     height: 25px;
     background: #000;
     border-radius: 50%;
     position: absolute; /*定義眼珠的位置,相對于眼眶的位置*/
     top: 45px;
     left: 60px;
     }
     /*左瞳孔*/
     .face>p:first-child p p{
     width: 10px; /*定義黑色瞳孔的大小*/
     height: 10px;
     background: #ffffff;
     border-radius: 50%;
     position: absolute; /*定義黑色瞳孔的位置,相對于眼珠的位置*/
     top: 7px;
     left: 10px;
     }
     /*右眼珠和左眼珠畫法一樣*/
     .face>p:last-child p{
     width: 20px;
     height: 25px;
     background: #000;
     border-radius: 50%;
     position: absolute;
     top: 45px;
     }
     /*右瞳孔和左瞳孔的畫法一樣*/
     .face>p:last-child p p{
     width: 10px;
     height: 10px;
     background: #ffffff;
     border-radius: 50%;
     position: absolute;
     top: 7px;
     }
     .nose{
     width: 30px; /*定義紅鼻子的大小*/
     height: 30px;
     border-radius: 50%;
     background: #c70000;
     position: absolute;
     top: 130px;
     left: 50%;
     margin-left: -15px;
     z-index: 10;
     }
     .nose p{
     width: 10px; /*定義紅鼻子里面白色圈圈的大小*/
     height: 10px;
     border-radius: 50%;
     position: absolute;
     background: #ffffff;
     top: 10px;
     margin-left: 20px;
     z-index: 10;
     }
     .nose1{
     width: 2px; /*定義紅鼻子下面的那一條黑線*/
     height: 130px;
     background: #000;
     position: absolute;
     top: 160px;
     left: 50%;
     margin-left: -1px;
     z-index: 10;
     }
  • html打造動畫【系列4】哆啦A夢1

    哆啦a夢的頭部.png

  • 畫哆啦a夢的嘴巴部分

  • 嘴巴應該是很簡單的了吧,看一眼就知道是是用邊框+border-radius實現(xiàn)的。

    <p class="mouth"></p>
    .mouth{
     width: 250px; /*定義嘴巴的大小*/
     height: 200px;
     border-radius: 50%;
     background: snow;
     border-bottom: 2px #000 solid;
     margin: -230px auto;
     position: relative; /*定義嘴巴的位置*/
     }

    html打造動畫【系列4】哆啦A夢2

    哆啦a夢的嘴巴.png

  • 畫哆啦a夢的胡須部分

  • 胡須部分其實在上一篇文章畫html打造動畫【連載3】- 小貓笑臉動畫里面畫胡須的時候就已經(jīng)介紹了畫胡須的方法,在這里就不贅述了,基本思路都是一樣的。

    <!-- 胡須 -->
      <p class="beard">
     <!-- 左邊胡須部分 -->
     <p class="left">
     <!-- 第一根胡須 -->
     <p></p>
     <!-- 第二根胡須 -->
     <p></p>
     <!-- 第三根胡須 -->
     <p></p>
     </p>
     <p class="right">
     <p></p>
     <p></p>
     <p></p>
     </p>
     <!-- 脖子部分的小白條部分 -->
     <span></span>
     </p>
    /*胡須樣式*/
    .beard .left p:first-child{
     width: 120px;
     height: 40px;
     border-top: 2px #000 solid;
     border-radius: 10% 90% 10% 90% / 10% 90% 10% 90%;
     position: absolute;
     left: 50%;
     top: 140px;
     margin-left: -170px;
     z-index: 100;
     }
     .beard .left p:nth-child(2){
     width: 120px;
     height: 40px;
     border-top: 2px #000 solid;
     border-radius: 10% 90% 10% 90% / 30% 70% 40% 60%;
     position: absolute;
     left: 50%;
     top: 170px;
     margin-left: -170px;
     z-index: 100;
     }
     .beard .left p:last-child{
     width: 120px;
     height: 40px;
     border-top: 2px #000 solid;
     border-radius: 10% 90% 10% 90% / 40% 60% 10% 90%;
     position: absolute;
     left: 50%;
     top: 200px;
     margin-left: -170px;
     z-index: 100;
     }
    
     .beard .right p:first-child{
     width: 120px;
     height: 40px;
     border-top: 2px #000 solid;
     border-radius: 90% 10% 90% 10% / 90% 10% 90% 10%;
     position: absolute;
     left: 50%;
     top: 140px;
     margin-left: 50px;
     z-index: 100;
     }
     .beard .right p:nth-child(2){
     width: 120px;
     height: 40px;
     border-top: 2px #000 solid;
     border-radius: 90% 10% 90% 10% / 70% 30% 60% 40%;
     position: absolute;
     left: 50%;
     top: 170px;
     margin-left: 50px;
     z-index: 100;
     }
     .beard .right p:last-child{
     width: 120px;
     height: 40px;
     border-top: 2px #000 solid;
     border-radius: 90% 10% 90% 10% / 60% 40% 90% 10%;
     position: absolute;
     left: 50%;
     top: 200px;
     margin-left: 50px;
     z-index: 100;
     }
     .beard span{
     display: block;
     width: 60px;
     height: 3.5px;
     background: #ffffff;
     border-radius: 4px;
     position: absolute;
     top: 352px;
     left: 50%;
     margin-left: -105px;
     }

    html打造動畫【系列4】哆啦A夢3

    哆啦a夢的胡須.png

  • 畫哆啦a夢的脖子部分(脖子部分包括鈴鐺)

  • 脖子就是基本p變形之后的圖形,多余的部分隱藏到頭部下面就可以了。

  • 鈴鐺部分是各個很簡單的基本圖形組成。

    <!-- 脖 -->
      <p class="neck">
     <!-- 鈴鐺的圓形 -->
     <p></p>
     <!-- 鈴鐺的小圓角矩形 -->
     <p></p>
     <!-- 鈴鐺的小圓形 -->
     <p></p>
     <!-- 鈴鐺的小豎線 -->
     <p></p>
     </p>
    .neck{
     width: 330px;
     height: 200px;
     border-radius: 50% 50% 20% 20% / 50% 50% 50% 50%;
     background: #e30000;
     margin: 80px auto;
     z-index: 100;
     }
     .neck p:first-child{
     border: 2px #000 solid;
     border-radius: 50%;
     width: 40px;
     height: 40px;
     background: #ffdd2e;
     position: absolute;
     top: 350px;
     left: 50%;
     margin-left: -22px;
     transition: all 1s;
     }
     .neck p:nth-child(2){
     border: 2px #000 solid;
     width: 44px;
     height: 5px;
     background: #ffdd2e;
     position: absolute;
     left: 50%;
     margin-left: -24px;
     top: 363px;
     border-radius: 5px;
     transition: all 1s;
     }
     .neck p:nth-child(3){
     width: 8px;
     height: 8px;
     border: 2px #000 solid;
     position: absolute;
     background: #6c5844;
     border-radius: 50%;
     left: 50%;
     margin-left: -6px;
     top: 375px;
     transition: all 1s;
     }
     .neck p:nth-child(4){
     width: 2px;
     height: 8px;
     background: #000;
     position: absolute;
     left: 50%;
     margin-left: -1px;
     top: 385px;
     transition: all 1s;
     }

    html打造動畫【系列4】哆啦A夢4

    哆啦a夢的脖子.png

  • 完成哆啦a夢的動態(tài)效果

  • 動起來的哆啦a夢才比較萌對吧,那我們就讓它動起來吧(transition屬性)。

  • 鼠標移動到眼睛部位左眼珠移動到左邊。

  • 鼠標移動到嘴巴部位,臉部表情變化。

  • 鼠標移動到鈴鐺部分,鈴鐺變大。

    /*眼睛動效*/
    .head:hover .face>p:first-child p{
     left: 0px;
     transition: all 1s;
     }
     .head:hover .face>p:first-child p p{
     left: 0px;
     transition: all 1s;
     }
    /*嘴巴動效,嘴巴的dom容器下面要加了個空的p容器*/
    .mouth p:first-child{
     width: 82px;
     height: 2px;
     background: #000;
     position: absolute;
     z-index: 1000;
     top: -25px;
     left: 6px;
     display: none;
     }
     .mouth p:nth-child(2){
     width: 82px;
     height: 2px;
     background: #000;
     position: absolute;
     z-index: 1000;
     top: -25px;
     left: 90px;
     display: none;
     }
     .mouth:hover{
     border-radius: 0;
     width: 180px;
     height: 200px;
     }
     .mouth:hover p:first-child,.mouth:hover p:nth-child(2){
     display: block;
     }
    /*鈴鐺動效*/
    .neck:hover p:first-child{
     width: 60px;
     height: 60px;
     left: 50%;
     margin-left: -30px;
     }
     .neck:hover p:nth-child(2){
     width: 66px;
     height: 7.5px;
     left: 50%;
     margin-left: -33px;
     }
     .neck:hover p:nth-child(3){
     width: 12px;
     height: 12px;
     left: 50%;
     margin-left: -6px;
     top: 385px;
     }
     .neck:hover p:nth-child(4){
     width: 2px;
     height: 12px;
     left: 50%;
     margin-left: 1px;
     top: 400px;
     }

    html打造動畫【系列4】哆啦A夢5

以上就是分享html打造動畫哆啦A夢的示例代碼的詳細內容,更多請關注php中文網(wǎng)其它相關文章!


網(wǎng)站建設是一個廣義的術語,涵蓋了許多不同的技能和學科中所使用的生產(chǎn)和維護的網(wǎng)站。




主站蜘蛛池模板: 杨幂国产精品福利在线观看 | 欧美无遮挡一区二区三区 | 亚欧免费视频一区二区三区 | 亚洲精品乱码久久久久久麻豆 | 伊人婷婷在线 | 四虎精品久久久久影院 | 欧美亚洲中日韩中文字幕在线 | 香蕉久久夜色精品国产小说 | 亚洲国产亚洲综合在线尤物 | 亚洲第二十页 | 日韩射| 青娱乐国产精品视频 | 最近免费的中文字幕一 | 天天热天天干 | 日本一二区在线观看 | 色综合久久天天综合 | 午夜5060网| 四虎性 | 青青青视频在线免费观看 | 在线视频一区二区三区 | 日本大片在线看 | 亚洲乱亚洲23p女 | 日本高清在线一区二区三区 | 午夜成人免费视频 | 日韩美香港a一级毛片 | 午夜精| 天堂网在线最新版www | 婷婷射丁香 | 日韩欧美视频免费观看 | 亚洲国产成人久久综合一区 | 亚洲二区在线观看 | 色羞羞 | 一级毛片一级毛片一级毛片一级毛片 | 欧洲精品视频完整版在线 | 特级片在线观看 | 日韩精品一区二区三区高清 | 日韩美女免费线视频网址 | 亚洲三级在线观看 | 午夜特片网 | 手机看片国产精品 | 欧美在线免费播放 |