我是靠谱客的博主 优雅银耳汤,这篇文章主要介绍css怎么设置元素一直旋转,现在分享给大家,希望可以做个参考。

本文操作环境:Windows7系统、HTML5&&CSS3版,DELL G3电脑

我们在进行网页页面设计时,经常会遇到各种关于图片展示的问题,比如有的需要让图片圆角展示、图片点击放大展示等等效果。

主要就给大家介绍用css3实现图片自动循环360旋转的具体方法

css可以使用transform 属性设置元素进行旋转、缩放、移动或倾斜。

我们可以使用css样式transform:rotate(360deg)设置元素旋转360度。

可以使用animation设置动画属性。可以通过animation-duration属性设置动画时长。

css3可以通过设置元素css样式为transform:rotate(360deg)设置元素旋转角度为360度,然后通过animation-duration属性来设置动画时长即可实现元素不停旋转。

示例:

HTML代码:

<div class="demo">
<img class="an img" src="1.jpg" width="400" height="400"/>
登录后复制

css图片旋转360度的动画代码示例如下:

.demo{text-align: center;
    margin-top: 100px;}
@-webkit-keyframes rotation{
    from {-webkit-transform: rotate(0deg);}
    to {-webkit-transform: rotate(360deg);}
}
.an{
    -webkit-transform: rotate(360deg);
    animation: rotation 3s linear infinite;
    -moz-animation: rotation 3s linear infinite;
    -webkit-animation: rotation 3s linear infinite;
    -o-animation: rotation 3s linear infinite;
}
.img{border-radius: 200px;}
登录后复制

效果图:

1.gif

推荐学习:《css视频教程》

以上就是css怎么设置元素一直旋转的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是优雅银耳汤最近收集整理的关于css怎么设置元素一直旋转的全部内容,更多相关css怎么设置元素一直旋转内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(101)

评论列表共有 0 条评论

立即
投稿
返回
顶部