书小宅网页设计CSS3——animation动画

Animation

在这里插入图片描述

矩形向椭圆的渐变

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CSS3矩形向椭圆的渐变</title>
<style>
	.shape-1{
		animation-name:rad;/*绑定*/
		animation-duration:5s;/*运行的时间*/
		animation-iteration-count:infinite;/*运行的次数*/
		animation-direction:alternate-reverse;/*轮播*/
		width: 400px;
		height:300px; 
		background-color:#5c0240;
	    margin:30px auto; 
		border-radius:50%
	} 
	/*长宽不同时,border-radius属性值为百分比则是椭圆,是像素值则形如胶囊*/
	
	/*加动画:制作动画的关键词keyframe:关键帧*/
	@keyframes rad{
		0%{border-radius:0}/*开始帧*/
		100%{border-radius:50%}/*结束帧*/
		/*动画的名字必须和相应的类或值绑定*/
	}
</style>
</head>

<body>
<section>
    <div class="shape-1"></div>
</section>
<script>
</script>
</body>
</html>

在这里插入图片描述
###钟摆

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CSS3钟摆动画</title>
<style>
	.swing{
		width:630px; 
		height:400px; 
		border:1px solid #aaa;
		margin:auto
	} 
	.line{
		/*动画的简写格式:*/
		/*animation:name duration timing-function delay iteration-count direction*/
		animation:swing 5s infinite;
		animation-direction:alternate;
		animation-timing-function:ease-in-out;
		
		width:2px;
		height:260px;
		background-color:#333;
		margin:auto;
		position:relative;
		/*旋转中心从摆线转移到旋转点*/
		transform-origin:center top;
	}
	/*画固定线的小圆,径向渐变填充*/
	.line:before{
		content:"";
		width:10px;
		height:10px;
		/*中心亮点,颜色渐变到外侧*/
		background:radial-gradient(#fff 0%,#333 100%);
		position:absolute;/*定位之后变成块*/
		left:-5px;/*固定点向中间定位*/
		border-radius:50%;/*利用圆角矩形的实现原理将方形变成圆*/
	}
	/*作摆钟的大圆*/
	.line:after{
		content:"";
		width:50px;
		height:50px;
		background:radial-gradient(#fff 0%,#ff9900 100%);
		border-radius:50%;
		position:absolute;
		/*大圆移动到末端*/
		left:50%;
		transform:translate(-50%);
		top:100%;
	}
	@keyframes swing{
		0%{transform:rotate(-90deg)}
		100%{transform:rotate(+90deg)}
	}
</style>
</head>

<body>
<section>
<!--swing类中有钟摆类line-->
    <div class="swing">
    	<div class="line"></div>
     </div>
<ction>
<script>
</script>
</body>
<ml>

在这里插入图片描述

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值