html5开发三八女王节表白神器
程序员文章站
2023-11-16 16:38:22
一年一度的三八女王节马上来临,今天小编基于html5给大家开发一个表白神器,做一个 浪漫的程序猿,具体代码大家参考下本文... 18-03-07...
效果图如下所示:
开发三八女王节表白神器运用到的知识点:css33d场景、3d变换、爱心制作技巧、3d立方*作技巧、自定义动画,原生js dom节点操作、循环等。
:point_down:html代码:
<div id="display"> </div> <div class='heart3d'> <div class='rib1'></div> <div class='rib2'></div> <div class='rib3'></div> <div class='rib4'></div> <div class='rib5'></div> <div class='rib6'></div> <div class='rib7'></div> <div class='rib8'></div> <div class='rib9'></div> <div class='rib10'></div> <div class='rib11'></div> <div class='rib12'></div> <div class='rib13'></div> <div class='rib14'></div> <div class='rib15'></div> <div class='rib16'></div> <div class='rib17'></div> <div class='rib18'></div> <div class='rib19'></div> <div class='rib20'></div> <div class='rib21'></div> <div class='rib22'></div> <div class='rib23'></div> <div class='rib24'></div> <div class='rib25'></div> <div class='rib26'></div> <div class='rib27'></div> <div class='rib28'></div> <div class='rib29'></div> <div class='rib30'></div> <div class='rib31'></div> <div class='rib32'></div> <div class='rib33'></div> <div class='rib34'></div> <div class='rib35'></div> <div class='rib36'></div> <div class="per"> <div class="img"><img width="50" height="50" src="images/1.jpg" /></div> <div class="img"><img width="50" height="50" src="images/2.jpg" /></div> <div class="img"><img width="50" height="50" src="images/3.jpg" /></div> <div class="img"><img width="50" height="50" src="images/4.jpg" /></div> <div class="img"><img width="50" height="50" src="images/5.jpg" /></div> <div class="img"><img width="50" height="50" src="images/6.jpg" /></div> </div> </div>
:point_down:css代码:
<style>/*css样式表的衣柜*/ *{margin:0px;padding:0px;}/*去除默认外边距、内边距*/ body{background:#000;} .heart3d { position: absolute; top: 0; right: 0; bottom: 0; left: 0; margin: auto; width: 100px; height: 160px; transform-origin:center center center; transform-style: preserve-3d; animation: spin 15s infinite linear; } #display{width:200px;color:white;font-size:24px;white-space:normal;text-indent:55px;position:absolute;left:100px;top:100px;} .heart3d [class^="rib"] { position: absolute; width: 100px; height: 160px; border: solid #f22613; border-width: 1px 1px 0 0; border-radius: 50% 50% 0 / 40% 50% 0; } .heart3d [class$="1"] { transform: rotatey(10deg) rotatez(45deg) translatex(30px); } .heart3d [class$="2"] { transform: rotatey(20deg) rotatez(45deg) translatex(30px); } .heart3d [class$="3"] { transform: rotatey(30deg) rotatez(45deg) translatex(30px); } .heart3d [class$="4"] { transform: rotatey(40deg) rotatez(45deg) translatex(30px); } .heart3d [class$="5"] { transform: rotatey(50deg) rotatez(45deg) translatex(30px); } .heart3d [class$="6"] { transform: rotatey(60deg) rotatez(45deg) translatex(30px); } .heart3d [class$="7"] { transform: rotatey(70deg) rotatez(45deg) translatex(30px); } .heart3d [class$="8"] { transform: rotatey(80deg) rotatez(45deg) translatex(30px); } .heart3d [class$="9"] { transform: rotatey(90deg) rotatez(45deg) translatex(30px); } .heart3d [class$="10"] { transform: rotatey(100deg) rotatez(45deg) translatex(30px); } .heart3d [class$="11"] { transform: rotatey(110deg) rotatez(45deg) translatex(30px); } .heart3d [class$="12"] { transform: rotatey(120deg) rotatez(45deg) translatex(30px); } .heart3d [class$="13"] { transform: rotatey(130deg) rotatez(45deg) translatex(30px); } .heart3d [class$="14"] { transform: rotatey(140deg) rotatez(45deg) translatex(30px); } .heart3d [class$="15"] { transform: rotatey(150deg) rotatez(45deg) translatex(30px); } .heart3d [class$="16"] { transform: rotatey(160deg) rotatez(45deg) translatex(30px); } .heart3d [class$="17"] { transform: rotatey(170deg) rotatez(45deg) translatex(30px); } .heart3d [class$="18"] { transform: rotatey(180deg) rotatez(45deg) translatex(30px); } .heart3d [class$="19"] { transform: rotatey(190deg) rotatez(45deg) translatex(30px); } .heart3d [class$="20"] { transform: rotatey(200deg) rotatez(45deg) translatex(30px); } .heart3d [class$="21"] { transform: rotatey(210deg) rotatez(45deg) translatex(30px); } .heart3d [class$="22"] { transform: rotatey(220deg) rotatez(45deg) translatex(30px); } .heart3d [class$="23"] { -webkit-transform: rotatey(230deg) rotatez(45deg) translatex(30px); transform: rotatey(230deg) rotatez(45deg) translatex(30px); } .heart3d [class$="24"] { transform: rotatey(240deg) rotatez(45deg) translatex(30px); } .heart3d [class$="25"] { transform: rotatey(250deg) rotatez(45deg) translatex(30px); } .heart3d [class$="26"] { transform: rotatey(260deg) rotatez(45deg) translatex(30px); } .heart3d [class$="27"] { transform: rotatey(270deg) rotatez(45deg) translatex(30px); } .heart3d [class$="28"] { transform: rotatey(280deg) rotatez(45deg) translatex(30px); } .heart3d [class$="29"] { transform: rotatey(290deg) rotatez(45deg) translatex(30px); } .heart3d [class$="30"] { transform: rotatey(300deg) rotatez(45deg) translatex(30px); } .heart3d [class$="31"] { transform: rotatey(310deg) rotatez(45deg) translatex(30px); } .heart3d [class$="32"] { transform: rotatey(320deg) rotatez(45deg) translatex(30px); } .heart3d [class$="33"] { transform: rotatey(330deg) rotatez(45deg) translatex(30px); } .heart3d [class$="34"] { transform: rotatey(340deg) rotatez(45deg) translatex(30px); } .heart3d [class$="35"] { transform: rotatey(350deg) rotatez(45deg) translatex(30px); } .heart3d [class$="36"] { transform: rotatey(360deg) rotatez(45deg) translatex(30px); } @keyframes spin { to { transform: rotatey(360deg) rotatex(360deg); } } .per{ width:50px;height:50px;position:absolute;top:0;left:0;right:0;bottom:0; margin:auto;transform-style: preserve-3d;perspective:800px; } .img{width:50px;height:50px;position:absolute;backface-visibility:hidden; } .img:nth-child(1){top:-50px;left:0;transform-origin:bottom; transform:translatez(30px) rotatex(90deg);} .img:nth-child(2){top:50px;left:0;transform-origin:top; transform:translatez(30px) rotatex(-90deg);} .img:nth-child(3){top:0px;left:-50px;transform-origin:right; transform:translatez(30px) rotatey(-90deg);} .img:nth-child(4){top:0px;left:50px;transform-origin:left; transform:translatez(30px) rotatey(90deg);} .img:nth-child(6){top:0px;left:0;transform:translatez(30px);} .img:nth-child(5){top:0px;left:0;transform:translatez(0px);} </style>
:point_down:javascript代码:
<script> var i = 0; var str1 = "对于一个网页制作者来说,对html语言一定不会感到陌生,因为html语言是所有网页制作的基础。但是如果页面能够方便网友们的使用,友好而大方,甚至像桌面应用程序一样,那么仅仅依靠html语言是不够的,javascript在这其中扮演着重要的角色。"; var str ="如果,爱一个人,守一份爱情,可以在早春一起去踏青,可以在盛夏一起去赏荷,可以在浅秋一起去观月,可以在深冬一起去寻梅,不厌倦,却欢乐,不平凡,却平淡。那么,此生便无憾了。"; window.onload = function typing(){ var mydiv = document.getelementbyid("display"); mydiv.innerhtml += str.charat(i); var obtn = document.getelementbyid('btn'); i++; var id = settimeout(typing,100); if(i==str.length){ cleartimeout(id); mydiv.value =""; mydiv.innerhtml +="" //alert("程序执行完毕!"); } } </script>
总结
以上所述是小编给大家介绍的html5开发三八女王节表白神器,希望对大家有所帮助