热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

css实现随机颜色,CSS3一个显示随机颜色的动画

CSS语言:CSSSCSS确定html,body{background:-webkit-linear-gradient(top,#fff,#dcf);backgrou

CSS

语言:

CSSSCSS

确定

html,

body {

background: -webkit-linear-gradient(top, #fff, #dcf);

background: linear-gradient(to bottom, #fff, #dcf);

height: 100%;

}

.container {

position: absolute;

top: 50%;

left: 50%;

-webkit-transform: translateX(-50%) translateY(-50%);

transform: translateX(-50%) translateY(-50%);

}

.box {

background: #fff;

box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);

margin: .1em;

height: 2em;

width: 2em;

display: inline-block;

position: relative;

padding: 0;

}

.box:after {

content: "";

background: #f00;

height: 100%;

width: 100%;

box-shadow: 0 3px 10px rgba(0, 0, 0, 0.8);

position: absolute;

top: 0;

left: 0;

opacity: 0;

}

.box:nth-of-type(1):after {

-webkit-animation: 3s 0s block-animation linear infinite;

animation: 3s 0s block-animation linear infinite;

}

@-webkit-keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #954ade;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #954ade;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(2):after {

-webkit-animation: 3s 0.1s block-animation linear infinite;

animation: 3s 0.1s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #3175b0;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(3):after {

-webkit-animation: 3s 0.2s block-animation linear infinite;

animation: 3s 0.2s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #e3b9e0;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(4):after {

-webkit-animation: 3s 0.3s block-animation linear infinite;

animation: 3s 0.3s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #be1290;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(5):after {

-webkit-animation: 3s 0.4s block-animation linear infinite;

animation: 3s 0.4s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #cb4dce;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(10):after {

-webkit-animation: 3s 0.5s block-animation linear infinite;

animation: 3s 0.5s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #ee44c9;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(15):after {

-webkit-animation: 3s 0.6s block-animation linear infinite;

animation: 3s 0.6s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #a1a89e;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(20):after {

-webkit-animation: 3s 0.7s block-animation linear infinite;

animation: 3s 0.7s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #869ca3;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(25):after {

-webkit-animation: 3s 0.8s block-animation linear infinite;

animation: 3s 0.8s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #74af40;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(24):after {

-webkit-animation: 3s 0.9s block-animation linear infinite;

animation: 3s 0.9s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #6cb3e4;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(23):after {

-webkit-animation: 3s 1s block-animation linear infinite;

animation: 3s 1s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #47b6e3;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(22):after {

-webkit-animation: 3s 1.1s block-animation linear infinite;

animation: 3s 1.1s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #26dba9;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(21):after {

-webkit-animation: 3s 1.2s block-animation linear infinite;

animation: 3s 1.2s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #9bd27;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(16):after {

-webkit-animation: 3s 1.3s block-animation linear infinite;

animation: 3s 1.3s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #246be5;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(11):after {

-webkit-animation: 3s 1.4s block-animation linear infinite;

animation: 3s 1.4s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #38a7c3;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(6):after {

-webkit-animation: 3s 1.5s block-animation linear infinite;

animation: 3s 1.5s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #13482f;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(7):after {

-webkit-animation: 3s 1.6s block-animation linear infinite;

animation: 3s 1.6s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #730d6b;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(8):after {

-webkit-animation: 3s 1.7s block-animation linear infinite;

animation: 3s 1.7s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #1a605a;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(9):after {

-webkit-animation: 3s 1.8s block-animation linear infinite;

animation: 3s 1.8s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #42e64a;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(14):after {

-webkit-animation: 3s 1.9s block-animation linear infinite;

animation: 3s 1.9s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #ce1f8a;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(19):after {

-webkit-animation: 3s 2s block-animation linear infinite;

animation: 3s 2s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #ecbc9d;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(18):after {

-webkit-animation: 3s 2.1s block-animation linear infinite;

animation: 3s 2.1s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #b1e9c8;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(17):after {

-webkit-animation: 3s 2.2s block-animation linear infinite;

animation: 3s 2.2s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #138169;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(12):after {

-webkit-animation: 3s 2.3s block-animation linear infinite;

animation: 3s 2.3s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #397f8d;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}

.box:nth-of-type(13):after {

-webkit-animation: 3s 2.4s block-animation linear infinite;

animation: 3s 2.4s block-animation linear infinite;

}

@keyframes block-animation {

0% {

opacity: 0;

}

10% {

opacity: 1;

background: #7ad1f4;

}

20% {

opacity: 0;

}

100% {

opacity: 0;

}

}



推荐阅读
  • 本文整理了常用的CSS属性及用法,包括背景属性、边框属性、尺寸属性、可伸缩框属性、字体属性和文本属性等,方便开发者查阅和使用。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • 本文由编程笔记#小编为大家整理,主要介绍了css回到顶部按钮相关的知识,希望对你有一定的参考价值。 ... [详细]
  • VScode格式化文档换行或不换行的设置方法
    本文介绍了在VScode中设置格式化文档换行或不换行的方法,包括使用插件和修改settings.json文件的内容。详细步骤为:找到settings.json文件,将其中的代码替换为指定的代码。 ... [详细]
  • 知识图谱——机器大脑中的知识库
    本文介绍了知识图谱在机器大脑中的应用,以及搜索引擎在知识图谱方面的发展。以谷歌知识图谱为例,说明了知识图谱的智能化特点。通过搜索引擎用户可以获取更加智能化的答案,如搜索关键词"Marie Curie",会得到居里夫人的详细信息以及与之相关的历史人物。知识图谱的出现引起了搜索引擎行业的变革,不仅美国的微软必应,中国的百度、搜狗等搜索引擎公司也纷纷推出了自己的知识图谱。 ... [详细]
  • 高质量SQL书写的30条建议
    本文提供了30条关于优化SQL的建议,包括避免使用select *,使用具体字段,以及使用limit 1等。这些建议是基于实际开发经验总结出来的,旨在帮助读者优化SQL查询。 ... [详细]
  • 合并列值-合并为一列问题需求:createtabletab(Aint,Bint,Cint)inserttabselect1,2,3unionallsel ... [详细]
  • 本文介绍了如何使用n3-charts绘制以日期为x轴的数据,并提供了相应的代码示例。通过设置x轴的类型为日期,可以实现对日期数据的正确显示和处理。同时,还介绍了如何设置y轴的类型和其他相关参数。通过本文的学习,读者可以掌握使用n3-charts绘制日期数据的方法。 ... [详细]
  • 项目需要实现弹幕,网上参考了各种方法,最后觉得transform+transition实现的效果在移动设备上性能最好,在iphone6和红米4上测试,看不到 ... [详细]
  • 动态多点××× 单云双HUB
    动态多点是一个高扩展的IPSEC解决方案传统的ipsecS2S有如下劣势1.中心站点配置量大,无论是采用经典ipsec***还是采用greoveripsec多一个分支 ... [详细]
  • css div中文字位置_超赞的 CSS 阴影技巧与细节
    本文的题目是CSS阴影技巧与细节。CSS阴影,却不一定是box-shadow与filter:drop-shadow,为啥?因为使用其他属性 ... [详细]
  • 为什么三角形与菜单背景的颜色不同? - Why is the triangle a different colour shade to the menu background?
    Imnotunderstandingastowhythetrianglewhichappearswhenthemousehoversoverthemenuitem, ... [详细]
  • 之前我曾经写过一篇关于CSS的border-image属性的文章。现在几乎所有的现代浏览器都支持这个属性——除了IE10及以下IE版本。看起来这是一个非常 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
author-avatar
夡敧
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有