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

相关文章

SpringBoot中四种AOP实战应用场景及代码实现

《SpringBoot中四种AOP实战应用场景及代码实现》面向切面编程(AOP)是Spring框架的核心功能之一,它通过预编译和运行期动态代理实现程序功能的统一维护,在SpringBoot应用中,AO... 目录引言场景一:日志记录与性能监控业务需求实现方案使用示例扩展:MDC实现请求跟踪场景二:权限控制与

利用Python调试串口的示例代码

《利用Python调试串口的示例代码》在嵌入式开发、物联网设备调试过程中,串口通信是最基础的调试手段本文将带你用Python+ttkbootstrap打造一款高颜值、多功能的串口调试助手,需要的可以了... 目录概述:为什么需要专业的串口调试工具项目架构设计1.1 技术栈选型1.2 关键类说明1.3 线程模

Python Transformers库(NLP处理库)案例代码讲解

《PythonTransformers库(NLP处理库)案例代码讲解》本文介绍transformers库的全面讲解,包含基础知识、高级用法、案例代码及学习路径,内容经过组织,适合不同阶段的学习者,对... 目录一、基础知识1. Transformers 库简介2. 安装与环境配置3. 快速上手示例二、核心模

Java的栈与队列实现代码解析

《Java的栈与队列实现代码解析》栈是常见的线性数据结构,栈的特点是以先进后出的形式,后进先出,先进后出,分为栈底和栈顶,栈应用于内存的分配,表达式求值,存储临时的数据和方法的调用等,本文给大家介绍J... 目录栈的概念(Stack)栈的实现代码队列(Queue)模拟实现队列(双链表实现)循环队列(循环数组

HTML5中的Microdata与历史记录管理详解

《HTML5中的Microdata与历史记录管理详解》Microdata作为HTML5新增的一个特性,它允许开发者在HTML文档中添加更多的语义信息,以便于搜索引擎和浏览器更好地理解页面内容,本文将探... 目录html5中的Mijscrodata与历史记录管理背景简介html5中的Microdata使用M

html5的响应式布局的方法示例详解

《html5的响应式布局的方法示例详解》:本文主要介绍了HTML5中使用媒体查询和Flexbox进行响应式布局的方法,简要介绍了CSSGrid布局的基础知识和如何实现自动换行的网格布局,详细内容请阅读本文,希望能对你有所帮助... 一 使用媒体查询响应式布局        使用的参数@media这是常用的

HTML5表格语法格式详解

《HTML5表格语法格式详解》在HTML语法中,表格主要通过table、tr和td3个标签构成,本文通过实例代码讲解HTML5表格语法格式,感兴趣的朋友一起看看吧... 目录一、表格1.表格语法格式2.表格属性 3.例子二、不规则表格1.跨行2.跨列3.例子一、表格在html语法中,表格主要通过< tab

Vue3组件中getCurrentInstance()获取App实例,但是返回null的解决方案

《Vue3组件中getCurrentInstance()获取App实例,但是返回null的解决方案》:本文主要介绍Vue3组件中getCurrentInstance()获取App实例,但是返回nu... 目录vue3组件中getCurrentInstajavascriptnce()获取App实例,但是返回n

使用Java将DOCX文档解析为Markdown文档的代码实现

《使用Java将DOCX文档解析为Markdown文档的代码实现》在现代文档处理中,Markdown(MD)因其简洁的语法和良好的可读性,逐渐成为开发者、技术写作者和内容创作者的首选格式,然而,许多文... 目录引言1. 工具和库介绍2. 安装依赖库3. 使用Apache POI解析DOCX文档4. 将解析

C++使用printf语句实现进制转换的示例代码

《C++使用printf语句实现进制转换的示例代码》在C语言中,printf函数可以直接实现部分进制转换功能,通过格式说明符(formatspecifier)快速输出不同进制的数值,下面给大家分享C+... 目录一、printf 原生支持的进制转换1. 十进制、八进制、十六进制转换2. 显示进制前缀3. 指