建站学习网,专业提供各类建站教程,网页素材,SEO资讯等建站资源!

网站模板_网站源码_网站素材_建站教程_建站学习网

当前位置:建站学习网 > DIV+CSS教程 > DIV CSS教程 >

CSS3动态效果学习笔记

更新时间:2016-12-31整理编辑:建站学习网阅读:0

   @keyframe 规定动画

  一般是跟animation一起用

  animation : 规定动画的名字 规定动画的时间 规定动画的速度曲线。

  @keyframe 定义动画的名称{ 动画时长的百分比。{一个或多个合法的 CSS 样式属性} }

  目前大部分浏览器都没有支持@keyframe 和animation;所以要分浏览器书写

  @keyframe

  1.safari和chrome浏览器

  @-webkit-keyframes myfrom{

  from {top:0;}

  to {top:200px;}

  }

  2.Firefox浏览器

  @-moz-keyframes myfrom{

  from {top:0;}

  to {top:200px;}

  }

  3.Opera浏览器

  @-o-keyframes myfrom{

  from {top:0;}

  to {top:200px;}

  }

  animation

  1.safari和chrome浏览器

  @-webkit-animation : myfrom 5s infinite

  2.Firefox浏览器

  @-moz-animation : myfrom 5s infinite

  2.Opera浏览器

  @-o-animation : myfrom 5s infinite

  例子

 代码如下  

<!DOCTYPE html>
<html>
 <head>
  <title>CSS3动态效果demo</title>
  <meta charset="utf-8">
  <meta name="keyword" content="CSS3动态效果demo">
  <meta name="description" content="CSS3动态效果demo">
  <meta name="author" content="戎sir">
  <link rel="stylesheet" type="text/css" href="css.css">
 </head>
 <body>
  <div class="main">
   <div class="cont">
    <div class="cont1  conns">
     animation
     动画属性
     @keyframes:
     规定动画
    </div>
    <span data="1">源代码</span>
   </div>
   <div class="cont">
    <div class="cont2 conns">
     animation-delay:
     规定动画何时开始
    </div>
    <span data="2">源代码</span>
   </div>
   <div class="cont">
    <div class="cont3 conns">
     animation-iteration-count:
     规定动画次数
    </div>
    <span data="3">源代码</span>
   </div>
   <div class="cont">
    <div class="cont4 conns">
     animation-direction:
     规定下次动画逆向
    </div>
    <span data="4">源代码</span>
   </div>
   <div class="cont">
    <div class="cont5 conns">
    </div>
    <span data="5">源代码</span>
   </div>
   <div class="cont">
    <div class="cont6 conns">
     
    </div>
    <span data="6">源代码</span>
   </div>
   <div class="cont">
    <div class="cont7 conns">
     
    </div>
    <span data="7">源代码</span>
   </div>
   <div class="cont">
    <div class="cont8 conns">
     
    </div>
    <span data="8">源代码</span>
   </div>
  </div>
  <div class="overbody hidden"></div>
  <div class="commom" id="show1">
   <textarea readonly="readonly" class="tip" style="border-bottom:1px solid #000;">&lt;div class="cont1  conns"&gt;animation-delay:规定动画何时开始 &lt;/div&gt;</textarea>
   <textarea readonly="readonly" class="tipcss">
body{background-color: #000;}
.cont{
 border: 1px solid #fff;
 float: left;
 width: 250px;
 height: 250px;
 position: relative;
 box-sizing:border-box;
}
.conns{white-space: initial;}
.cont a{
 position: absolute;
 top:50px;
 left: 5px;
 color: #e3e3e3;
 word-wrap: break-word; 
 display: block;
 width: 5px;
 text-decoration: none;
}
.cont1{
 width: 100px;
 height:80px;
 margin:0 auto;
 background-color: #999;
 color: #fff;
 padding: 10px;
 position:relative;
 overflow: hidden;
 animation:myfrom 5s infinite;
 -webkit-animation:myfrom 5s infinite;
}
@-webkit-keyframes myfrom{
 from {top:0;}
 to {top:150px;}
}
@keyframes myfrom{
 from {top:0;}
 to {top:150px;}
}</textarea>
  </div>
  <div class="commom" id="show2">
   <textarea readonly="readonly" class="tip" style="border-bottom:1px solid #000;">&lt;div class="cont2  conns"&gt;animation 动画属性,@keyframes:规定动画 &lt;/div&gt;</textarea>
   <textarea readonly="readonly" class="tipcss">
.cont2{
 width: 80px;
 height:80px;
 margin:0 auto;
 background-color: #999;
 color: #fff;
 padding: 10px;
 position:relative;
 overflow: hidden;
 animation:myfrom 5s infinite;
 -webkit-animation:myfrom 5s infinite;
 animation-delay:2s;
 -webkit-animation-delay:2s;
}
其余css同第一个
</textarea>
  </div>
  <div class="commom" id="show3">
   <textarea readonly="readonly" class="tip" style="border-bottom:1px solid #000;">&lt;div class="cont3  conns"&gt;animation-iteration-count: 规定动画次数&lt;/div&gt;</textarea>
   <textarea readonly="readonly" class="tipcss">
.cont3{
 width: 80px;
 height:80px;
 margin:0 auto;
 background-color: #999;
 color: #fff;
 padding: 10px;
 position:relative;
 overflow: hidden;
 animation:myfrom 5s infinite;
 -webkit-animation:myfrom 5s infinite;
 animation-iteration-count:2;
 -webkit-animation-iteration-count:2;
}
其余css同第一个
</textarea>
  </div>
  <div class="commom" id="show4">
   <textarea readonly="readonly" class="tip" style="border-bottom:1px solid #000;">&lt;div class="cont4  conns"&gt;animation-direction: 规定下次动画逆向&lt;/div&gt;</textarea>
   <textarea readonly="readonly" class="tipcss">
.cont4{
 width: 80px;
 height:80px;
 margin:0 auto;
 background-color: #999;
 color: #fff;
 padding: 10px;
 position:relative;
 overflow: hidden;
 animation:myfrom 5s infinite;
 -webkit-animation:myfrom 5s infinite;
 animation-direction:alternate;
 -webkit-animation-direction:alternate;}
其余css同第一个
</textarea>
  </div>
  <div class="commom" id="show5">
   <textarea readonly="readonly" class="tip" style="border-bottom:1px solid #000;">&lt;div class="cont5  conns"&gt; &lt;/div&gt;</textarea>
   <textarea readonly="readonly" class="tipcss">
.cont5{
 margin: 6em auto;
 font-size: 10px;
 position: relative;
 border: 1.1em solid rgba(255, 255, 255, 0.2);
 border-left: 1.1em solid #ffffff;
   -webkit-animation: cont5 1.1s infinite linear;
   animation: cont5 1.1s infinite linear;
}
.cont5,.cont5:after{
 border-radius: 50%;
 width: 10em;
 height: 10em;
}
@keyframes cont5{
 from {-webkit-transform: rotate(0deg);transform: rotate(0deg);}
 to {-webkit-transform: rotate(360deg);transform: rotate(360deg);}
}
@-webkit-keyframes cont5{
 from {-webkit-transform: rotate(0deg);transform: rotate(0deg);}
 to {-webkit-transform: rotate(360deg);transform: rotate(360deg);}
}</textarea>
  </div>
  <div class="commom" id="show6">
   <textarea readonly="readonly" class="tip" style="border-bottom:1px solid #000;">&lt;div class="cont6  conns"&gt; &lt;/div&gt;</textarea>
   <textarea readonly="readonly" class="tipcss">
body{background-color: #000;}
.cont6{
 height: 120px;
 width: 120px;
 margin: 50px auto;
 border-radius: 50%;
 background:linear-gradient(left,#fff,#000);
 background:-webkit-linear-gradient(left,#fff 10%,rgba(255,255,255,0) 40%);
 background:-moz-linear-gradient(left,#fff 10%,rgba(255,255,255,0) 40%);
 background:-o-linear-gradient(left,#fff 10%,rgba(255,255,255,0) 40%);
 background:-ms-linear-gradient(left,#fff 10%,rgba(255,255,255,0) 40%);
 position: relative;
 -webkit-animation: cont6 1.1s infinite linear;
   animation: cont6 1.1s infinite linear;
}
.cont6:before{
 height: 50%;
 width: 50%;
 background:#fff;
 content: '';
 display: block;
 border-radius:100% 0 0 0;
 position: absolute;
 top:0;
 left: 0;
}
.cont6:after{
 height: 75%;
 width: 75%;
 margin: auto;
 background:#000;
 content:'';
 display: block;
 border-radius:50%;
 position: absolute;
 top:0;left: 0;
 right: 0;
 bottom: 0;
}
@keyframes cont6{
 from {-webkit-transform: rotate(0deg);transform: rotate(0deg);}
 to {-webkit-transform: rotate(360deg);transform: rotate(360deg);}
}
@-webkit-keyframes cont6{
 from {-webkit-transform: rotate(0deg);transform: rotate(0deg);}
 to {-webkit-transform: rotate(360deg);transform: rotate(360deg);}
}</textarea>
  </div>
  <div class="commom" id="show7">
   <textarea readonly="readonly" class="tip" style="border-bottom:1px solid #000;">&lt;div class="cont7  conns"&gt; &lt;/div&gt;</textarea>
   <textarea readonly="readonly" class="tipcss">
body{background-color: #000;}
.cont7,.cont7:before,.cont7:after{
 height: 25px;
 width: 25px;
 border-radius: 50%;
 animation:cont7 1.8s infinite ease-in-out;
 -webkit-animation:cont7 1.8s infinite ease-in-out;
}
.cont7{
 position: relative;
 top:0;
 margin: 80px auto;
 animation-delay:0.2s;
 -webkit-animation-delay:0.2s;
}
.cont7:before{
 content: '';
 position: absolute;
 left: -50px;
}
.cont7:after{
 content: '';
 position: absolute;
 left: 50px;
 animation-delay:0.4s;
 -webkit-animation-delay:0.4s;
}
@keyframes cont7{
  0%,
  80%,
  100% {box-shadow: 0 2.5em 0 -1.3em #ffffff; }
  40% {box-shadow: 0 2.5em 0 0 #FFF;}
}
@-webkit-keyframes cont7{
  0%,
  80%,
  100% {box-shadow: 0 2.5em 0 -1.3em #ffffff;}
  40% {box-shadow: 0 2.5em 0 0 #FFF;}
}</textarea>
  </div>
  <div class="commom" id="show8">
   <textarea readonly="readonly" class="tip" style="border-bottom:1px solid #000;">&lt;div class="cont8  conns"&gt; &lt;/div&gt;</textarea>
   <textarea readonly="readonly" class="tipcss">
body{background-color: #000;}
.cont8{
 width: 96px;
 height: 48px;
 border-radius: 50%;
 border-bottom:50px solid #fff;
 border-top:2px solid #fff;
 border-left:2px solid #fff;
 border-right:2px solid #fff;
 position: relative;
 top:0;
 margin: 80px auto;
}
.cont8:before{
 content: '';
 position: absolute;
 width: 12px;
 height: 12px;
 border-radius: 50%;
 border: 18px solid #000;
 top:21px;
 background-color: #fff;
 left: 0;
}
.cont8:after{
 content: '';
 position: absolute;
 width: 12px;
 height: 12px;
 border-radius: 50%;
 border: 18px solid #fff;
 top:21px;
 background-color: #000;
 right: 0;
}</textarea>
  </div>
  <script type="text/javascript" src="jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="show.js"></script>
 </body>
</html>

 

本文网址:https://www.dedexuexi.com/divcss/jc/1739.html

本站部分文章搜集与网络,如有侵权请联系本站,转载请说明出处。

标签:技巧
收藏此文 赞一下!() 打赏本站

如本文对您有帮助,就请建站学习网抽根烟吧!

支付宝打赏
微信打赏
div标签元素css margin-top失效不起作用怎么办
« 上一篇2016年12月31日
用CSS的float属性创建三栏布局网页的方法
2016年12月31日下一篇 »
  • DIV CSS如何给文字字体添加下划线?
    0阅读
    在css中可以使用text-decoration属性或border-bottom属性来给文字添加下划线样式。下面本篇文章就来给大家介绍一下,希望对大家有所帮助。方法1:使用text-decoration属性设置css的text-decoration属性用于指定添加到文本的修饰,其underline属...
  • 纯CSS3实现带动画效果导航菜单无需js
    0阅读
    随着互联网的发展,网页能表现的东西越来越多。由最开始单纯的文字和链接构成的网页,到后来的表格布局,再到div+css模式,现在发展到了 html+css3。网页能表达的东西越来越多,css3兴起已经
  • CSS定义超链接四个状态的正确顺序L-V-H-A
    0阅读
    css定义超链接是要有先后顺序的。否则,在某些浏览器里面有可能会出现某个样式不起作用的bug。不能正确显示想要的效果。 CSS属性的排列顺序: L-V-H-A 。 L-V-H-A是link、visited、hover、active的简写
  • 在ie7下css居中样式text-align:center;偏左问题解决方法
    0阅读
    css样式text-align:center;在ie7下偏左问题,想必有很多朋友的遇到过吧,下面有个不错的方法,大家可以参考下,希望对大家有所帮助 复制代码 代码如下: body { text-align:center; } 用ie7打开是居左的。
  • 对div盒子模型使用心得总结
    0阅读
    相信每一个从事web开发的人对盒子模型都有一个特殊的理解吧,本文也有一个理解并附有示例代码,喜欢的朋友可以参考下 盒子模型的计算 外边距(margin)+边框(border)+内边距(padding)+内容(content
 
QQ在线咨询