HTML圣诞树代码(动态效果)

2023-12-20 15:36

本文主要是介绍HTML圣诞树代码(动态效果),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

HTML代码过长所以在顶部资源链接可以直接下载

Pug代码:

.main-wrapper.tree-container.star.spiral-containerul.spiral.one- for (var x = 1; x <= 43; x++)li.light-wrapper(class="light-wrapper-" + x).stabilise: .lightul.spiral.two- for (var x = 1; x <= 43; x++)li.light-wrapper(class="light-wrapper-" + x).stabilise: .lightul.spiral.three- for (var x = 1; x <= 43; x++)li.light-wrapper(class="light-wrapper-" + x).stabilise: .lightul.spiral.four- for (var x = 1; x <= 43; x++)li.light-wrapper(class="light-wrapper-" + x).stabilise: .lightul.spiral.five- for (var x = 1; x <= 43; x++)li.light-wrapper(class="light-wrapper-" + x).stabilise: .lightul.spiral.six- for (var x = 1; x <= 43; x++)li.light-wrapper(class="light-wrapper-" + x).stabilise: .light.text-container//- h2 The best is yet to comeh2.happy Happy Holidays

LESS代码:

@import url('https://fonts.googleapis.com/css?family=Great+Vibes');
@itemsize: 6px;.main-wrapper {background: radial-gradient(ellipse at bottom, #a90e0e 5%, #4e0303 55%, #330000 78%);position: absolute;display: flex;align-items: center;justify-content: center;top: 0;left: 0;width: 100%;height: 100%;margin: 0;padding: 0;
}.tree-container {display: block;	height: 370px;margin: 0;padding: 0;
}.text-container {margin: 0;padding: 0;position: absolute;bottom: 14%;left: 15%;right: 15%;display: flex;align-items: center;justify-content: center;flex-direction: column;text-align: center;h2 {color: rgba(252, 251, 233, 0.85);font-family: 'Great Vibes', cursive;font-weight: 400;margin: 0 0 .8em 0;&.happy {font-size: 3.3em;}}a.c2 {@size: 40px;display: block;font-size: 13px;width: @size;height: @size;background-color: rgba(252, 251, 233, 0.8);border-radius: 50%;color: #8c1313;text-decoration: none;line-height: @size;}
}.star {@dimensions: 12px;@color: #f7b93f;@divider: 1.3;border-radius: 0;border-color: @color transparent transparent transparent;border-style: solid;border-top-width: @dimensions / @divider;border-right-width: @dimensions;border-left-width: @dimensions;height: 0;width: 0;margin-bottom: 5px;background: transparent;z-index: 100;animation: pulsate-star 1.4s ease-in-out infinite alternate-reverse;&:before,&:after {border-color: @color transparent transparent transparent;border-style: solid;border-top-width: @dimensions / @divider;border-right-width: @dimensions;border-left-width: @dimensions;border-bottom: 0;content: '';display: block;height: 0;left: -@dimensions;position: absolute;top: -@dimensions / @divider;width: 0;}&:before {transform: translate(15.5555555%, -15.5555555%) rotate(360deg/5) translateY(50%);}&:after {transform: translate(-15.5555555%, -15.5555555%) rotate(-360deg/5) translateY(50%);}
}.spiral-container {width: 100%;height: 100%;display: block;
}.spiral {position: relative;margin: 0;padding: 0;transform-style: preserve-3d;&.one {animation: rotate-tree 6s infinite linear both;animation-delay: 0s;.light {background: #fcfbe9;}}&.two {animation: rotate-tree 7s infinite linear both;animation-delay: 0.5s;.light {background: #e8a41d;}}&.three {animation: rotate-tree 8s infinite linear both;animation-delay: 1s;.light {background: #f5e393;}}&.four {animation: rotate-tree 9s infinite linear both;animation-delay: 1.5s;.light {background: #a1e8a4;}}&.five {animation: rotate-tree 10s infinite linear both;animation-delay: 2s;.light {background: #e8a4d8;}}&.six {animation: rotate-tree 11s infinite linear both;animation-delay: 2.5s;.light {background: #a4d8e8;}}> .light-wrapper {border-radius: 50%;position: absolute;display: block;width: @itemsize;height: @itemsize;left: 50%;top: 50%;margin: -@itemsize/2 0 0 -@itemsize/2;}.stabilise {position: absolute;display: block;width: 100%;height: 100%;}.light {position: absolute;display: block;width: 100%;height: 100%;border-radius: 50%;top: 0;left: 0;border-radius: 50%;opacity: 1;animation-name: pulsate;animation-timing-function: ease-in-out;animation-iteration-count: infinite;animation-direction: alternate-reverse;}
}.makespiral( @className: ~".spiral"; @itemNo:3; @degrees:0; @elNo: 1; @size: 5px; @delayOffset: 0 ) when ( @elNo <= @itemNo ) {@spacing: 11;@currDeg: unit(@degrees,deg);@correctionDeg: unit(-@degrees,deg);@y: unit(cos(@currDeg) * @elNo * @elNo / 10, px);@x: unit(sin(@currDeg) * @elNo * @elNo / 10, px);@z: unit(@elNo * @elNo / 6, px);@duration: 0.65s; // 固定持续时间@{className} {.light-wrapper.light-wrapper-@{elNo} {transform: translate3d( @x, @y, @z ) rotateX(90deg) rotateZ(0deg) rotateY(@correctionDeg);width: (@size * (@elNo / @itemNo) * 7);height: (@size * (@elNo / @itemNo) * 7);.light {animation-duration: @duration;animation-delay: @delayOffset + @elNo * 0.1s;}}}.makespiral(@className; @itemNo; @degrees + @spacing; @elNo + 1; @size; @delayOffset);
}.makespiral(@className: ~".spiral.one"; @itemNo: 43; @size: 2px); // 第一条螺旋
.makespiral(@className: ~".spiral.two"; @itemNo: 43; @size: 3px; @delayOffset: 1); // 第二条螺旋
.makespiral(@className: ~".spiral.three"; @itemNo: 43; @size: 2px; @delayOffset: .5); // 第三条螺旋
.makespiral(@className: ~".spiral.four"; @itemNo: 43; @size: 2.5px; @delayOffset: 0.8); // 第四条螺旋
.makespiral(@className: ~".spiral.five"; @itemNo: 43; @size: 3.5px; @delayOffset: 0.3); // 第五条螺旋
.makespiral(@className: ~".spiral.six"; @itemNo: 43; @size: 2.8px; @delayOffset: 1.2); // 第六条螺旋@keyframes pulsate {0% {transform: scale(.5);opacity: .4;}100% {transform: scale(1);}
}@keyframes pulsate-star {0% {transform: scale(.9);opacity: .8;}100% {transform: scale(1);opacity: 1;}
}@keyframes rotate-tree {0% {transform: rotateX(-90deg) rotateZ(0deg) rotateY(0deg);}100% {transform: rotateX(-90deg) rotateZ(360deg) rotateY(0deg);}
}

源码地址(因为源码会报错,上面的代码是修改过能运行的,而且在效果上我也做了些改变):Animated 3D Christmas Tree · GitHub

-----------------------------------------------------------------我是分割线--------------------------------------------------------------

看完了觉得不错就点个赞或者评论下吧,感谢!!!

这篇关于HTML圣诞树代码(动态效果)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/516541

相关文章

JS+HTML实现在线图片水印添加工具

《JS+HTML实现在线图片水印添加工具》在社交媒体和内容创作日益频繁的今天,如何保护原创内容、展示品牌身份成了一个不得不面对的问题,本文将实现一个完全基于HTML+CSS构建的现代化图片水印在线工具... 目录概述功能亮点使用方法技术解析延伸思考运行效果项目源码下载总结概述在社交媒体和内容创作日益频繁的

前端CSS Grid 布局示例详解

《前端CSSGrid布局示例详解》CSSGrid是一种二维布局系统,可以同时控制行和列,相比Flex(一维布局),更适合用在整体页面布局或复杂模块结构中,:本文主要介绍前端CSSGri... 目录css Grid 布局详解(通俗易懂版)一、概述二、基础概念三、创建 Grid 容器四、定义网格行和列五、设置行

前端下载文件时如何后端返回的文件流一些常见方法

《前端下载文件时如何后端返回的文件流一些常见方法》:本文主要介绍前端下载文件时如何后端返回的文件流一些常见方法,包括使用Blob和URL.createObjectURL创建下载链接,以及处理带有C... 目录1. 使用 Blob 和 URL.createObjectURL 创建下载链接例子:使用 Blob

Vuex Actions多参数传递的解决方案

《VuexActions多参数传递的解决方案》在Vuex中,actions的设计默认只支持单个参数传递,这有时会限制我们的使用场景,下面我将详细介绍几种处理多参数传递的解决方案,从基础到高级,... 目录一、对象封装法(推荐)二、参数解构法三、柯里化函数法四、Payload 工厂函数五、TypeScript

使用Python实现全能手机虚拟键盘的示例代码

《使用Python实现全能手机虚拟键盘的示例代码》在数字化办公时代,你是否遇到过这样的场景:会议室投影电脑突然键盘失灵、躺在沙发上想远程控制书房电脑、或者需要给长辈远程协助操作?今天我要分享的Pyth... 目录一、项目概述:不止于键盘的远程控制方案1.1 创新价值1.2 技术栈全景二、需求实现步骤一、需求

Java中Date、LocalDate、LocalDateTime、LocalTime、时间戳之间的相互转换代码

《Java中Date、LocalDate、LocalDateTime、LocalTime、时间戳之间的相互转换代码》:本文主要介绍Java中日期时间转换的多种方法,包括将Date转换为LocalD... 目录一、Date转LocalDateTime二、Date转LocalDate三、LocalDateTim

jupyter代码块没有运行图标的解决方案

《jupyter代码块没有运行图标的解决方案》:本文主要介绍jupyter代码块没有运行图标的解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录jupyter代码块没有运行图标的解决1.找到Jupyter notebook的系统配置文件2.这时候一般会搜索到

Python通过模块化开发优化代码的技巧分享

《Python通过模块化开发优化代码的技巧分享》模块化开发就是把代码拆成一个个“零件”,该封装封装,该拆分拆分,下面小编就来和大家简单聊聊python如何用模块化开发进行代码优化吧... 目录什么是模块化开发如何拆分代码改进版:拆分成模块让模块更强大:使用 __init__.py你一定会遇到的问题模www.

Vue3使用router,params传参为空问题

《Vue3使用router,params传参为空问题》:本文主要介绍Vue3使用router,params传参为空问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录vue3使用China编程router,params传参为空1.使用query方式传参2.使用 Histo

CSS Padding 和 Margin 区别全解析

《CSSPadding和Margin区别全解析》CSS中的padding和margin是两个非常基础且重要的属性,它们用于控制元素周围的空白区域,本文将详细介绍padding和... 目录css Padding 和 Margin 全解析1. Padding: 内边距2. Margin: 外边距3. Padd