当前位置:   article > 正文

2023新春祝福html代码,包你学会_怎么做新年祝福网址

怎么做新年祝福网址

前言

大家新年好!今天是年三十,在这个充满喜悦和欢乐的节日里,祝大家新年快乐。不论你在外面过的风生水起还是不尽人意,回到家一家人团团聚聚才是最好的。进入正题,我们作为IT民工,我们要用自己的方式表达对别人的祝福!

这是一个前端的祝福网页,网址是 新年快乐 (imimbert.github.io) ,完整代码一共两个文件,大家可以研究前端代码或者部署到 Github 给别人看。

使用方法

由于这次教程面向所有人,包括无任何编程基础的人群,所以非常详细。

首先在你存代码的目录下打开文件拓展名

新建文本文档

重命名为 index.txt。

再用同样的方法创建 index1.txt

然后把以下内容复制进 index.txt。

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>新年快乐</title><!-- 这是网页标题 -->
  6. <style>
  7. @import url('https://fonts.googleapis.com/css?family=Poppins:100,200,300,400,500,600,700,800,900');
  8. @font-face {
  9. font-family: mono;
  10. src: url(../fonts/JetBrainsMono-Medium.ttf);
  11. }
  12. * {
  13. padding: 0;
  14. margin: 0;
  15. }
  16. ::placeholder {
  17. color: #009bff66;
  18. }
  19. a {
  20. text-decoration: none;
  21. }
  22. body .container {
  23. background-color: #1e1e22;
  24. box-sizing: border-box;
  25. height: 500vw;
  26. padding: 0 2vw;
  27. }
  28. body .container .main {
  29. margin: 0 auto;
  30. width: 80vw;
  31. }
  32. body .container .main .header {
  33. height: 60px;
  34. position: relative;
  35. }
  36. body .container .main .header .nav {
  37. height: 60px;
  38. display: inline-block;
  39. }
  40. body .container .main .header .nav li {
  41. float: left;
  42. height: 60px;
  43. line-height: 60px;
  44. margin: 0 1vw;
  45. font-family: 'Poppins', serif;
  46. font-size: 1vw;
  47. list-style: none;
  48. }
  49. body .container .main .header .nav li a {
  50. border-bottom: 1px solid #009bff;
  51. color: #ddd;
  52. transition: all 0.5s;
  53. }
  54. body .container .main .header .nav li a:hover {
  55. color: #009bff;
  56. }
  57. body .container .main .header .nav li p {
  58. color: #009bff;
  59. }
  60. body .container .main .header .btn-login {
  61. position: absolute;
  62. right: 0;
  63. top: 0;
  64. height: 60px;
  65. display: flex;
  66. flex-direction: row-reverse;
  67. align-items: center;
  68. }
  69. body .container .main .header .btn-login .nav-1 {
  70. padding: 0 20px;
  71. display: flex;
  72. flex-direction: row;
  73. height: 40px;
  74. line-height: 40px;
  75. color: #000;
  76. background-color: #009bff;
  77. border-radius: 20px;
  78. text-align: center;
  79. transition: all 0.3s;
  80. }
  81. body .container .main .header .btn-login .nav-1:hover {
  82. color: #ddd;
  83. }
  84. body .container .main .header .btn-login .nav-1 ion-icon {
  85. height: 40px;
  86. padding-right: 10px;
  87. }
  88. body .container .main .header .btn-login .nav-2 {
  89. padding: 0 20px;
  90. display: flex;
  91. flex-direction: row;
  92. height: 40px;
  93. line-height: 40px;
  94. color: #ddd;
  95. text-align: center;
  96. transition: all 0.3s;
  97. }
  98. body .container .main .header .btn-login .nav-2:hover {
  99. color: #009bff;
  100. }
  101. body .container .main .header .btn-login .nav-2 ion-icon {
  102. height: 40px;
  103. padding-right: 10px;
  104. }
  105. body .container .main section .title-bar {
  106. height: 10vw;
  107. }
  108. body .container .main section .title-bar .title {
  109. border-right: 2px solid #000;
  110. margin-top: 4vw;
  111. display: inline-block;
  112. font-size: 6vw;
  113. font-family: 'mono', serif;
  114. color: rgb(255, 255, 255);
  115. overflow: hidden;
  116. white-space: nowrap;
  117. animation: borders 1s infinite normal,
  118. widths 4s steps(16);
  119. }
  120. @keyframes borders {
  121. from {
  122. border-right-color: #000;
  123. }
  124. to {
  125. border-right-color: #ddd;
  126. }
  127. }
  128. @keyframes widths {
  129. from {
  130. width: 0;
  131. }
  132. to {
  133. width: 16ch;
  134. }
  135. }
  136. .about {
  137. margin-top: 3vw;
  138. }
  139. .about p {
  140. font-size: 1.5vw;
  141. font-family: 'Poppins', serif;
  142. color: #fff;
  143. }
  144. .func-1 {
  145. margin-top: 5vw;
  146. display: flex;
  147. flex-direction: row;
  148. }
  149. .func-1 .func-1-left {
  150. width: 55vw;
  151. margin-right: 5vw;
  152. border: 2px solid #ffffff;
  153. border-radius: 25px;
  154. }
  155. .func-1 .func-1-left #foo-bar {
  156. padding: 1vw;
  157. }
  158. .func-1 .func-1-left p {
  159. font-family: "Poppins", serif;
  160. font-size: 1.5vw;
  161. color: #fff;
  162. padding-left: 2vw;
  163. }
  164. #daily-words {
  165. padding-left: 3vw;
  166. }
  167. .shop {
  168. display: flex;
  169. flex-direction: column;
  170. margin: 2vw 0;
  171. }
  172. .shop a{
  173. color: #009bff;
  174. transition: all .5s;
  175. }
  176. .shop a:hover{
  177. color: white;
  178. }
  179. .shop p {
  180. font-family: "Poppins", serif;
  181. font-size: 1.5vw;
  182. color: #fff;
  183. padding-left: 1vw;
  184. border-left: 2px solid #009bff;
  185. }
  186. .shop h2 {
  187. color: white;
  188. margin-top: .5vw;
  189. font-weight: 300;
  190. font-family: "Poppins", serif;
  191. font-size: 1.5vw;
  192. }
  193. .shop h1{
  194. font-family: 'Poppins', serif;
  195. font-size: 3vw;
  196. font-weight: 400;
  197. color: #fff;
  198. transition: all 1s;
  199. }
  200. .shop h1:hover {
  201. color: #009bff;
  202. }
  203. </style>
  204. </head>
  205. <body>
  206. <style>
  207. body .container {
  208. background-color: black;
  209. box-sizing: border-box;
  210. height: 500vw;
  211. padding: 0 2vw;
  212. }
  213. </style>
  214. <div class="container">
  215. <div class="main">
  216. <ul class="header">
  217. <ul class="nav">
  218. <li>
  219. <a href="#">Back to top</a>
  220. </li>
  221. </ul>
  222. </ul>
  223. <div class="shop" id="talk">
  224. <h1 style="color:white;">输入你的昵称</h1>
  225. <input type="text" style="width: 300px;height:30px;" id="a-name"><br>
  226. <button style="width: 60px;height:25px;" onclick="get()">提交</button>
  227. </div>
  228. <script>
  229. function get(){
  230. var butt = document.getElementById("a-name").value;
  231. // alert(butt);
  232. window.location = "./index1.html?name="+butt;
  233. window.sessionStorage.setItem('name', butt);
  234. }
  235. </script>
  236. </div>
  237. </div>
  238. </body>
  239. </html>

再把以下内容复制进 index1.html

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>新年快乐</title><!-- 这是网页标题 -->
  6. <style>
  7. body{
  8. overflow: hidden;
  9. margin: 0;
  10. }
  11. h1{
  12. position: fixed;
  13. top: 30%;
  14. left: 0;
  15. width: 100%;
  16. text-align: center;
  17. transform:translateY(-50%);
  18. font-family: 'Love Ya Like A Sister', cursive;
  19. font-size: 60px;
  20. color: #c70012;
  21. padding: 0 20px;
  22. }
  23. h1 span{
  24. position: fixed;
  25. left: 0;
  26. width: 100%;
  27. text-align: center;
  28. margin-top:30px;
  29. font-size:40px;
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <h1 id="h1"></h1>
  35. <canvas></canvas> <!--canvas 画布-->
  36. <script>
  37. var canvas = document.querySelector("canvas"),
  38. ctx = canvas.getContext("2d");
  39. var ww,wh;
  40. function onResize(){
  41. ww = canvas.width = window.innerWidth;
  42. wh = canvas.height = window.innerHeight;
  43. }
  44. ctx.strokeStyle = "red";
  45. ctx.shadowBlur = 25;
  46. ctx.shadowColor = "hsla(0, 100%, 60%,0.5)";
  47. var precision = 100;
  48. var hearts = [];
  49. var mouseMoved = false;
  50. function onMove(e){
  51. mouseMoved = true;
  52. if(e.type === "touchmove"){
  53. hearts.push(new Heart(e.touches[0].clientX, e.touches[0].clientY));
  54. hearts.push(new Heart(e.touches[0].clientX, e.touches[0].clientY));
  55. }
  56. else{
  57. hearts.push(new Heart(e.clientX, e.clientY));
  58. hearts.push(new Heart(e.clientX, e.clientY));
  59. }
  60. }
  61. var Heart = function(x,y){
  62. this.x = x || Math.random()*ww;
  63. this.y = y || Math.random()*wh;
  64. this.size = Math.random()*2 + 1;
  65. this.shadowBlur = Math.random() * 10;
  66. this.speedX = (Math.random()+0.2-0.6) * 8;
  67. this.speedY = (Math.random()+0.2-0.6) * 8;
  68. this.speedSize = Math.random()*0.05 + 0.01;
  69. this.opacity = 1;
  70. this.vertices = [];
  71. for (var i = 0; i < precision; i++) {
  72. var step = (i / precision - 0.5) * (Math.PI * 2);
  73. var vector = {
  74. x : (15 * Math.pow(Math.sin(step), 3)),
  75. y : -(13 * Math.cos(step) - 5 * Math.cos(2 * step) - 2 * Math.cos(3 * step) - Math.cos(4 * step))
  76. }
  77. this.vertices.push(vector);
  78. }
  79. }
  80. Heart.prototype.draw = function(){
  81. this.size -= this.speedSize;
  82. this.x += this.speedX;
  83. this.y += this.speedY;
  84. ctx.save();
  85. ctx.translate(-1000,this.y);
  86. ctx.scale(this.size, this.size);
  87. ctx.beginPath();
  88. for (var i = 0; i < precision; i++) {
  89. var vector = this.vertices[i];
  90. ctx.lineTo(vector.x, vector.y);
  91. }
  92. ctx.globalAlpha = this.size;
  93. ctx.shadowBlur = Math.round((3 - this.size) * 10);
  94. ctx.shadowColor = "hsla(0, 100%, 60%,0.5)";
  95. ctx.shadowOffsetX = this.x + 1000;
  96. ctx.globalCompositeOperation = "screen"
  97. ctx.closePath();
  98. ctx.fill()
  99. ctx.restore();
  100. };
  101. function render(a){
  102. requestAnimationFrame(render);
  103. hearts.push(new Heart())
  104. ctx.clearRect(0,0,ww,wh);
  105. for (var i = 0; i < hearts.length; i++) {
  106. hearts[i].draw();
  107. if(hearts[i].size <= 0){
  108. hearts.splice(i,1);
  109. i--;
  110. }
  111. }
  112. }
  113. onResize();
  114. window.addEventListener("mousemove", onMove);
  115. window.addEventListener("touchmove", onMove);
  116. window.addEventListener("resize", onResize);
  117. requestAnimationFrame(render);
  118. window.onload=function starttime(){
  119. time(h1,'2023/1/21'); // 2023年春节时间
  120. ptimer = setTimeout(starttime,1000); // 添加计时器
  121. }
  122. function time(obj,futimg){
  123. var nowtime = new Date().getTime(); // 现在时间转换为时间戳
  124. var futruetime = new Date(futimg).getTime(); // 未来时间转换为时间戳
  125. var msec = futruetime-nowtime; // 毫秒 未来时间-现在时间
  126. var time = (msec/1000); // 毫秒/1000
  127. var day = parseInt(time/86400); // 天 24*60*60*1000
  128. var hour = parseInt(time/3600)-24*day; // 小时 60*60 总小时数-过去的小时数=现在的小时数
  129. var minute = parseInt(time%3600/60); // 分 -(day*24) 以60秒为一整份 取余 剩下秒数 秒数/60 就是分钟数
  130. var second = parseInt(time%60); // 以60秒为一整份 取余 剩下秒数
  131. obj.innerHTML="<br>距离春节还有:<br>"+day+"天"+hour+"小时"+minute+"分"+second+"秒"+"<br><span>愿我所想的事顺心如意。<br>and may the things I think of be all right.<br>祝"+window.sessionStorage.getItem('name')+"新年快乐!"+"</span>"
  132. return true;
  133. }
  134. </script>
  135. <!-- <audio id="bgmusic" src="http://music.163.com/song/media/outer/url?id=1851244378.mp3" autoplay="autoplay" loop="loop" style="display: block; width: 3%; height:3%;"></audio> -->
  136. <script type="text/javascript">
  137. // alert(butt);
  138. document.addEventListener('DOMContentLoaded', function () {
  139. function audioAutoPlay() {
  140. var audio = document.getElementById('bgmusic');
  141. audio.play();
  142. document.addEventListener("WeixinJSBridgeReady", function () {
  143. audio.play();
  144. }, false);
  145. }
  146. audioAutoPlay();
  147. });
  148. </script>
  149. </body>
  150. </html>

重命名两个文件的后缀为 .html

然后双击 index.html,即可看到效果。

部署 Github

如果你想把你的网页分享给别人看,那你就要部署到 github(免费)

首先创建一个 github 账号,网址:github.com

注册好后创建一个仓库

命名为 xxx.github.io,例如 NewYear.github.io

然后进入这个页面

点这里

进入这个页面

把你刚才那两个文件拖到中间

点这

到这个页面

点这

到这个页面

点这

到这个页面

点这里,选择 main

变成这样

点 save

等几分钟刷新一下,出现类似这个就代表成功了

点这里就可以访问你的网站了

最后

最后也是给大家送上新年的祝福,再见~

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/85189
推荐阅读
相关标签
  

闽ICP备14008679号