css实现简单的抽奖动画效果和旋转效果,还有春联效果

2023-12-03 04:20

本文主要是介绍css实现简单的抽奖动画效果和旋转效果,还有春联效果,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

使用css的animation和transform和transition可以实现简单的图片放大缩小,旋转,位移的效果,由此可以延伸的动画效果还是挺多的,比如图片慢慢放大,图片慢慢旋转并放大,图片慢慢变化位置等等,

抽奖动画效果图

实现的原理也很简单,就是通过使用动画animation和关键动画帧来实现的,可以使用缩放来进行平滑的过渡效果,下面是源码:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title></head><body><div class="center"><div>抽奖效果</div><imgsrc="https://img-blog.csdnimg.cn/67fc9799ae8e48749e82cf70b179895b.png"class="card"/></div><style>.center {width: 500px;margin: 0 auto;text-align: center;}.card {width: 260px;height: 400px;animation: showImg 3s linear 1;}@keyframes showImg {0% {transform: scale(0.1) rotate(0);}50% {transform: scale(0.5) rotate(360deg);}100% {transform: scale(1) rotate(720deg);}}</style></body>
</html>

图片慢慢旋转动画

图片慢慢旋转是通过rotate来实现的,并且鼠标放上去之后,会有暂停的效果:下面的动图有卡顿的效果,实际情况非常丝滑

旋转图片的源代码:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title></head><body><div class="wrap"><div class="source"></div><div class="avatar"></div></div></body><style>body {background-color: black;padding-top: 100px;}.wrap {margin: 0 auto;display: flex;flex-direction: row;justify-content: center;align-items: center;}.source {width: 100px;height: 100px;margin-right: 20px;background-image: url('./assets/ball.png');background-position: center;background-size: 100% 100%;animation: circle 1s linear infinite;}.avatar {width: 100px;height: 100px;border-radius: 50%;background-image: url('https://profile-avatar.csdnimg.cn/f6acd04828d84240afc2739fe039fd49_weixin_44786530.jpg!1');background-position: center;background-size: 100% 100%;animation: circle 2s linear infinite;}.source:hover {animation-play-state: paused;}.avatar:hover {animation-play-state: paused;}@keyframes circle {0% {transform: rotate(0deg);}10% {transform: rotate(36deg);}20% {transform: rotate(72deg);}30% {transform: rotate(108deg);}40% {transform: rotate(144deg);}50% {transform: rotate(180deg);}60% {transform: rotate(216deg);}70% {transform: rotate(252deg);}80% {transform: rotate(288deg);}90% {transform: rotate(324deg);}100% {transform: rotate(360deg);}}</style>
</html>

春联效果

春节快要到了,所以春联也整起来吧,使用了变换中的旋转,还有变化中心位置的修改,效果图如下:

源代码:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title></head><body><div class="wrap"><div class="card"><div class="text">春</div></div><div class="two"><div class="text">到</div></div><div class="three"><div class="text">万</div></div><div class="for"><div class="text">家</div></div></div><style>* {padding: 0;margin: 0;box-sizing: border-box;}html,body {width: 100%;height: 100%;background-color: skyblue;}.wrap {width: 100px;/* margin-top: 200px; */margin: 100px auto;}.card {width: 100px;height: 100px;background-color: red;transform: rotate(45deg);transform-origin: left top;animation: shark 3s infinite ease-in-out -6s;}.two {width: 100px;height: 100px;margin-top: 45px;background-color: red;transform: rotate(45deg);transform-origin: left top;animation: shark 2s infinite ease-in-out -5s;}.three {width: 100px;height: 100px;margin-top: 45px;background-color: red;transform: rotate(45deg);transform-origin: left top;animation: shark 3s infinite ease-in-out -4s;}.for {width: 100px;height: 100px;margin-top: 45px;background-color: red;transform: rotate(45deg);transform-origin: left top;animation: shark 2s infinite ease-in-out -3s;}.text {font-size: 50px;color: white;transform: rotate(-45deg) translate(10px, 10px);}@keyframes shark {0% {transform: rotate(30deg);}50% {transform: rotate(60deg);}100% {transform: rotate(30deg);}}</style></body>
</html>

 

这篇关于css实现简单的抽奖动画效果和旋转效果,还有春联效果的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



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

相关文章

Nginx 配置跨域的实现及常见问题解决

《Nginx配置跨域的实现及常见问题解决》本文主要介绍了Nginx配置跨域的实现及常见问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来... 目录1. 跨域1.1 同源策略1.2 跨域资源共享(CORS)2. Nginx 配置跨域的场景2.1

Python中提取文件名扩展名的多种方法实现

《Python中提取文件名扩展名的多种方法实现》在Python编程中,经常会遇到需要从文件名中提取扩展名的场景,Python提供了多种方法来实现这一功能,不同方法适用于不同的场景和需求,包括os.pa... 目录技术背景实现步骤方法一:使用os.path.splitext方法二:使用pathlib模块方法三

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

Java实现删除文件中的指定内容

《Java实现删除文件中的指定内容》在日常开发中,经常需要对文本文件进行批量处理,其中,删除文件中指定内容是最常见的需求之一,下面我们就来看看如何使用java实现删除文件中的指定内容吧... 目录1. 项目背景详细介绍2. 项目需求详细介绍2.1 功能需求2.2 非功能需求3. 相关技术详细介绍3.1 Ja

使用Python和OpenCV库实现实时颜色识别系统

《使用Python和OpenCV库实现实时颜色识别系统》:本文主要介绍使用Python和OpenCV库实现的实时颜色识别系统,这个系统能够通过摄像头捕捉视频流,并在视频中指定区域内识别主要颜色(红... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间详解

PostgreSQL中MVCC 机制的实现

《PostgreSQL中MVCC机制的实现》本文主要介绍了PostgreSQL中MVCC机制的实现,通过多版本数据存储、快照隔离和事务ID管理实现高并发读写,具有一定的参考价值,感兴趣的可以了解一下... 目录一 MVCC 基本原理python1.1 MVCC 核心概念1.2 与传统锁机制对比二 Postg