专业网站建设品牌,十四年专业建站经验,服务6000+客户--广州京杭网络
免费热线:400-683-0016      微信咨询  |  联系我们

CSS3 transition过渡效果(变形、变色、旋转、停顿时间)_CSS学习

当前位置:网站建设 > 技术支持
资料来源:网络整理       时间:2023/3/4 0:55:35       共计:3619 浏览

三个案例,分别用transition实现了变色 变形 旋转以及停顿时间。

直接分享代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>菜鸟教程(runoob.com)</title>
<style> 
.demo1 {
    width: 100px;height: 100px;background: red;
    -webkit-transition: width 2s, height 2s,background 2s;
 -webkit-transform 2s; /* 旋转时间 For Safari 3.1 to 6.0 */
    transition: width 2s, height 2s, transform 2s, background 2s;}
.demo1:hover {width: 300px;height: 200px;background: blue;
    -webkit-transform: rotate(180deg); /* 旋转角度 Chrome, Safari, Opera */
    transform: rotate(180deg);/* 旋转角度*/}
/*------------------------------------------------------*/
.demo2{width:100px;height:100px;
 background:red;
 color: #FFF;
 transition:width 2s,height 2s,background 2s;
 -webkit-transition:width 2s,height 2s,background 2s; /* Safari */}
.demo2:hover{width:300px;background:blue;}
/*-----------------------------------------------------------*/
.demo3{width:100px;height:100px;background:red;
 transition-property:width;
 transition-duration:1s;
 transition-delay:1.2s;
/* Safari */
-webkit-transition-property:width; 
-webkit-transition-duration:1s;
-webkit-transition-delay:1.2s;}
.demo3:hover{width:500px;}
/* --------------------------------------------------*/
</style>
</head>
<body>
<p><b>注意:</b>该实例无法在 Internet Explorer 9 及更早 IE 版本上工作。</p>
<div class="demo1">拉长拉宽、变色、旋转</div>
<br><br>
<div class="demo2">拉长、变色</div>
<br><br>
<div class="demo3">停顿时间、拉长、变色</div>
</body>
</html>

对于transition一定要多多学习和熟悉使用,很多情况下可以省去写JS的烦恼。

版权说明:
本网站凡注明“广州京杭 原创”的皆为本站原创文章,如需转载请注明出处!
本网转载皆注明出处,遵循行业规范,如发现作品内容版权或其它问题的,请与我们联系处理!
欢迎扫描右侧微信二维码与我们联系。
·上一条:CSS3:扔在桌子上的照片(transform 属性)带旋转角度_CSS学习 | ·下一条:CSS3 : last-child 选择器 - 可指定属于其父元素的最后一个子元素,为其单独添加属性_CSS学习

Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有    粤ICP备16019765号 

广州京杭网络科技有限公司 版权所有