transform属性允许我们对元素进行旋转、缩放、移动和倾斜;

animation属性允许我们对元素实现一些动画效果;

跳动的心源码

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>跳动的心</title>
<style>
*{
margin: 0;
padding: 0;
}
.contain{
width: 100%;
height: 100%;
position: fixed; /*固定定位相对于浏览器窗口*/
background-color: white;
animation-name: contain;
animation-duration: 1s;
animation-iteration-count: infinite; /*动画次数*/
}
.heart{
width: 50px;
height: 50px;
background-color:pink;
position: absolute;
margin: auto;
top: 0;
bottom: 0;
left: 0;
right: 0;
transform: rotate(-45deg);
animation-name: beat;
animation-duration: 1s;
animation-iteration-count: infinite;
}
.heart:before{
background-color: pink;
content: "";
border-radius: 50%;
width: 50px;
height: 50px;
position: absolute;
top:-25px;
left: 0;
} .heart:after{
background-color: pink;
content: "";
border-radius: 50%;
width:50px;
height: 50px;
position: absolute;
top: 0 ;
left: 25px;
} @keyframes contain {
50%{
background-color: #ffe6f2;
}
} @keyframes beat{
0%{
transform: scale(1) rotate(-45deg);
}
50%{
transform: scale(0.6) rotate(-45deg);
}
}
</style>
</head>
<body>
<div class="contain">
<div class="heart"> </div>
</div>
</body>
</html>

以上代码使用了两个动画:背景图的颜色变化、桃心的大小变化;

关于.heart的伪类:

1.top和left值的变化 (该数值与原heart的大小的联系)

使用transform属性和animation属性制作跳动的心的更多相关文章

  1. 纯CSS制作“跳动的心”demo

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

  2. CSS Transform / Transition / Animation 属性的区别

    back21 Jun 2011 Category: tech Tags: css 最近想UI的动画转到css3能吃进3d加速的属性上面来以加强动画的连贯性.只是对于css几个新加的属性不太熟悉,常常容 ...

  3. CSS3 Transform、Transition和Animation属性总结

    CSS3的三个与变形和动画啊相关的属性: Transform 浏览器支持情况: Internet Explorer 10.Firefox.Opera 支持 transform 属性. Internet ...

  4. CSS3学习之 animation 属性

    发现animation这个新属性很有趣,在此学习,并整理下!  浏览器支持: Internet Explorer 10.Firefox 以及 Opera 支持 animation 属性: Safari ...

  5. css3 animation 属性众妙

    转自:凹凸实验室(https://aotu.io/notes/2016/11/28/css3-animation-properties/) 本文不会详细介绍每个 css3 animation 属性(需 ...

  6. CSS3 animation属性中的steps实现GIF动图(逐帧动画)

    相信 animation 大家都用过很多,知道是 CSS3做动画用的.而我自己就只会在 X/Y轴 上做位移旋转,使用 animation-timing-function 规定动画的速度曲线,常用到的 ...

  7. CSS3之animation属性

    CSS中的animation属性可用于为许多其他CSS属性设置动画,例如颜色,背景色,高度或宽度. 每个动画都需要使用@keyframes这种at-rule语句定义,然后使用animation属性来调 ...

  8. CSS3动画属性之Animation

    首先定义一个动画规则: @keyframes mymove { from {top:0px;} to {top:200px;} } @-moz-keyframes mymove /* Firefox ...

  9. Android动画总结#补间动画(Tween Animation/View Animation) #帧动画(Frame Animation/Drawable Animation)#属性动画(PropertyAnimation)

    1.共有三种动画,英文名字多种叫法如下 第一种动画:补间动画(Tween Animation/View Animation) 四个:RotateAnimation旋转. AlphaAnimation透 ...

随机推荐

  1. 调用远程linux服务器shell脚本

    package com.haiyisoft.hyoaPc.ui; import java.io.BufferedReader;import java.io.IOException;import jav ...

  2. ceph-----常用命令

    #查看存储池 ceph osd lspools #设置存储池副本数 ceph osd pool set data size 3 #查看存储池具体信息 ceph osd pool ls detail # ...

  3. numpy之填充为nan的数据为该列平均值

    # coding=utf-8 import numpy as np ''' 填充nan的数据,为该列的平均值 ''' def fill_ndarray(t1): for i in range(t1.s ...

  4. HAproxy负载均衡-ACL篇(转) blog.csdn.net/tantexian

    ACL定制法则: 开放策略:拒绝所有,只开放已知 拒绝策略:允许所有,只拒绝某些 事实上实现安全策略,无非也就是以上两种方法 redirect 参考:http://cbonte.github.io/h ...

  5. mingw32-gcc-9.2.1-i686-posix-sjlj-20190904-8ba5c53

    gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=d:/msys/mingw32/bin/../libexec/gcc/ ...

  6. python操作轻量级数据库

    1.导入Python SQLITE数据库模块 Python2.5之后,内置了SQLite3,成为了内置模块,这给我们省了安装的功夫,只需导入即可~ import sqlite3 2. 创建/打开数据库 ...

  7. CentOS 7 安装java 环境

    1.创建安装目录 mkdir /usr/local/java/ 2.将下载的安装包 上传到 安装目录   (可用Xftp 上传) 3.解压 tar -xzvf jdk-8u221-linux-x64. ...

  8. OpenStack组件——Nova计算资源管理

    1.nova介绍 Nova 是 OpenStack 最核心的服务,负责维护和管理云环境的计算资源.OpenStack 作为 IaaS 的云操作系统,虚拟机生命周期管理也就是通过 Nova 来实现的. ...

  9. 【Linux开发】linux设备驱动归纳总结(八):2.总线、设备和驱动的关系

    linux设备驱动归纳总结(八):2.总线.设备和驱动的关系 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...

  10. NoSQL--leveldb

    什么是leveldb: leveldb它是一个 NOSQL 存储引擎,它和 Redis 不是一个概念.Redis 是一个完备的数据库,而 LevelDB 它只是一个引擎. LevelDB 还可以将它看 ...