最近一直在研究HTML5的动画表现,特别是在移动设备上的呈现。在上一篇文章《盛开的CSS3梦幻荷花》中提到如何用css3制作丰富动画效果的两个思路,当然除此之外,结合使用javascript脚本语言将可以实现更加强大的动画效果以及交互动作。

今天就为大家分享一个用HTML5+CSS3制作的城市场景动画,动画包含了白天到夜晚的渐变动画以及太阳、云朵、气球等动画效果;除此之外,页面的视觉效果采用了插画的设计风格,希望大家会喜欢。

一、HTML结构

这个示例中的HTML结构采用了HTML5的语言来编写,代码将更加的简洁、结构更加清晰易懂。从下面的代码可以看出示例中的每个元素是独立的,最后再重组成一个完整的动画效果。

二、动画解析

整个城市场景的动画是由若干个元素的动画组成,如:天空的变化、云朵的运动、太阳的自转等等。在下面我们一一来为大家解析每个动画的实现思路以及代码组成。

天空的变化

.stage {

position: relative;

overflow: hidden;

height: 600px;

background: #ddf5f7;

-webkit-animation: skyset 110s infinite linear;

-moz-animation: skyset 110s infinite linear;

-o-animation: skyset 110s infinite linear;

animation: skyset 110s infinite linear;

}

@keyframes skyset {

0% {

background: #ddf5f7;

}

23% {

background: #ddf5f7;

}

25% {

background: #350847;

}

27% {

background: #0f192c;

}

50% {

background: #0f192c;

}

68% {

background: #0f192c;

}

75% {

background: #f9c7b8;

}

82% {

background: #ddf5f7;

}

100% {

background: #ddf5f7;

}

}

天空的颜色逐渐的变暗然后又变亮,这是一个有序的过程,但得注意时间的安排。

天黑遮罩层变化

当天空变暗时,也就是到黑夜时,整个城市也是变暗的,所以我们在整个城市的上方加个遮罩层,以背景色来实现,逐渐改变其透明度来实现变化。

.nightOverlay {

z-index: 9999;

position: absolute;

top: 0;

left: 0;

right: 0;

bottom: 0;

background: rgba(15, 25, 44, 0.7);

opacity: 0;

-webkit-animation: set 110s infinite linear;

-moz-animation: set 110s infinite linear;

-o-animation: set 110s infinite linear;

animation: set 110s infinite linear;

}

@keyframes set {

0% {

filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);

opacity: 0;

}

50% {

filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);

opacity: 1;

}

100% {

filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);

opacity: 0;

}

}

太阳自转以及动画

在这里我们需要两个图标,一个是白天的太阳(黄色),一个是夜晚的太阳(黑色)。然后我们再让这个图片轮流显示在画面上就行。

.rotation {

position: absolute;

z-index: 1;

left: 50%;

top: 50%;

margin: -350px 0 0 -350px;

height: 700px;

width: 700px;

-webkit-transform: rotate(45deg);

-moz-transform: rotate(45deg);

-ms-transform: rotate(45deg);

-o-transform: rotate(45deg);

transform: rotate(45deg);

-webkit-animation: rotation 110s infinite linear;

-moz-animation: rotation 110s infinite linear;

-o-animation: rotation 110s infinite linear;

animation: rotation 110s infinite linear;

}

@keyframes rotation {

0% {

transform: rotate(45deg);

}

100% {

transform: rotate(405deg);

}

}

.sun, .moon {

position: absolute;

height: 145px;

width: 145px;

-webkit-border-radius: 50%;

-moz-border-radius: 50%;

-ms-border-radius: 50%;

-o-border-radius: 50%;

border-radius: 50%;

}

.sun {

top: 0;

left: 0;

background: yellow;

}

.moon {

bottom: 0;

right: 0;

background: black;

}

云朵的移动

示例中总共有三朵云朵,分别为大、中、小,为了有更加逼真的效果,我们要分别定义三朵云朵的运动速度、位置以及大小。

.cloud {

position: absolute;

}

.cloud.small {

z-index: 1;

top: 5%;

left: 15%;

background: url(images/cloudSmall.png) no-repeat no-repeat center;

height: 50px;

width: 89px;

-webkit-animation: cloudSmall 165s infinite;

-moz-animation: cloudSmall 165s infinite;

-o-animation: cloudSmall 165s infinite;

animation: cloudSmall 165s infinite;

}

.cloud.medium {

z-index: 3;

top: 25%;

left: 30%;

background: url(images/cloudMedium.png) no-repeat no-repeat center;

height: 92px;

width: 159px;

-webkit-animation: cloudMedium 80s infinite;

-moz-animation: cloudMedium 80s infinite;

-o-animation: cloudMedium 80s infinite;

animation: cloudMedium 80s infinite;

}

.cloud.large {

z-index: 2;

top: 5%;

right: 15%;

background: url(images/cloudLarge.png) no-repeat no-repeat center;

height: 169px;

width: 302px;

-webkit-animation: cloudLarge 105s infinite;

-moz-animation: cloudLarge 105s infinite;

-o-animation: cloudLarge 105s infinite;

animation: cloudLarge 105s infinite;

}

@keyframes cloudSmall {

0% {

left: -8%;

}

100% {

left: 108%;

}

}

@keyframes cloudMedium {

0% {

left: -8%;

}

100% {

left: 108%;

}

}

@keyframes cloudLarge {

0% {

right: -18%;

}

100% {

right: 118%;

}

}

气球的漂浮

接下来是气球的漂浮,可适当的给予摇摆的动作。

.balloon {

position: absolute;

z-index: 3;

top: 5%;

right: 20%;

background: url(images/balloon.png) no-repeat no-repeat center;

height: 227px;

width: 157px;

-webkit-animation: balloon 30s infinite cubic-bezier(0.91, 0.01, 1, 0.89);

-moz-animation: balloon 30s infinite cubic-bezier(0.1, 0.1, 0.95, 0.5);

-o-animation: balloon 30s infinite cubic-bezier(0.1, 0.1, 0.95, 0.5);

animation: balloon 30s infinite cubic-bezier(0.1, 0.1, 0.95, 0.5);

}

@keyframes balloon {

0% {

right: -20%;

transform: rotate(0deg);

}

5% {

right: -20%;

transform: rotate(0deg);

}

25% {

transform: rotate(0deg);

}

100% {

right: 120%;

transform: rotate(-30deg);

}

}

到这里,我们的动画效果基本已经完成了,其中需要添加浏览器前缀的请自行添加。或者下载我们的附件参看完整的css源代码。

三、城市场景组成图片

最后,就是我们城市场景的图片组件了。

.skyline {

position: absolute;

z-index: 5;

width: 100%;

bottom: 26%;

background: url(images/skyline.png) repeat no-repeat;

height: 147px;

}

.beans {

position: absolute;

z-index: 4;

height: 201px;

width: 88px;

bottom: 30%;

left: 50%;

background: url(images/beans.png) no-repeat no-repeat;

}

.ground {

position: absolute;

width: 100%;

bottom: 0;

}

.ground.front {

z-index: 30;

background: url(images/groundFront.png) repeat no-repeat center;

height: 301px;

}

.ground.mid {

z-index: 20;

background: url(images/groundMid.png) repeat no-repeat;

height: 299px;

}

.ground.back {

z-index: 10;

background: url(images/groundBack.png) repeat no-repeat center;

height: 281px;

}

.dowEventCenter {

position: absolute;

z-index: 12;

bottom: 20%;

left: 5%;

background: url(images/dowEventCenter.png) no-repeat no-repeat center;

height: 236px;

width: 524px;

}

.planetarium {

position: absolute;

z-index: 12;

bottom: 18%;

right: 10%;

background: url(images/Planetarium.png) no-repeat no-repeat center;

height: 285px;

width: 347px;

}

.friendshipShell {

position: absolute;

z-index: 21;

bottom: 18%;

left: 20%;

background: url(images/friendshipShell.png) no-repeat no-repeat center;

height: 370px;

width: 231px;

}

.glockenspiel {

position: absolute;

z-index: 11;

bottom: 26%;

right: 50%;

background: url(images/Glockenspiel.png) no-repeat no-repeat center;

height: 263px;

width: 137px;

}

ok,我们的示例分享就到这里,希望大家会喜欢,更加希望大家可以拿这个小小的示例多加练习,多加研究每个动画的实现技巧。

html5 渐变动画效果图,html5+css3城市场景动画_觉唯设计相关推荐

  1. html5场景动画效果图,HTML5+CSS3城市场景动画

    最近一直在研究HTML5的动画表现,特别是在移动设备上的呈现.今天就为大家分享一个用HTML5+CSS3制作的城市场景动画,动画包含了白天到夜晚的渐变动画以及太阳.云朵.气球等动画效果;除此之外,页面 ...

  2. html5遮罩层动画,HTML5+CSS3城市场景动画

    最近一直在研究HTML5的动画表现,特别是在移动设备上的呈现.今天就为大家分享一个用HTML5+CSS3制作的城市场景动画,动画包含了白天到夜晚的渐变动画以及太阳.云朵.气球等动画效果:除此之外,页面 ...

  3. css3动画边框一闪一闪,css3动画条纹边框_觉唯设计

    之前分享过一篇关于<焦点图相框>的文章,深受大家的喜爱.今天也同样为大家分享一篇用css3制作的动画条纹边框,效果还是蛮有趣的,推荐大家用一用.玩一玩. 先简单的说一下实现原理,大家都可以 ...

  4. css3 3d头像,创意css3头像展示_觉唯设计

    今天就为大家分享一个非常有创意的CSS3头像展示效果,交互性强,是一个基于css3和js来实现的,代码量不多,但是最终的效果却很让人赞叹,所以特别推荐给大家.其中关于本示例的一些css样式呈现,个人认 ...

  5. 城市场景动画(HTML)

    <!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8" ...

  6. html5发光动态效果图,一款带有发光动画的HTML5表单

    今天给大家秀一款带有发光动画的HTML5表单,挺酷的,效果图如下: 当表单获取焦点时,表单四周就会呈现出发光动画的效果,并不断地进行颜色渐变:当表单失去焦点时,停止发光.其中颜色渐变的动画只有基于we ...

  7. html模板动画效果图,html5动画模板_使基本HTML模板更上一层楼的动画

    为了更轻松地处理动画,我首先想对不同的方面进行分类和组织. 每个动画将具有五个参数,并具有一系列潜在值: 类型 :单身,团体,相关  顺序 :顺序,随机,同时  事件 :加载,滚动,单击,悬停,调整大 ...

  8. css3 动画图片滚动条,CSS3实现滚动条动画效果代码分享

    一团网资讯 一团资讯 > css3 > CSS3实现滚动条动画效果代码分享 CSS3实现滚动条动画效果代码分享 2018-05-01 08:57:16     发布者:来源网络 先给大家一 ...

  9. html5中怎么让文字旋转动画效果图,HTML5中实现的CSS 3D文字旋转动画

    一个基于HTML5的网页文字3D旋转动画效果,支持中文和英文字符,浏览请注意要使用支持CSS3技术的浏览器,比如Opera.Chrome等,主要结合transition 和 animation来实现, ...

最新文章

  1. linux 查看锁机时间,3分钟短文|Linux 登陆痕迹查看,last 锁定所有可疑对象
  2. Laravel 5.2--如何让表单提交错误,不清空?
  3. POJ - 1185 炮兵阵地(状压dp)
  4. vues响应接口and实例
  5. 【NLP-NER】命名实体识别
  6. android播放html5视频,仅仅有声音没有图像视频
  7. HDU 4079 Happy Telephones 简单题
  8. python读写音频文件小结
  9. t-SNE数据降维(2维3维)及可视化
  10. 使用数字芯片将5V转3.3V方案电路图
  11. 用一个div绘制背景流动网格特效
  12. 函数的定义以及关键字参数
  13. 常用加密与解密算法示例代码
  14. 电感RDC、IDC值是什么意思?或DCR DCI
  15. 互联网公司招聘--阿里巴巴--运营岗--2015年笔试题
  16. Eclipse ShotCut[From internet]
  17. Z=X+Y的概率密度100%做对的方法
  18. Gwallet路演柬埔寨站:区块链是游戏行业的巨大机会
  19. 世界元宇宙大会暨元宇宙探索交流论坛 礼码生活构建元宇宙庞大生态
  20. Android抓包指南: 使用Fiddler抓HTTP/HTTPS包

热门文章

  1. 分享个解决右键没有新建TXT文档的办法
  2. Java8 lambda表达式详解
  3. 最优停止找停车位问题的最简单解释
  4. 接口中的变量public static final
  5. 把ubuntu20装在移动固态硬盘
  6. w7测算计算机分级,win7游戏分级系统
  7. 使用GUID分区表(GPT)的笔记本硬盘做移动硬盘,windowsXP系统不识别的问题
  8. 理解Sharpe夏普比率与Python实现
  9. 《网赚的秘密——草根网民淘金实战》一一1.4 网赚推广的重要性
  10. 《苏菲的世界》——读书笔记