CSS基本属性(三)

11 篇文章 1 订阅
8 篇文章 0 订阅

CSS基本属性3
Transition—复合属性[检索或设置对象变换时的过渡。]
<’ transition-property '>: 检索或设置对象中的参与过渡的属性
none: 不指定过渡的css属性
all: 所有可以进行过渡的css属性
自定义属性:指定要进行过渡的css属性

<’ transition-duration '>: 检索或设置对象过渡的持续时间
时长:指定对象过渡的持续时间 [单位s秒]

<’ transition-timing-function '>: 检索或设置对象中过渡的动画类型
linear:线性过渡。
ease:平滑过渡。
ease-in:由慢到快。
ease-out由快到慢。
ease-in-out: 由慢到快再到慢。
step-start: 等同于 steps(1, start)
step-end: 等同于 steps(1, end)
steps(<integer>[, [ start | end ] ]?):
接受两个参数的步进函数。第一个参数必须为正整数,指定函数的 步数。第二个参数取值可以是start或end,指定每一步的值发生变 化的时间点。第二个参数是可选的,默认值为end。
cubic-bezier(<number>, <number>, <number>, ): 特定的贝 塞尔曲线类型,4个数值需在[0, 1]区间内

<’ transition-delay '>: 检索或设置对象延迟过渡的时间
时长:指定对象过渡的持续时间 [单位s秒]

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Transition</title>
		<!--
		<style>
			/*
			#div1{
				width: 400px;
				height: 100px;
				background-color: whitesmoke;
				transition: background-color 3s  ease-out  1s;
			}
			#div1:hover{
				background-color: black;
			}
			*/
		</style>
		-->
		<!--
		<style>
			/*
			#div1{width: 400px;height: 100px;background-color: whitesmoke;transition: background-color 3s  ease-out  1s;}
			#div1:hover{background-color: black;}
			*/
		</style>
		 -->
		<style>
			body{
				width: 1000px;
				height: 1000px;
			}
			#div1{
				width: 50%;
				height: 50%;
				background-color: black;
				-webkit-transition-property: background-color;
				-webkit-transition-duration: 5s;
				-webkit-transition-timing-function: ease-out;
				-webkit-transition-delay:1s;
			}
			#div1:hover{
				background-color: red;
			}
		</style> 
	</head>
	<body>
		<div id="div1"></div>
	</body>
</html>

在这里插入图片描述

动画 Animation—复合属性。检索或设置对象所应用的动画特效。
<’ animation-name '>: 检索或设置对象所应用的动画名称
通过@keyframes定义动画名称
定义动画时,简单的动画可以直接使用关键字from和to,即从一种状态过渡到另一种状态:
@keyframes testanimations {
from { opacity: 1; }
to { opacity: 0; }
}
如果复杂的动画,可以混合去设置某个时间段内的任意时间点的样式:
@keyframes testanimations {
from { transform: translate(0, 0); }
20% { transform: translate(20px, 20px); }
40% { transform: translate(40px, 0); }
60% { transform: translate(60px, 20); }
80% { transform: translate(80px, 0); }
to { transform: translate(100px, 20px); }
}
@keyframes testanimations{
0% { transform: translate(0, 0); }
20% { transform: translate(20px, 20px); }
40% { transform: translate(40px, 0); }
60% { transform: translate(60px, 20px); }
80% { transform: translate(80px, 0); }
100% { transform: translate(100px, 20px); }

<’ animation-duration '>: 检索或设置对象动画的持续时间

<’ animation-timing-function '>: 检索或设置对象动画的过渡类型

<’ animation-delay 'gt;: 检索或设置对象动画延迟的时间

<’ animation-iteration-count '>:检索或设置对象动画的循环次数

<’ animation-direction '>: 检索或设置对象动画在循环中是否反向运动
normal: 正常方向
reverse: 反方向运行
alternate: 动画先正常运行再反方向运行,并持续交替运行
alternate-reverse: 动画先反运行再正方向运行,并持续交替运行

<’ animation-fill-mode '>: 检索或设置对象动画时间之外的状态
none: 默认值。不设置对象动画之外的状态
forwards: 设置对象状态为动画结束时的状态
backwards: 设置对象状态为动画开始时的状态
both: 设置对象状态为动画结束或开始的状态

<’ animation-play-state 'gt;: 检索或设置对象动画的状态。w3c正考虑是否将该属性移除,因为动画的状态可以通过其它的方式实现,比如重设样式
running: 运动 paused: 暂停

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Animation</title>
		<style>
			html, body {
						height: 100%;
						overflow: hidden;
					}
			body {
				  margin: 0;
				  padding: 0;
				  position: relative;
				}
			ul {
				padding: 0;
				margin: 0;
				list-style: none;
				}
			.pics {
					width: 100%;
					height: 100%;
					position: relative;
				}
			.pics li {
						width: 100%;
						height: 100%;
						position: absolute;
						left: 0;
						top: 0;
						background-size: cover;
					}
			.pics li:nth-child(1) {
						background-image: url(./images/bg1.jpg);
						z-index: 3;
					}
			.pics li:nth-child(2) {
						background-image: url(./images/bg2.jpg);
						z-index: 2;
					}
			.pics li:nth-child(3) {
						background-image: url(./images/bg3.jpg);
						z-index: 1;
					}
			.btn {
					position: absolute;
					bottom: 100px;
					z-index: 9;
					width: 100%;
					height: 100px;
					text-align: center;
					}
			.btn li {
					display: inline-block;
					width: 100px;
					height: 100px;
					line-height: 100px;
					margin: 0 10px;
					background-color: pink;
					font-size: 30px;
					border-radius: 50px;
					}
			.btn a {
					display: inline-block;
					width: 100%;
					height: 100%;
					color: #000;
					text-decoration: none;
					}
			#pic1:target {
						z-index: 3;
						animation: mytranslate 5s ease-out;
					}
			#pic2:target {
						z-index: 3;
						animation: myscale 1s linear;
					}
			#pic3:target {
						z-index: 3;
						animation: myrotate 5s linear 1s;
					}
					
			@keyframes mytranslate {
						from {
							transform: translateX(-100%);
						}
						to {
							transform: translateX(0px);
						}
					}
			@keyframes myscale {
						from {
							transform: scale(0);
						}
			
						to {
							transform: scale(1);
						}
					}
			@keyframes myrotate {
						from {
							transform: scale(0) rotate(0deg);
						}
						to {
							transform: scale(1) rotate(360deg);
						}
					}		
		</style>
	</head>
	<body>
		<ul class="pics">
				<li id="pic1"></li>
				<li id="pic2"></li>
				<li id="pic3"></li>
		</ul>
		<ul class="btn">
				<li>
					<a href="#pic1">1</a>
				</li>
				<li>
					<a href="#pic2">2</a>
				</li>
				<li>
					<a href="#pic3">3</a>
				</li>
		</ul>
	</body>
</html>

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值