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

相关文章

HTML5 中的<button>标签用法和特征

《HTML5中的<button>标签用法和特征》在HTML5中,button标签用于定义一个可点击的按钮,它是创建交互式网页的重要元素之一,本文将深入解析HTML5中的button标签,详细介绍其属... 目录引言<button> 标签的基本用法<button> 标签的属性typevaluedisabled

HTML5实现的移动端购物车自动结算功能示例代码

《HTML5实现的移动端购物车自动结算功能示例代码》本文介绍HTML5实现移动端购物车自动结算,通过WebStorage、事件监听、DOM操作等技术,确保实时更新与数据同步,优化性能及无障碍性,提升用... 目录1. 移动端购物车自动结算概述2. 数据存储与状态保存机制2.1 浏览器端的数据存储方式2.1.

基于 HTML5 Canvas 实现图片旋转与下载功能(完整代码展示)

《基于HTML5Canvas实现图片旋转与下载功能(完整代码展示)》本文将深入剖析一段基于HTML5Canvas的代码,该代码实现了图片的旋转(90度和180度)以及旋转后图片的下载... 目录一、引言二、html 结构分析三、css 样式分析四、JavaScript 功能实现一、引言在 Web 开发中,

Python如何去除图片干扰代码示例

《Python如何去除图片干扰代码示例》图片降噪是一个广泛应用于图像处理的技术,可以提高图像质量和相关应用的效果,:本文主要介绍Python如何去除图片干扰的相关资料,文中通过代码介绍的非常详细,... 目录一、噪声去除1. 高斯噪声(像素值正态分布扰动)2. 椒盐噪声(随机黑白像素点)3. 复杂噪声(如伪

Java Spring ApplicationEvent 代码示例解析

《JavaSpringApplicationEvent代码示例解析》本文解析了Spring事件机制,涵盖核心概念(发布-订阅/观察者模式)、代码实现(事件定义、发布、监听)及高级应用(异步处理、... 目录一、Spring 事件机制核心概念1. 事件驱动架构模型2. 核心组件二、代码示例解析1. 事件定义

CSS place-items: center解析与用法详解

《CSSplace-items:center解析与用法详解》place-items:center;是一个强大的CSS简写属性,用于同时控制网格(Grid)和弹性盒(Flexbox)... place-items: center; 是一个强大的 css 简写属性,用于同时控制 网格(Grid) 和 弹性盒(F

CSS实现元素撑满剩余空间的五种方法

《CSS实现元素撑满剩余空间的五种方法》在日常开发中,我们经常需要让某个元素占据容器的剩余空间,本文将介绍5种不同的方法来实现这个需求,并分析各种方法的优缺点,感兴趣的朋友一起看看吧... css实现元素撑满剩余空间的5种方法 在日常开发中,我们经常需要让某个元素占据容器的剩余空间。这是一个常见的布局需求

CSS Anchor Positioning重新定义锚点定位的时代来临(最新推荐)

《CSSAnchorPositioning重新定义锚点定位的时代来临(最新推荐)》CSSAnchorPositioning是一项仍在草案中的新特性,由Chrome125开始提供原生支持需... 目录 css Anchor Positioning:重新定义「锚定定位」的时代来了! 什么是 Anchor Pos

CSS中的Static、Relative、Absolute、Fixed、Sticky的应用与详细对比

《CSS中的Static、Relative、Absolute、Fixed、Sticky的应用与详细对比》CSS中的position属性用于控制元素的定位方式,不同的定位方式会影响元素在页面中的布... css 中的 position 属性用于控制元素的定位方式,不同的定位方式会影响元素在页面中的布局和层叠关

HTML5 getUserMedia API网页录音实现指南示例小结

《HTML5getUserMediaAPI网页录音实现指南示例小结》本教程将指导你如何利用这一API,结合WebAudioAPI,实现网页录音功能,从获取音频流到处理和保存录音,整个过程将逐步... 目录1. html5 getUserMedia API简介1.1 API概念与历史1.2 功能与优势1.3