css3 animation 学习
css3中可以实现动画效果,主要是通过css3中新增加的属性(transform , transition,animation )来完成。
他们的详细解释可以参考 W3CSCHOOL
下面是效果图:
类似于tab选项卡,当点击某个input的时候,就以动画的效果来显示对应的内容区域。
- <html lang="zh" >
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <style>
- body{
- overflow: hidden;
- }
- .st-container {
- position: absolute;
- width: 100%;
- height: 100%;
- top: 0;
- left: 0;
- font-family: Arial, sans-serif;
- }
- /*put the “navigation” at the top of the page by giving it a fixed position*/
- .st-container > input,
- .st-container > a {
- position: fixed;
- top: 0;
- width: 20%;
- cursor: pointer;
- font-size: 16px;
- height: 34px;
- line-height: 34px;
- }
- .st-container > input {
- opacity: 0;
- z-index: 1000;
- }
- .st-container > a {
- z-index: 10;
- font-weight: 700;
- background: #e23a6e;
- color: #fff;
- text-align: center;
- text-shadow: 1px 1px 1px rgba(151,24,64,0.2);
- text-decoration: none;
- }
- /*It will have the same background color like the link elements:*/
- .st-container:after {
- content: '';
- position: fixed;
- width: 100%;
- height: 34px;
- background: #e23a6e;
- z-index: 9;
- top: 0;
- }
- /*give input and links respective left values*/
- #st-control-1, #st-control-1 + a {
- left: 0;
- }
- #st-control-2, #st-control-2 + a {
- left: 20%;
- }
- #st-control-3, #st-control-3 + a {
- left: 40%;
- }
- #st-control-4, #st-control-4 + a {
- left: 60%;
- }
- #st-control-5, #st-control-5 + a {
- left: 80%;
- }
- /*define a “selected” state for the link elements.*/
- .st-container > input:checked + a,
- .st-container > input:checked:hover + a{
- background: #821134;
- }
- /*add a little triangle using the pseudo-class :after and give it the same color:*/
- .st-container > input:checked + a:after,
- .st-container > input:checked:hover + a:after{
- top: 100%;
- border: solid transparent;
- content: '';
- height: 0;
- width: 0;
- position: absolute;
- pointer-events: none;
- border-top-color: #821134;
- border-width: 20px;
- left: 50%;
- margin-left: -20px;
- }
- /*define a hover state for the link element:*/
- .st-container > input:hover + a{
- background: #AD244F;
- }
- .st-container > input:hover + a:after {
- border-bottom-color: #AD244F;
- }
- /*define scroll panel style*/
- .st-scroll,
- .st-panel {
- position: relative;
- width: 100%;
- height: 100%;
- }
- .st-scroll {
- top: 0;
- left: 0;
- -webkit-transition: all 0.6s ease-in-out;
- /* Let's enforce some hardware acceleration */
- -webkit-transform: translate3d(0, 0, 0);
- -webkit-backface-visibility: hidden;
- border: solid 1px #ccc;
- }
- .st-panel{
- background: #fff;
- overflow: hidden;
- }
- /**define the positions for the st-scroll wrapper for each checked radio button*/
- #st-control-1:checked ~ .st-scroll {
- -webkit-transform: translateY(0%);
- background-color: green;
- }
- #st-control-2:checked ~ .st-scroll {
- -webkit-transform: translateY(-100%);
- background-color: green;
- }
- #st-control-3:checked ~ .st-scroll {
- -webkit-transform: translateY(-200%);
- background-color: green;
- }
- #st-control-4:checked ~ .st-scroll {
- -webkit-transform: translateY(-300%);
- background-color: green;
- }
- #st-control-5:checked ~ .st-scroll {
- -webkit-transform: translateY(-400%);
- background-color: green;
- }
- #st-control-1:checked ~ .st-scroll #st-panel-1 h2,
- #st-control-2:checked ~ .st-scroll #st-panel-2 h2,
- #st-control-3:checked ~ .st-scroll #st-panel-3 h2,
- #st-control-4:checked ~ .st-scroll #st-panel-4 h2,
- #st-control-5:checked ~ .st-scroll #st-panel-5 h2{
- -webkit-animation: moveDown 1.6s ease-in-out 1.2s backwards;
- }
- /** define animation for the scroll panel*/
- @keyframes moveDown{
- 0% {
- -webkit-transform: translateY(-40px);
- opacity: 0;
- }
- 100% {
- -webkit-transform: translateY(0px);
- opacity: 1;
- }
- }
- .st-panel h2 {
- color: #e23a6e;
- text-shadow: 1px 1px 1px rgba(151,24,64,0.2);
- position: absolute;
- font-size: 54px;
- font-weight: 900;
- width: 80%;
- left: 10%;
- text-align: center;
- line-height: 50px;
- margin: -70px 0 0 0;
- padding: 0;
- top: 50%;
- -webkit-backface-visibility: hidden;
- }
- .st-panel p {
- position: absolute;
- text-align: center;
- font-size: 16px;
- line-height: 22px;
- color: #8b8b8b;
- z-index: 2;
- padding: 0;
- width: 50%;
- left: 25%;
- top: 50%;
- margin: 10px 0 0 0;
- -webkit-backface-visibility: hidden;
- }
- </style>
- <body>
- <div class="container">
- <div class="st-container">
- <input type="radio" name="radio-set" checked="checked" id="st-control-1">
- <a href="#st-panel-1">Serendipity</a>
- <input type="radio" name="radio-set" id="st-control-2">
- <a href="#st-panel-2">Happiness</a>
- <input type="radio" name="radio-set" id="st-control-3">
- <a href="#st-panel-3">Tranquillity</a>
- <input type="radio" name="radio-set" id="st-control-4">
- <a href="#st-panel-4">Positivity</a>
- <input type="radio" name="radio-set" id="st-control-5">
- <a href="#st-panel-5">Passion</a>
- <div class="st-scroll">
- <!-- Placeholder text from http://hipsteripsum.me/ -->
- <section class="st-panel" id="st-panel-1">
- <h2>Serendipity</h2>
- <p>Banksy adipisicing eiusmod banh mi sed. Squid stumptown est odd future nisi, commodo mlkshk pop-up adipisicing retro.</p>
- </section>
- <section class="st-panel st-color" id="st-panel-2">
- <h2>Happiness</h2>
- <p>Art party readymade beard labore cosby sweater culpa. Art party whatever incididunt, scenester umami polaroid tofu.</p>
- </section>
- <section class="st-panel" id="st-panel-3">
- <h2>Tranquillity</h2>
- <p>Sint aute occaecat id vice. Post-ironic fap pork belly next level godard, id fanny pack williamsburg forage truffaut.</p>
- </section>
- <section class="st-panel st-color" id="st-panel-4">
- <h2>Positivity</h2>
- <p>Mixtape fap leggings art party, butcher authentic farm-to-table you probably haven't heard of them do labore cosby sweater.</p>
- </section>
- <section class="st-panel" id="st-panel-5">
- <h2>Passion</h2>
- <p>Fixie ad odd future polaroid dreamcatcher, nesciunt carles bicycle rights accusamus mcsweeney's mumblecore nulla irony.</p>
- </section>
- </div><!-- // st-scroll -->
- </div><!-- // st-container -->
- </div>
- </body>
- </html>
css3 animation 学习的更多相关文章
- CSS3 Animation学习笔记
Internet Explorer 9,以及更早的版本, 不支持 @keyframe 规则或 animation 属性. Internet Explorer 10.Firefox 以及 Opera 支 ...
- 实现了一个百度首页的彩蛋——CSS3 Animation简介
在百度搜索中有这样一个彩蛋:搜索“旋转”,“跳跃”,“反转”等词语,会出现相应的动画效果(搜索“反转”后的效果).查看源码可以发现,这些效果正是通过CSS3的animation属性实现的. 实现这个彩 ...
- css3 animation实现风车转动
项目中经常有用到动画效果,比如Loading.风车转动等等.最简单的办法是使用gif,但是gif在半透明背景下有白边,体验不友好,好在现在可以使用css3的anmiation来实现动画效果,极大的提升 ...
- css3 animation动画特效插件的巧用
这一个是css3 animation动画特效在线演示的网站 https://daneden.github.io/animate.css/ 下载 animate.css文件,文件的代码很多,不过要明白 ...
- CSS3 Animation Cheat Sheet:实用的 CSS3 动画库
CSS3 Animation Cheat Sheet 是一组预设的动画库,为您的 Web 项目添加各种很炫的动画.所有你需要做的是添加样式表到你的网站,为你想要添加动画效果的元素应用预制的 CSS 类 ...
- Android Animation学习(六) View Animation介绍
Android Animation学习(六) View Animation介绍 View Animation View animation系统可以用来执行View上的Tween animation和F ...
- Android Animation学习(五) ApiDemos解析:容器布局动画 LayoutTransition
Android Animation学习(五) ApiDemos解析:容器布局动画 LayoutTransition Property animation系统还提供了对ViewGroup中的View改变 ...
- Android Animation学习(四) ApiDemos解析:多属性动画
Android Animation学习(四) ApiDemos解析:多属性动画 如果想同时改变多个属性,根据前面所学的,比较显而易见的一种思路是构造多个对象Animator , ( Animator可 ...
- Android Animation学习(三) ApiDemos解析:XML动画文件的使用
Android Animation学习(三) ApiDemos解析:XML动画文件的使用 可以用XML文件来定义Animation. 文件必须有一个唯一的根节点: <set>, <o ...
随机推荐
- 1257: [CQOI2007]余数之和
题目链接 bzoj1257: [CQOI2007]余数之和 题解 数论分块,乘等差数列求和 代码 #include<bits/stdc++.h> using namespace std; ...
- bzoj4001: [TJOI2015]概率论
题目链接 bzoj4001: [TJOI2015]概率论 题解 生成函数+求导 设\(g(n)\)表示有\(n\)个节点的二叉树的个数,\(g(0) = 1\) 设\(f(x)\)表示\(n\)个节点 ...
- SGU 200. Cracking RSA (高斯消元求自由变元个数)
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=200 200. Cracking RSA time limit per test: ...
- HDU 4436 str2int (后缀自动机SAM,多串建立)
str2int Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total S ...
- [Go] 正则表达式 示例
package main import "bytes" import "fmt" import "regexp" func main() { ...
- <label>标签引起的Firefox焦点问题
在使用Dreamweaver做页面form的时候,默认情况下Dreamweaver都会生成一个<label>标签把元素包装一下,但是有事由于包装不好也会出现一些问题,例如我现在遇到的问题: ...
- 源码编译Tkinter
要让Python支持Tkinter, 需要首先安装tcl和tk两个软件包. 下载地址: http://www.tcl.tk/software/tcltk/download.html 或 tcl:htt ...
- FTP服务器原理(转)
本文转自https://www.cnblogs.com/Aiapple/p/5955736.html 感谢作者 21.1 FTP服务器原理 使用明码传输方式,且有相当多的安全危机历史.因此一般 ...
- nginx网站攻击防护
1.上上个月架构全部迁移上云以后,总的来说比较稳定,业务量也上来,可爱的坏人也来了,7X24小时不停恶意攻击我的网站,第一次收到报警是网站流入流量1分钟以内连续3次超过1000000bps,换算下1M ...
- 常见排序的JAVA实现和性能测试
五种常见的排序算法实现 算法描述 1.插入排序 从第一个元素开始,该元素可以认为已经被排序 取出下一个元素,在已经排序的元素序列中从后向前扫描 如果该元素(已排序)大于新元素,将该元素移到下一位置 重 ...