分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

CSS3 transition动画

发布时间:2023-09-06 02:28责任编辑:苏小强关键词:CSS动画
1.transition动画

(1)transition-property 设置过渡的属性,比如:width height background-color

(2)transition-duration 设置过渡的时间,比如:1s 500ms

(3)transition-timing-function 设置过渡的运动方式,常用有linear(匀速)| ease(缓冲运动)

(4)transition-delay 设置动画的延迟

(5)transition:property duration timing-function delay; 同时设置

<head>
<meta charset="utf-8">
<title>transition动画</title>
<style type="text/css">

.box{ ???width: 100px; ???height: 100px; ???background-color: yellow; ???transition: all 500ms ease,background-color 2s ease;}.box:hover{ ???width: 500px; ???height: 500px; ???background-color: red;}</style>

</head>

<body>

<div class="box"></div>

</body>

例子二:图片说明文字

<head>
<meta charset="utf-8">
<title>图片</title>
<style type="text/css">

.box{ ???width: 320px; ???height: 405px; ???margin: 50px auto 0; ???position: relative; ???overflow: hidden;}.text{ ???width: 320px; ???height: 100px; ???position: absolute; ???top: 405px; ???background-color: rgba(124,119,119,0.30); ???transition: all 500ms ease;}.box:hover .text{ ???position: absolute; ???top: 305px;}</style>

</head>

<body>
<div class="box">
<img src="images/3_02.png" alt="星空">
<div class="text">

 ???????????<h3>夜空中最亮的星</h3> ???????????<p>我在思考人生</p> ???????</div></div>

</body>

例子三:夏目

<head>
<meta charset="utf-8">
<title>joke</title>
<style type="text/css">

@keyframes joke{ ???from{ ???????left: 0px; ???} ???to{ ???????left: -2136px; ?????/*图片宽度*/ ???}}.box{ ???width: 534px; ???height: 300px; ???margin: 50px auto; ???overflow: hidden; ???position: relative;}.box img{ ???position: absolute; ???animation: joke 1s steps(4) infinite;}</style>

</head>

<body>

<div class="box"> ???<img src="images/xia.png" alt="夏目友人帐"></div>

</body>

CSS3 transition动画

原文地址:http://blog.51cto.com/13742773/2337008

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved