当前位置:首页 > 代码 > 正文

css动画效果代码大全(css3动画效果大全代码)[20240422更新]

admin 发布:2024-04-22 18:01 117


本篇文章给大家谈谈css动画效果代码大全,以及css3动画效果大全代码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

CSS如何实现hover动态效果的示例代码

!DOCTYPE htmlhtml head meta charset="utf-8" /head style type="text/css" .wrap { width: 500px; height: 500px; margin: 0 auto; border: 1px solid blue; } .con { width: 80%; height: 100px; margin: 40px auto; border: 1px solid black; } /*必须在父级hover,兼容:IE6+*/ .one:hover p { color: red; } /*标签内要加data-title属性,兼容:IE9+*/ .two:hover::before { content: attr(data-title);/*取到data-title属性的值*/ color: green; } .three:hover::after { content: attr(data-title);/*取到data-title属性的值*/ color: blue; } /style body p p class="con one" span鼠标移进来/span p颜色会变哦/p /p p class="con two" data-title="看我七十二变" span鼠标移进来/span p文字会变哦/p /p p class="con three" data-title="看我七十二变" span鼠标移进来/span p文字会变哦/p /p /p /body/html

求CSS图片轮播完整代码?

以4张图片为例:

1.基本布局:

将4张图片左浮动横向并排放入一个div容器内,图片设置统一尺寸,div宽度设置4个图片的总尺寸,然后放入相框容器div,

相框设置1个图片的大小并设置溢出隐藏,以保证正确显示一个照片。

2.设置动画:

然后使用css3动画,通过对photos进行位移,从而达到显示不同的图片,每次偏移一个图片的宽度,即可显示下一张图片。

4张图片,需要切换3次.

根据需要可以对各个图片添加相应的序号和图片简介。

3.代码如下:

复制代码

1 style

2 #frame{position:absolute;width:300px;height:200px;overflow:hidden;border-radius:5px}

3 #dis{position:absolute;left:-50px;top:-10px;opacity:.5}

4 #dis li{display:inline-block;width:200px;height:20px;margin:0 50px;float:left;text-align:center;color:#fff;border-radius:10px;background:#000}

5 #photos img{float:left;width:300px;height:200px}

6 #photos { position: absolute;z-index:9; width: calc(300px * 4);/*---修改图片数量的话需要修改下面的动画参数*/ }

7 .play{ animation: ma 20s ease-out infinite alternate;}

8 @keyframes ma {

9 0%,25% { margin-left: 0px; }

10 30%,50% { margin-left: -300px; }

11 55%,75% { margin-left: -600px; }

12 80%,100% { margin-left: -900px; }

13

14 }

15 /style

复制代码

复制代码

div id="frame"

div id="photos" class="play"

img src="images/1.jpg"

img src="images/3.jpg"

img src="images/4.jpg"

img src="images/5.jpg"

ul id="dis"

li;/li

li22222222222222/li

li33333333333333/li

li44444444444444/li

/ul

/div

/div

拿走不谢!

css样式里常用代码 包括哪些

font-size:12px;/*文字大小*/

color:#CCCCCC;/*文字颜色*/

font-family:Arial,

Helvetica,

sans-serif;/*设置字体*/

font-weight:bold;/*文字加粗*/

text-align:center;/*DIV标签内部水平方向居中或居左右*/

text-decoration:underline;/*下划线*/

line-height:150%;/*行高*/

margin:10px

5px

0;/*容器外部边距*/

margin-top:10px;

padding:10px

5px

0;/*容器内部边距*/

float:left;/*1.仅在做列的结构才用

2.用了float要用父DIV包起来*/

background-color:#999999;/*背景颜色*/

background-image:url(images/test.gif);/*背景图片*/

background-repeat:no-repeat;/*背景图片不平铺*/

background-position:5px

10px;/*背景图片的位置,第一个为横坐标,第二个为纵坐标*/

list-style-type:none;/*消除ul无序列表li前面的小黑点*/

display:block;/*以块形式显示,通常用于链接中实现鼠标划过的效果*/

display:inline;/*当用了float时做靠边的DIV外边距出现翻倍情况时才使用,针对的是IE6的一个bug*/

border:1px

solid

#ccc;/*表格、DIV、LI、A等容器的边框属性,虚线是dashed*/

overflow:hidden;/*溢出部分隐藏*/

overflow:auto;/*自动判断容器高度,从而选择自动出现/隐藏垂直滚动条*/

/*自动适应高度,并且兼容火狐的做法*/

clear:both;

overflow:hidden;

css旋转动画代码

transition使用

为鼠标指针的滑过状态设置一些动画效果。图标在1秒内匀速旋转360度。

.close:hover::before{

-webkit-transform:rotate(360deg);

transform:rotate(360deg);

-webkit-transition:-webkit-transform 1s linear;

transition:transform 1s linear;

}

如何利用CSS3动画实现弹跳效果

HTML代码

html xmlns=""

head

title用CSS3动画给一个小球创建跳跃的动画效果/title

link rel="stylesheet" type="text/css" href="index.css" /

/head

body

section class="main"

div id="ballWrapper"

div id="ball"/div

div id="ballShadow"/div

/div

/section

/body

/html

CSS代码(创建一个与html同目录的index.css文件)

#ballWrapper{position:fixed;top:35%;left:50%;z-index:100;margin-left:-70px;width:140px;height:300px;cursor:pointer;-webkit-transition:all 5s linear 0s;-moz-transition:all 5s linear 0s;transition:all 5s linear 0s;-webkit-transform:scale(1);-moz-transform:scale(1);-o-transform:scale(1);transform:scale(1);-ms-transform:scale(1)}

#ballWrapper:active{cursor:pointer;-webkit-transform:scale(0);-moz-transform:scale(0);-o-transform:scale(0);transform:scale(0);-ms-transform:scale(0)}

#ball{position:absolute;top:0;z-index:11;width:140px;height:140px;border-radius:70px;background:#bbb;background:url(data:image/svg+xml; background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(187,187,187,1)), color-stop(99%,rgba(119,119,119,1))); background: -webkit-linear-gradient(top, rgba(187,187,187,1) 0%,rgba(119,119,119,1) 99%); background: -o-linear-gradient(top, rgba(187,187,187,1) 0%,rgba(119,119,119,1) 99%); background: -ms-linear-gradient(top, rgba(187,187,187,1) 0%,rgba(119,119,119,1) 99%); background: linear-gradient(top, rgba(187,187,187,1) 0%,rgba(119,119,119,1) 99%); box-shadow: inset 0 -5px 15px rgba(255,255,255,0.4), inset -2px -1px 40px rgba(0,0,0,0.4), 0 0 1px #000; cursor: pointer; base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2JiYmJiYiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9Ijk5JSIgc3RvcC1jb2xvcj0iIzc3Nzc3NyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);background:-moz-linear-gradient(top,rgba(187,187,187,1) 0,rgba(119,119,119,1) 99%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#bbbbbb', endColorstr='#777777', GradientType=0 );-webkit-animation:jump 1s infinite;-moz-animation:jump 1s infinite;-o-animation:jump 1s infinite;-ms-animation:jump 1s infinite;animation:jump 1s infinite}

#ball::after{position:absolute;top:10px;left:30px;z-index:10;width:80px;height:40px;border-radius:40px/20px;background:url(data:image/svg+xml; background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(232,232,232,1)), color-stop(1%,rgba(232,232,232,1)), color-stop(100%,rgba(255,255,255,0))); background: -webkit-linear-gradient(top, rgba(232,232,232,1) 0%,rgba(232,232,232,1) 1%,rgba(255,255,255,0) 100%); background: -o-linear-gradient(top, rgba(232,232,232,1) 0%,rgba(232,232,232,1) 1%,rgba(255,255,255,0) 100%); background: -ms-linear-gradient(top, rgba(232,232,232,1) 0%,rgba(232,232,232,1) 1%,rgba(255,255,255,0) 100%); background: linear-gradient(top, rgba(232,232,232,1) 0%,rgba(232,232,232,1) 1%,rgba(255,255,255,0) 100%); content: ""; base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2U4ZThlOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjElIiBzdG9wLWNvbG9yPSIjZThlOGU4IiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIwIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);background:-moz-linear-gradient(top,rgba(232,232,232,1) 0,rgba(232,232,232,1) 1%,rgba(255,255,255,0) 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#e8e8e8', endColorstr='#00ffffff', GradientType=0 )}

#ballShadow{position:absolute;bottom:0;left:50%;z-index:10;margin-left:-30px;width:60px;height:75px;border-radius:30px/40px;background:rgba(20,20,20,.1);box-shadow:0 0 20px 35px rgba(20,20,20,.1);-webkit-transform:scaleY(.3);-moz-transform:scaleY(.3);-o-transform:scaleY(.3);transform:scaleY(.3);-ms-transform:scaleY(.3);-webkit-animation:shrink 1s infinite;-moz-animation:shrink 1s infinite;-o-animation:shrink 1s infinite;-ms-animation:shrink 1s infinite;animation:shrink 1s infinite}

@-webkit-keyframes jump{0%{top:0;-webkit-animation-timing-function:ease-in}

50%{top:140px;height:140px;-webkit-animation-timing-function:ease-out}

55%{top:160px;height:120px;border-radius:70px/60px;-webkit-animation-timing-function:ease-in}

65%{top:120px;height:140px;border-radius:70px;-webkit-animation-timing-function:ease-out}

95%{top:0;-webkit-animation-timing-function:ease-in}

100%{top:0;-webkit-animation-timing-function:ease-in}

}

@-moz-keyframes jump{0%{top:0;-moz-animation-timing-function:ease-in}

50%{top:140px;height:140px;-moz-animation-timing-function:ease-out}

55%{top:160px;height:120px;border-radius:70px/60px;-moz-animation-timing-function:ease-in}

65%{top:120px;height:140px;border-radius:70px;-moz-animation-timing-function:ease-out}

95%{top:0;-moz-animation-timing-function:ease-in}

100%{top:0;-moz-animation-timing-function:ease-in}

}

@-o-keyframes jump{0%{top:0;-o-animation-timing-function:ease-in}

50%{top:140px;height:140px;-o-animation-timing-function:ease-out}

55%{top:160px;height:120px;border-radius:70px/60px;-o-animation-timing-function:ease-in}

65%{top:120px;height:140px;border-radius:70px;-o-animation-timing-function:ease-out}

95%{top:0;-o-animation-timing-function:ease-in}

100%{top:0;-o-animation-timing-function:ease-in}

}

@-ms-keyframes jump{0%{top:0;-ms-animation-timing-function:ease-in}

50%{top:140px;height:140px;-ms-animation-timing-function:ease-out}

55%{top:160px;height:120px;border-radius:70px/60px;-ms-animation-timing-function:ease-in}

65%{top:120px;height:140px;border-radius:70px;-ms-animation-timing-function:ease-out}

95%{top:0;-ms-animation-timing-function:ease-in}

100%{top:0;-ms-animation-timing-function:ease-in}

}

@keyframes jump{0%{top:0;animation-timing-function:ease-in}

50%{top:140px;height:140px;animation-timing-function:ease-out}

55%{top:160px;height:120px;border-radius:70px/60px;animation-timing-function:ease-in}

65%{top:120px;height:140px;border-radius:70px;animation-timing-function:ease-out}

95%{top:0;animation-timing-function:ease-in}

100%{top:0;animation-timing-function:ease-in}

}

@-webkit-keyframes shrink{0%{bottom:0;margin-left:-30px;width:60px;height:75px;border-radius:30px/40px;background:rgba(20,20,20,.1);box-shadow:0 0 20px 35px rgba(20,20,20,.1);-webkit-animation-timing-function:ease-in}

50%{bottom:30px;margin-left:-10px;width:20px;height:5px;border-radius:20px;background:rgba(20,20,20,.3);box-shadow:0 0 20px 35px rgba(20,20,20,.3);-webkit-animation-timing-function:ease-out}

100%{bottom:0;margin-left:-30px;width:60px;height:75px;border-radius:30px/40px;background:rgba(20,20,20,.1);box-shadow:0 0 20px 35px rgba(20,20,20,.1);-webkit-animation-timing-function:ease-in}

}

@-moz-keyframes shrink{0%{bottom:0;margin-left:-30px;width:60px;height:75px;border-radius:30px/40px;background:rgba(20,20,20,.1);box-shadow:0 0 20px 35px rgba(20,20,20,.1);-moz-animation-timing-function:ease-in}

50%{bottom:30px;margin-left:-10px;width:20px;height:5px;border-radius:20px;background:rgba(20,20,20,.3);box-shadow:0 0 20px 35px rgba(20,20,20,.3);-moz-animation-timing-function:ease-out}

100%{bottom:0;margin-left:-30px;width:60px;height:75px;border-radius:30px/40px;background:rgba(20,20,20,.1);box-shadow:0 0 20px 35px rgba(20,20,20,.1);-moz-animation-timing-function:ease-in}

}

@-o-keyframes shrink{0%{bottom:0;margin-left:-30px;width:60px;height:75px;border-radius:30px/40px;background:rgba(20,20,20,.1);box-shadow:0 0 20px 35px rgba(20,20,20,.1);-o-animation-timing-function:ease-in}

50%{bottom:30px;margin-left:-10px;width:20px;height:5px;border-radius:20px;background:rgba(20,20,20,.3);box-shadow:0 0 20px 35px rgba(20,20,20,.3);-o-animation-timing-function:ease-out}

100%{bottom:0;margin-left:-30px;width:60px;height:75px;border-radius:30px/40px;background:rgba(20,20,20,.1);box-shadow:0 0 20px 35px rgba(20,20,20,.1);-o-animation-timing-function:ease-in}

}

@-ms-keyframes shrink{0%{bottom:0;margin-left:-30px;width:60px;height:75px;border-radius:30px/40px;background:rgba(20,20,20,.1);box-shadow:0 0 20px 35px rgba(20,20,20,.1);-ms-animation-timing-function:ease-in}

50%{bottom:30px;margin-left:-10px;width:20px;height:5px;border-radius:20px;background:rgba(20,20,20,.3);box-shadow:0 0 20px 35px rgba(20,20,20,.3);-ms-animation-timing-function:ease-out}

100%{bottom:0;margin-left:-30px;width:60px;height:75px;border-radius:30px/40px;background:rgba(20,20,20,.1);box-shadow:0 0 20px 35px rgba(20,20,20,.1);-ms-animation-timing-function:ease-in}

}

@keyframes shrink{0%{bottom:0;margin-left:-30px;width:60px;height:75px;border-radius:30px/40px;background:rgba(20,20,20,.1);box-shadow:0 0 20px 35px rgba(20,20,20,.1);animation-timing-function:ease-in}

50%{bottom:30px;margin-left:-10px;width:20px;height:5px;border-radius:20px;background:rgba(20,20,20,.3);box-shadow:0 0 20px 35px rgba(20,20,20,.3);animation-timing-function:ease-out}

100%{bottom:0;margin-left:-30px;width:60px;height:75px;border-radius:30px/40px;background:rgba(20,20,20,.1);box-shadow:0 0 20px 35px rgba(20,20,20,.1);animation-timing-function:ease-in}

}

如何用css实现网页的动态效果

网页的动态效果你说的这里的动态效果是让一个画面或者文字动一下吧?因为在专业里边动态是与数据库连接的后台的技术。

css是层叠样式表,是不能够实现动态效果的。但是可以让某个画面动,比如:

一个文字点击的时候,变大的css代码为:

a{font-size:12px;}      /*这里文字默认大小是12像素*/

a:hover{font-size:14px;}      /*这里鼠标经过大小是14像素*/

上边这个简单的代码就实现鼠标经过a的时候,文字变大,离开又恢复。

希望能帮到你

关于css动画效果代码大全和css3动画效果大全代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/280.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载