当前位置:Gxlcms > html代码 > 用纯css3绘制的能自适应屏幕宽度的哆啦a梦动画

用纯css3绘制的能自适应屏幕宽度的哆啦a梦动画

时间:2021-07-01 10:21:17 帮助过:44人阅读

本人是学生,正在想深入学习html5css3,所以最近在研究用css3绘制矢量图,于是就用纯css3基于百分比方案绘制了能自适应浏览器宽度而自动变化比例的哆啦a梦动画,

动画的宽高比例为:”46.5“,动画理论上能基于”4:6.5“的宽高比例来无限放大且完美展示,但动画的最小宽高建议为:”150px243.75px“,因为动画的边框单位是”px“,

所以本人亲测证实大于或等于此宽高,动画的效果稳定且不变形,过小则会错位。

然后有部分表情动画是通过css伪类“:hover“来触发,这让哆啦A梦显得更有灵性,给人更好的体验。

PS:兼容css3的浏览器一般都可以正常观看,下面是网页截图:

哆啦a梦

一瞬间的灵感,近4小时的原型编码,4天时间的修改调整,成果全在下面,废话不多说了,直接给代码。

html 代码:

<div class="dlam">
    
    <div class="bozi">
        <div class="lingdan">
            <div class="xiaoyuan">div>
            <div class="shudiao">div>
        div>
    div>
    <div class="top">
         <div class="top-lian">
              <div class="top-yan1"><div class="p1"><div class="p4">div>div>div>
              <div class="top-yan2"><div class="p2"><div class="p4">div>div>div>
              <div class="top-bi1"><div class="p5">div>div>
              <div class="bixian"> <div class="bixian2">div>div>
              <div class="top-zui">
                    <div class="top-zui2">
                            <div class="top-bi2">div>
                    div>
              div>
              <div class="mao1">div>
              <div class="mao2">div>
              <div class="mao3">div>
              <div class="mao4">div>
              <div class="mao5">div>
              <div class="mao6">div>
         div>
    div>
    
  <div class="shengti">
    <div class="shoubi1"><div class="ctou1">div>div>
    <div class="duzi">
        <div class="koudai"><div class="xiaokoudai">div>div>
    div>
    <div class="shoubi2"><div class="ctou2">div>div>
    <div class="jiao1"><div class="jiaozi">div>div>
    <div class="jiao2"><div class="jiaozi">div>div>
  div>
    
div>

css 代码:

@media screen and (max-width: 200px) { 
.dlam {width: 150px;height:243.75px;} 

}
@media screen and (max-width: 400px) { 
.dlam {width: 200px;height:325px;} 

}

@media screen and (min-width: 400px) { 
.dlam {width: 200px;height:325px;}
  
}
@media screen and (min-width: 600px) { 
.dlam {width: 300px;height:487.5px;}
  
}

@media screen and (min-width: 1000px) { 
.dlam {width: 400px;height:650px;}
  
}

@media screen and (min-width: 2000px) { 
.dlam {width: 500px;height:778.5px;}
  
}
.dlam {
    border: 1px dashed #0C9;
    min-width: 150px;
    min-height: 243.75px;
    margin-top: 50px;
    margin-right: auto;
    margin-left: auto;
    overflow: hidden;
    border-radius: 10px;
    -moz-border-radius: 10px;
    -ms-border-radius: 10px;
    -o-border-radius: 10px;
    -webkit-border-radius: 10px;
    box-shadow: 0px 0px 10px 0px #666666;
    -moz-box-shadow: 0px 0px 10px 0px #666666;
    -ms-box-shadow: 0px 0px 3px 10px #666666;
    -o-box-shadow: 0px 0px 3px 10px #666666;
    -webkit-box-shadow: 0px 0px 10px 0px #666666;
    -webkit-transition: all 0.5s ease 0s;
    -moz-transition: all 0.5s ease 0s;
    -ms-transition: all 0.5s ease 0s;
    -o-transition: all 0.5s ease 0s;
    transition: all 0.5s ease 0s;
}
.top {
    cursor: pointer;
    height: 45%;
    width: 80%;
    position: relative;
    border: 2px solid #007EA8;
    border-radius: 9999px;
    -moz-border-radius: 9999px;
    -ms-border-radius: 9999px;
    -o-border-radius: 9999px;
    -webkit-border-radius: 9999px;
    left: 8.8%;
    top: 0%;
    background-color: #39C;
    overflow: hidden;
}
.top-lian {
    height: 80%;
    width: 80%;
    border: 2px solid #007EA8;
    position: relative;
    top: 20%;
    left: 10%;
    right: 10%;
    border-radius: 9999px;
    -moz-border-radius: 9999px;
    -ms-border-radius: 9999px;
    -o-border-radius: 9999px;
    -webkit-border-radius: 9999px;
    background-color: #FFF;
    box-shadow: 0px -5px 10px 0px #0085B0;
    -moz-box-shadow: 0px -5px 10px 0px #0085B0;
    -ms-box-shadow: 0px -5px 10px 0px #0085B0;
    -o-box-shadow: 0px -5px 10px 0px #0085B0;
    -webkit-box-shadow: 0px -5px 10px 0px #0085B0;
}

.p1{
    border-radius: 9999px;
    -moz-border-radius: 9999px;
    -ms-border-radius: 9999px;
    -o-border-radius: 9999px;
    -webkit-border-radius: 9999px;
    background-color: #333;
    height: 60%;
    width: 65%;
    position: relative;
    top:10%;
    left: 20%;
    -webkit-transition: all 0.5s ease 0s;
    -moz-transition: all 0.5s ease 0s;
    -ms-transition: all 0.5s ease 0s;
    -o-transition: all 0.5s ease 0s;
    transition: all 0.5s ease 0s;
    animation:pp1 5s ;
    -moz-animation:pp1 5s; /* Firefox */
    -webkit-animation:pp1 5s; /* Safari and Chrome */
    -ms-animation:pp1 5s; /* Opera */
    -o-animation:pp1 5s;
    -moz-animation-iteration-count:9999;
    -webkit-animation-iteration-count:9999;
    -ms-animation-iteration-count:9999;
    -o-animation-iteration-count:9999;
    animation-iteration-count:9999;
    }
@keyframes pp1{
    0%{top: 15%;left: 20%;height: 60%;width: 65%;}
    20%{top: 4%;left: 20%;height: 60%;width: 65%;}
    40%{top: 10%;left: 40%;height: 60%;width: 65%;}
    60%{top: 15%;left: 20%;height: 60%;width: 65%;}
    80%{top: 40%;left: 30%;height: 15%;width: 65%;}
    85%{top: 15%;left: 5%;height: 60%;width: 65%;}
    90%{top: 10%;left: 20%;height: 60%;width: 65%;}
    100%{top: 15%;left: 20%;height: 60%;width: 65%;}
    }
@-moz-keyframes pp1{
    0%{top: 15%;left: 20%;height: 60%;width: 65%;}
    20%{top: 4%;left: 20%;height: 60%;width: 65%;}
    40%{top: 10%;left: 40%;height: 60%;width: 65%;}
    60%{top: 15%;left: 20%;height: 60%;width: 65%;}
    80%{top: 40%;left: 30%;height: 15%;width: 65%;}
    85%{top: 15%;left: 5%;height: 60%;width: 65%;}
    90%{top: 10%;left: 20%;height: 60%;width: 65%;}
    100%{top: 15%;left: 20%;height: 60%;width: 65%;}
    }
@-webkit-keyframes pp1{
    0%{top: 15%;left: 20%;height: 60%;width: 65%;}
    20%{top: 4%;left: 20%;height: 60%;width: 65%;}
    40%{top: 10%;left: 40%;height: 60%;width: 65%;}
    60%{top: 15%;left: 20%;height: 60%;width: 65%;}
    80%{top: 40%;left: 30%;height: 15%;width: 65%;}
    85%{top: 15%;left: 5%;height: 60%;width: 65%;}
    90%{top: 10%;left: 20%;height: 60%;width: 65%;}
    100%{top: 15%;left: 20%;height: 60%;width: 65%;}
    }
@-o-keyframes pp1{
    0%{top: 15%;left: 20%;height: 60%;width: 65%;}
    20%{top: 4%;left: 20%;height: 60%;width: 65%;}
    40%{top: 10%;left: 40%;height: 60%;width: 65%;}
    60%{top: 15%;left: 20%;height: 60%;width: 65%;}
    80%{top: 40%;left: 30%;height: 15%;width: 65%;}
    85%{top: 15%;left: 5%;height: 60%;width: 65%;}
    90%{top: 10%;left: 20%;height: 60%;width: 65%;}
    100%{top: 15%;left: 20%;height: 60%;width: 65%;}
    }
@-ms-keyframes pp1{
    0%{top: 15%;left: 20%;height: 60%;width: 65%;}
    20%{top: 4%;left: 20%;height: 60%;width: 65%;}
    40%{top: 10%;left: 40%;height: 60%;width: 65%;}
    60%{top: 15%;left: 20%;height: 60%;width: 65%;}
    80%{top: 40%;left: 30%;height: 15%;width: 65%;}
    85%{top: 15%;left: 5%;height: 60%;width: 65%;}
    90%{top: 10%;left: 20%;height: 60%;width: 65%;}
    100%{top: 15%;left: 20%;height: 60%;width: 65%;}
    }
.p2{
    border-radius: 9999px;
    -webkit-border-radius:9999px;
    -moz-border-radius:9999px;
    -ms-border-radius:9999px;
    -o-border-radius:9999px;
    background-color: #333;
    height: 60%;
    width: 65%;
    position: relative;
    top:10%;
    left: 20%;
    -webkit-transition: all 0.5s ease 0s;
    -moz-transition: all 0.5s ease 0s;
    -ms-transition: all 0.5s ease 0s;
    -o-transition: all 0.5s ease 0s;
    transition: all 0.5s ease 0s;
    animation:pp1 5s ;
    -moz-animation:pp1 5s; /* Firefox */
    -webkit-animation:pp1 5s; /* Safari and Chrome */
    -ms-animation:pp1 5s; 
    -o-animation:pp1 5s;/* Opera */
    -moz-animation-iteration-count:9999;
    -webkit-animation-iteration-count:9999;
    -o-animation-iteration-count:9999;
    -ms-animation-iteration-count:9999;
    animation-iteration-count:9999;
    }
.top-yan1 {
    background-color: #FFF;
    height: 25%;
    width: 20%;
    border: 2px solid #333;
    border-radius: 9999px;
    -moz-border-radius: 9999px;
    -ms-border-radius: 9999px;
    -o-border-radius: 9999px;
    -webkit-border-radius: 9999px;
    float: left;
    margin-top: -10%;
    margin-right: 0%;
    margin-left: 25%;
    overflow: hidden;
}
.top-yan1:hover .p1{
    top:30%;}

.top-yan2 {
    background-color: #FFF;
    height: 25%;
    width: 20%;
    border: 2px solid #333;
    border-radius: 9999px;
    -moz-border-radius: 9999px;
    -ms-border-radius: 9999px;
    -o-border-radius: 9999px;
    -webkit-border-radius: 9999px;
    float: left;
    margin-top: -10%;
    margin-right: 0%;
    margin-left: 3%;
    overflow: hidden;
}
.p4{
    height: 25%;
    width: 22%;
    border-radius: 9999px;
    -moz-border-radius: 9999px;
    -ms-border-radius: 9999px;
    -o-border-radius: 9999px;
    -webkit-border-radius: 9999px;
    background-color: #FFF;
    box-shadow: 0px 0px 3px 0px #FFFFFF;
    -webkit-box-shadow: 0px 0px 3px 0px #FFFFFF;
    -moz-box-shadow: 0px 0px 3px 0px #FFFFFF;
    -ms-box-shadow: 0px 0px 3px 0px #FFFFFF;
    -o-box-shadow: 0px 0px 3px 0px #FFFFFF;
    position: relative;
    left: 60%;
    top: 40%;
    right: auto;
    }
.top-yan2:hover .p2{
    top:30%;}
.top-lian:hover .p1{
    top:35%;
    left:30%;}
.top-lian:hover .p2{
    top:35%;
    left:6%;}
.top-bi1 {
    background-color: #FF5353;
    float: left;
    height: 15%;
    width: 15%;
    border: 2px solid #F33;
    margin-top: 12%;
    margin-right: 36%;
    margin-left: 42%;
    border-radius: 9999px;
    -moz-border-radius: 9999px;
    -ms-border-radius: 9999px;
    -o-border-radius: 9999px;
    -webkit-border-radius: 9999px;
    -webkit-transition: all 0.5s ease 0s;
    -moz-transition: all 0.5s ease 0s;
    -ms-transition: all 0.5s ease 0s;
    -o-transition: all 0.5s ease 0s;
    transition: all 0.5s ease 0s;
    box-shadow: 0px 0px 3px 0px #666666;
    -webkit-box-shadow: 0px 0px 3px 0px #666666;
    -moz-box-shadow: 0px 0px 3px 0px #666666;
    -ms-box-shadow: 0px 0px 3px 0px #666666;
    -o-box-shadow: 0px 0px 3px 0px #666666;
}
.top-bi1:hover{
    box-shadow: 0px 0px 5px 0px #FFE064;
    -webkit-box-shadow: 0px 0px 5px 0px #FFE064;
    -moz-box-shadow: 0px 0px 5px 0px #FFE064;
    -ms-box-shadow: 0px 0px 5px 0px #FFE064;
    -o-box-shadow: 0px 0px 5px 0px #FFE064;
    }
.p5{
    height: 30%;
    width: 25%;
    border-radius: 9999px;
    -moz-border-radius: 9999px;
    -ms-border-radius: 9999px;
    -o-border-radius: 9999px;
    -webkit-border-radius: 9999px;
    background-color: #FFDBDB;
    box-shadow: 0px 0px 6px 0px #FFFFFF;
    -webkit-box-shadow: 0px 0px 6px 0px #FFFFFF;
    -moz-box-shadow: 0px 0px 6px 0px #FFFFFF;
    -ms-box-shadow: 0px 0px 6px 0px #FFFFFF;
    -o-box-shadow: 0px 0px 6px 0px #FFFFFF;
    position: relative;
    left: 50%;
    top: 40%;
    }
.top-bi2 {
    background-color: #FF5353;
    height: 100%;
    width: 0%;
    margin-top: 0%;
    margin-left: auto;
    margin-right: auto;
    -webkit-transition: all 0.7s ease 0s;
    -moz-transition: all 0.7s ease 0s;
    -ms-transition: all 0.7s ease 0s;
    -o-transition: all 0.7s ease 0s;
    transition: all 0.7s ease 0s;
    border-right-width: 1px;
    border-left-width: 1px;
    border-top-style: none;
    border-right-style: solid;
    border-bottom-style: none;
    border-left-style: solid;
    border-right-color: #C30;
    border-left-color: #C30;
}
.top-zui {
    background-color: #FF4848;
    float: left;
    height: 20%;
    width: 40%;
    margin-top: 0%;
    margin-right: 30%;
    margin-left: 30%;
    border-radius: 0px 0px 9999px 9999px;
    -webkit-border-radius:0px 0px 9999px 9999px;
    -moz-border-radius:0px 0px 9999px 9999px;
    -ms-border-radius:0px 0px 9999px 9999px;
    -o-border-radius:0px 0px 9999px 9999px;
    -webkit-transition: all 0.7s ease 0s;
    -moz-transition: all 0.7s ease 0s;
    -ms-transition: all 0.7s ease 0s;
    -o-transition: all 0.7s ease 0s;
    transition: all 0.7s ease 0s;
    border-bottom-width: 2px;
    border-bottom-style: solid;
    border-bottom-color: #C30;
    border-right-width: 2px;
    border-left-width: 2px;
    border-right-style: solid;
    border-left-style: solid;
    border-right-color: #C30;
    border-left-color: #C30;
}
.bixian {
    height: 13%;
    width: 100%;
    float: left;
    padding: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 2px;
}
.bixian2 {
    background-color: #FF4848;
    height: 100%;
    width: 0%;
    margin-top: 0px;
    margin-right: auto;
    margin-left: auto;
    border-right-width: 1px;
    border-left-width: 1px;
    border-top-style: none;
    border-right-style: solid;
    border-bottom-style: none;
    border-left-style: solid;
    border-right-color: #D2380B;
    border-left-color: #D2380B;
}
.top-zui2{
    float: left;
    height: 35%;
    width: 100%;
    border-radius: 0px 0px 9999px 9999px;
    -webkit-border-radius:0px 0px 9999px 9999px;
    -moz-border-radius:0px 0px 9999px 9999px;
    -ms-border-radius:0px 0px 9999px 9999px;
    -o-border-radius:0px 0px 9999px 9999px;
    background-color: #FFFFFF;
    -webkit-transition: all 0.7s ease 0s;
    -moz-transition: all 0.7s ease 0s;
    -ms-transition: all 0.7s ease 0s;
    -o-transition: all 0.7s ease 0s;
    transition: all 0.7s ease 0s;
    border-right-width: 2px;
    border-bottom-width: 2px;
    border-left-width: 2px;
    border-top-style: none;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-right-color: #C30;
    border-bottom-color: #C30;
    border-left-color: #C30;
    margin-left: -2px;
    margin-top: -1px;
    }
.top-zui:hover{
    height: 20%;
    width: 60%;
    height: 30%;
    margin-right: 20%;
    margin-left: 20%;
    }
.top-zui:hover .top-bi2 {
    background-color: #FF5353;
    height: 100%;
    width: 0%;
    margin-top: 0%;
    margin-left: auto;
    margin-right: auto;
}
.top-zui:hover .p3{
    border-radius:0px;
    background-color: #F00;
    height: 30%;
    width: 65%;
    position: relative;
    top: 10%;
    left: 20%;
    }    
.top-zui:hover .top-zui2{
    height: 10%;
    }
.mao1,.mao2,.mao3,.mao4,.mao5,.mao6{
    background-color: #369;
    height: 30%;
    width: 2%;
    position: relative;
    -webkit-transition: all 0.5s ease 0s;
    -moz-transition: all 0.5s ease 0s;
    -ms-transition: all 0.5s ease 0s;
    -o-transition: all 0.5s ease 0s;
    transition: all 0.5s ease 0s;
    }
.mao1{
    top: 20%;
    left: 5%;
    transform:rotate(-60deg);
    -webkit-transform:rotate(-60deg);
    -moz-transform:rotate(-60deg);
    -ms-transform:rotate(-60deg);
    -o-transform:rotate(-60deg);
}

                  

	 	
                    
                    
                    
                    
                    
                

人气教程排行