一个简单的动画效果demo,keyframes为关键帧,图片贴在代码下方。利用了伪类实现css3动画效果,初学者可以看一下,恩。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Keywords" content="关键词">
<meta name="Description" content="描述">
<title>css3 animation</title>
<style>
*{margin:0px;padding:0px;}/*去除默认外边距、内边距*/ body{width:272px;margin:0 auto;}
.auto{margin-top:40px;}
.auto-rotate{
color:#333;
font-weight:bold;
font-family:sans-serif;
}
span{font-size:40px;color:#000;font-weight:bold;
font-family:sans-serif;cursor:pointer;}
.anticlockwise{float:left;}
.clockwise{float:right}
.rotate{width:273px;height:273px;margin:auto;
background:url("1.jpg") no-repeat;} input:checked ~ .rotate{/*选中input框自动旋转*/
animation:clockwise 1s steps(30) infinite;
}
/*自定义动画:名称 动一次时间 多少步执行完 无限重复*/
input:checked ~ span{
display:none;
}
@keyframes clockwise{/*顺时针旋转*/
0%{
background-position:0px 0px;
}
100%{
background-position:-8192px 0px;
}
}
.anticlockwise:hover ~ .rotate{
animation:anticlockwise 1s steps(30) infinite;
}
.clockwise:hover ~ .rotate{
animation:clockwise 1s steps(30) infinite;
}
@keyframes anticlockwise{/*逆时针旋转*/
0%{
background-position:-8192px 0px;
}
100%{
background-position:0px 0px;
}
}
</style>
</head>
<body>
<!--选中自动播放-->
<input id="auto" class="auto" type="checkbox" checked / >
<label class="auto-rotate" for="auto">Auto ↻</label><br/>
<!-- 右箭头 -->
<span class="anticlockwise">←</span>
<!-- 左箭头 -->
<span class="clockwise">→</span>
<div class="rotate"></div>
</body>
</html>

CSS3伪类实现动画旋转效果的更多相关文章

  1. CSS3伪类nth-child结合transiton动画实现文字若影若现

    css3伪类nth-child结合transiton动画实现文字若影若现收先创建一个div盒子,然后包裹在div中的有10个span标签每个span标签填上内容一次为A,B,C,D,E,F,G,H,I ...

  2. CSS3伪类和伪元素

    作为一个CSS3初学不久者来说,很容易混淆单冒号(:)和双冒号(::)的用法,以为两者可以互换着来使用.我自己之前也混淆过他们,因为两者看起来太相像了,就像孪生兄弟.但实际上,他们的区别还是挺大的,最 ...

  3. Selectivizr-让IE6~8支持CSS3伪类和属性选择器

    一.下载和demo 下载: 您可以狠狠地点击这里:selectivizr-1.0.0.zip(右键-[目标|链接另存为] 9.24K) demo: 您可以狠狠地点击这里:Selectivizr部分属性 ...

  4. 利用CSS3伪类做3D按钮

    这是通过css3伪类实现的3d按钮,html代码为: <div id="container_buttons"> <p><a class="a ...

  5. CSS3 伪类选择器 nth-child() 的用法

    伪类选择器 nth-child() 在IE6-8和FF3.0-浏览器不支持,CSS3中nth-of-type(n)(比如nth-of-type(1))这个特殊的类选择符可以样式更加个性的标题和段落等, ...

  6. jQuery实现隔行变色、悬停变色 ( CSS3伪类选择器:nth-child() )

    <title>实现隔行变色</title> <script src="Js/jquery-1.8.0.min.js" type="text/ ...

  7. 巧用CSS3伪类选择器自定义checkbox和radio的样式

    由于原生的checkbox和radio的样式太简陋了,在设计页面的时候,设计师往往会设计自己的checkbox和radio样式.一半情况下,为了适应各个浏览器的兼容性,我们都会用其他的元素替代原生的c ...

  8. 玩转CSS3,嗨翻WEB前端,CSS3伪类元素详解/深入浅出[原创][5+3时代]

    在我的上一篇博客中, 很多园友提出说对css3"画图"不是很理解, 在跟他们私聊了一段时间以后,加上自己在开始自学css3的时候的疑惑,我觉得大家之所以不是很理解主要是因为对伪元素 ...

  9. css3 -- 伪类与伪元素

    伪类: 1.结构伪类 A:E : first-child{} E : nth-*(n){} E : first-*(even){}  E : first-*(odd){} B:nth-child 是根 ...

随机推荐

  1. R语言统计分析技术研究 特征值选择技术要点

    特征值选择技术要点                          作者:王立敏 文章来源:  网络 1.特征值 特征值是线性代数中的一个重要概念.在数学,物理学,化学,计算机等领域有着广泛的应用. ...

  2. 实现一个javascript手势库 -- base-gesture.js

    现在移动端这么普及呢,我们在手机上可以操作更多了.对于网页来说实现一些丰富的操作感觉也是非常有必要的,对吧(如果你仅仅需要click,,那就当我没说咯...)~~比如实现上下,左右滑动,点击之类的,加 ...

  3. Linux基础命令之总结一

    [root@ping ~]# tree -L 1 /   #使用tree 命令查看根目录下的一层的目录结构 ls - list directory contents[root@ping ~]# ls ...

  4. Linux: 安装NVIDIA显卡驱动

    Linux(Fedora25, 64bit)台式机配备了NVIDIA显卡GTX950,但是仅仅使用开源驱动nouveau,无法发挥NVIDIA显卡的性能,所以可以考虑使用官方提供的显卡驱动. # 先安 ...

  5. maven下载jar包失败后无法再次重新下载

    maven下载jar包失败后无法再次重新下载:删除maven 资源库中的 *.lastUpdated文件

  6. 搭建es6开发与非开发环境babel-browser

    前言 最近打算把es6应用到项目中,但是如何在开发环境(浏览器端)直接运行es6?es6已经发布一段时间了,现在大部分是在node.js环境运行,或者通过babel编译之后运行.babel-brows ...

  7. [leetcode-575-Distribute Candies]

    Given an integer array with even length, where different numbers in this array represent different k ...

  8. 【LeetCode】112. Path Sum

    题目: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up ...

  9. laravel blade模板介绍

    第一步:首先写好模板 在sites下新建立一个app.blade.php文件 写入模板如: <!DOCTYPT html><html><head> <titl ...

  10. web前段2017.6.8

    <body></body>background='图片路径'---表示背景图片图片:.jpg .png(透明图片) .gif(动态图)... 路径---绝对路径:相对于磁盘的路 ...