如何用css制作图片自上而下落下来的动画?

html-css017

如何用css制作图片自上而下落下来的动画?,第1张

可以使用CSS中的animation属性和@keyframes规则来实现图片自上而下落下来的动画效果。例如:

# image {

position: relative//图片的相对位置

animation: falling 1s linear//动画名称为falling,持续时间1s,动画速度变化线性

}

@keyframes falling {

0% { top: 0px} //初始时图片位于顶部

100% { top: 300px} //最终时图片位于300px处

}

使用纯css制作扇形图,合并起来形成饼图:

应该知道css3中引入了圆角属性(border-radius),一旦设置这个值,边框即会出现圆角。同样,我们对正方形设置圆角,即可得到饼状图

html:<div id="circle">11</div>

css:

#circle{

width:0

height:0

border-radius:100px

border-width:100px

border-style:solid

border-color: red blue green yellow

line-height:99em

overflow:hidden

cursor:pointer

margin: 30px auto

}

效果:

4.同样我们对其中三个边框设置透明色即可得到扇形

html:<div id="fan">11</div>

css:

#fan{

width:0

height:0

border-radius:100px

border-width:100px

border-style:solid

border-color:red transparent transparent transparent

line-height:99em

overflow:hidden

cursor:pointer

margin: 30px auto

}

效果: