本文是此链接的源代码。http://www.imooc.com/learn/77

关于的html5的使用:

transition----含义是:过渡的过程,能够对各种属性设置变化。

有5中过渡的形式:ease、linear、ease-in、ease-out、ease-in-out。

<!DOCTYPE html>
<html>
<head>
<title>html5 transition</title>
<style type="text/css">
#block_bar1{
width: 40px;
height: 100px;
background-color: #69c;
-webkit-transition:width 5s ease;
}
#block_bar1:hover{
width: 600px;
height: 100px;
background-color: #ff0000;
}
#block_bar2{
width: 40px;
height: 100px;
background-color: #69c;
-webkit-transition:width 5s linear;
}
#block_bar2:hover{
width: 600px;
height: 100px;
background-color: #ff0000;
}
#block_bar3{
width: 40px;
height: 100px;
background-color: #69c;
-webkit-transition:width 5s ease-in;
}
#block_bar3:hover{
width: 600px;
height: 100px;
background-color: #ff0000;
}
#block_bar4{
width: 40px;
height: 100px;
background-color: #69c;
-webkit-transition:width 5s ease-out;
}
#block_bar4:hover{
width: 600px;
height: 100px;
background-color: #ff0000;
}
</style>
</head>
<body>
<div id="block_bar1">
</div>
<div id="block_bar2">
</div>
<div id="block_bar3">
</div>
<div id="block_bar4">
</div>
</body>
</html>

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdHVrdTA4MDE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">不同的变化形式。

transform-----含义是:改变,使…变形;转换,动词

该行为是html5新添加的一个特性,主要translate()、rotate()、scale()、skew()等属性能够设置出动画。

example1:

<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
#test{
-webkit-perspective:800;
-webkit-perspective-origin: 50% 50%;
-webkit-transform-style:-webkit-preserve-3d; }
#block{
width: 500px;
height: 500px;
background-color: #69c;
margin: 100px auto;
-webkit-transform:rotateZ(30deg);
} </style>
</head>
<body>
<div id="test">
<div id="block"> </div>
</div>
</body>
</html>

example2:

<!DOCTYPE html>
<html>
<head>
<title>3dRotate</title>
<style type="text/css">
#test{
-webkit-perspective:800;
-webkit-perspective-origin:50% 50%;
-webkit-tranform-style:-webkit-preserve-3d;
}
#block{
width: 200px;
height: 200px;
background-color: #6699cc;
margin:100px auto;
}
#option{
margin: 60px auto;
font-size: 16px;
font-weight: bold;
width: 800px;
}
#option .range-control{width: 700px;}
</style> <script type="text/javascript">
function rotate(){
var x=document.getElementById("rotatex").value;
var y=document.getElementById("rotatey").value;
var z=document.getElementById("rotatez").value;
document.getElementById("block").style.webkitTransform = "rotateX("+x+"deg) rotateY("+y+"deg) rotateZ("+z+"deg)"; document.getElementById("degX-span").innerText =x;
document.getElementById("degY-span").innerText =y;
document.getElementById("degZ-span").innerText =z; }
</script>
</head>
<body>
<div id="test">
<div id="block"></div>
</div>
<div id="option">
<p>rotateX:<span id="degX-span">0</span> degree</p>
<input type="range" min="-360" max="360" id="rotatex" value="0" class="range-control" onMouseMove="rotate()" /><br>
<p>rotateY:<span id="degY-span">0</span> degree</p>
<input type="range" min="-360" max="360" id="rotatey" value="0" class="range-control" onMouseMove="rotate()" /><br>
<p>rotateX:<span id="degZ-span">0</span> degree</p>
<input type="range" min="-360" max="360" id="rotatez" value="0" class="range-control" onMouseMove="rotate()" /><br>
</div>
</body>
</html>

使用transform对translate和rotate进行设置。

最后一个是3维场景的搭建和翻页效果:

<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
#my3dspace{
-webkit-perspective:800;
-webkit-perspective-origin:50% 50%;
overflow: hidden;
}
#pagegroup{
width: 400px;
height: 400px;
margin: 0px auto; -webkit-transform-style:preserve-3d;
position: relative;
}
#op{
text-align: center;
margin:40px auto; }
.page{
width: 360px;
height: 360px;
padding: 20px;
background-color: #000; color: #fff;
font-weight: bold;
font-size: 360px;
line-height: 360px;
text-align: center;
position: absolute;
}
#page1{
-webkit-transform-origin:bottom;
-webkit-transition:-webkit-transform 1s linear;
}
#page2,#page3,#page4,#page5,#page6{
-webkit-transform-origin:bottom;
-webkit-transition:-webkit-transform 1s linear;
-webkit-transform:rotateX(90deg);
}
</style>
<script type="text/javascript">
var curIndex = 1;
function next(){
if(curIndex == 6)
return;
var curPage = document.getElementById("page"+curIndex);
curPage.style.webkitTransform = "rotateX(-90deg)"; curIndex ++;
var nextPage = document.getElementById("page"+curIndex);
nextPage.style.webkitTransform = "rotateX(0deg)";
}
function prev(){
if(curIndex == 1)
return; var curPage = document.getElementById("page"+curIndex);
curPage.style.webkitTransform = "rotateX(90deg)"; curIndex --;
var nextPage = document.getElementById("page"+curIndex);
nextPage.style.webkitTransform = "rotateX(0deg)";
} </script>
</head>
<body>
<div id="my3dspace">
<div id="pagegroup">
<div class="page" id="page1">1</div>
<div class="page" id="page2">2</div>
<div class="page" id="page3">3</div>
<div class="page" id="page4">4</div>
<div class="page" id="page5">5</div>
<div class="page" id="page6">6</div>
</div>
</div>
<div id="op">
<a href="javascript:next()">next</a> <a href="javascript:prev()">previous</a>
</div>
</body>
</html>

css3和html5的学习的更多相关文章

  1. CSS3与页面布局学习笔记(八)——浏览器兼容性问题与前端性能优化方案

    一.浏览器兼容 1.1.概要 世界上没有任何一个浏览器是一样的,同样的代码在不一样的浏览器上运行就存在兼容性问题.不同浏览器其内核亦不尽相同,相同内核的版本不同,相同版本的内核浏览器品牌不一样,各种运 ...

  2. html5开发学习 html5自学需要怎么学

    记得很多大鳄都说过一句话:只要站在风口上,猪都能飞起来.而对于如今的IT技术领域来说,无疑这只幸运的"猪"非html5莫属.html5开发技术在16年迎来了一个飞跃的发展,这也让很 ...

  3. CSS3与页面布局学习总结(八)——浏览器兼容与前端性能优化

    一.浏览器兼容 1.1.概要 世界上没有任何一个浏览器是一样的,同样的代码在不一样的浏览器上运行就存在兼容性问题.不同浏览器其内核亦不尽相同,相同内核的版本不同,相同版本的内核浏览器品牌不一样,各种运 ...

  4. CSS3与页面布局学习总结(四)——页面布局大全

    一.负边距与浮动布局 1.1.负边距 所谓的负边距就是margin取负值的情况,如margin:-100px,margin:-100%.当一个元素与另一个元素margin取负值时将拉近距离.常见的功能 ...

  5. 数百个 HTML5 例子学习 HT 图形组件 – 3D建模篇

    http://www.hightopo.com/demo/pipeline/index.html <数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇>里提到 HT 很 ...

  6. 数百个 HTML5 例子学习 HT 图形组件 – 3D 建模篇

    http://www.hightopo.com/demo/pipeline/index.html <数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇>里提到 HT 很 ...

  7. 数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇

    <数百个 HTML5 例子学习 HT 图形组件 – 拓扑图篇>一文让读者了解了 HT的 2D 拓扑图组件使用,本文将对 HT 的 3D 功能做个综合性的介绍,以便初学者可快速上手使用 HT ...

  8. 数百个 HTML5 例子学习 HT 图形组件 – 拓扑图篇

    HT 是啥:Everything you need to create cutting-edge 2D and 3D visualization. 这口号是当年心目中的产品方向,接着就朝这个方向慢慢打 ...

  9. 五大主流浏览器 CSS3 和 HTML5 兼容性大比拼

    各大主流浏览器对 CSS3 和 HTML5 的支持越来越完善,曾经让多少前端开发人员心碎的IE系也开始拥抱标准.就在前几天,W3C的 HTML5 社区领袖 Shelley 宣布,HTML5的开发工作已 ...

随机推荐

  1. [BZOJ4869][六省联考2017]相逢是问候(线段树+扩展欧拉定理)

    4869: [Shoi2017]相逢是问候 Time Limit: 40 Sec  Memory Limit: 512 MBSubmit: 1313  Solved: 471[Submit][Stat ...

  2. 【树形DP】BZOJ1596-[Usaco2008 Jan]电话网络

    [题目大意] 在一棵有n个节点的树上建信号塔,每个节点的信号塔可以覆盖当前节点极其相连的节点.问要覆盖所有节点,至少需要多少座信号塔? [思路] 经典的树形DP,直接复制一下. f[i][0]:以i为 ...

  3. 【主席树】BZOJ3932-[CQOI2015]任务查询系统

    [题目大意] 超级计算机中的任务用三元组(Si,Ei,Pi)描述,(Si,Ei,Pi)表示任务从第Si秒开始,在第Ei秒后结束(第Si秒和Ei秒任务也在运行),其优先级为Pi.询问,第Xi秒正在运行的 ...

  4. Understanding Cache Access

    URL Loading System提供了综合的disk 和 in-memory 策略的请求缓存.使用缓存有利于减少程序对网络的依赖,并且能提高程序的体验. Using the Cache for a ...

  5. 用ExifInterface读取经纬度的时候遇到的一个问题

    如果读取图片经纬度,使用 String latValue = exifInterface.getAttribute(ExifInterface.TAG_GPS_LATITUDE); String ln ...

  6. Colorful Lecture Note

    Colorful Lecture Note 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi is writing an algorithm lectu ...

  7. Swift使用NSKeyedArchiver进行数据持久化保存的经验

    iOS提供了几种数据持久化保存的方法,有NSKeyedArchiver,Property List,NSUserDefaults和CoreData.我学习下来,觉得保存应用内的诸如列表,记录这些东西, ...

  8. 升/降压转换器 (Buck-boost)

    升/降压转换器 (Buck-boost) 当输入电压是变动的,有时比输出电压高.有时却比较低时(例如放电中的电池),升/降压转换器 (Buck-boost) 是最佳的电源解决方案. 升/降压转换器 ( ...

  9. Added components improve switching-regulator stability

    Added components improve switching-regulator stability

  10. Visual Studio 2010 使用 Git Extensions 连接 google code

    下载最新版本 Git Extensions http://code.google.com/p/gitextensions/downloads/list Git Extensions 2.46 Wind ...