前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >css实现logo扫光动画效果

css实现logo扫光动画效果

作者头像
申霖
发布2019-12-27 17:57:30
2.2K0
发布2019-12-27 17:57:30
举报
文章被收录于专栏:小白程序猿

在WordPress博客系统中经常见到网站logo出现光条的动画效果,感觉挺好看的,今天实际的写了一些代码、演示一下。

一、实现效果

在图片上出现光条并划过,无限循环的模式。如下图所示

1569412613849971.png
1569412613849971.png

二、代码

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>LOGO扫光效果</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
<style>
.logo{
width:200px;
height:70px;
display: flex;
line-height: 70px;
position: relative;
overflow: hidden;
}
.logo img{
width:100%;
height:70px;
}
/**根据logo外div样式名称修改before前名称**/
.logo:before{  
content:"";
position: absolute;
left: -10px; /**第一个数字参数控制扫光速度,数字越大越慢**/
top: -460px;
width: 200px;
height: 10px; /**光标的宽度,可根据实际调整**/
background-color: rgba(255,255,255,.5);
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-animation: searchLights 1s ease-in 1s infinite;
-o-animation: searchLights 1s ease-in 1s infinite;
animation: searchLights 1.5s ease-in 1s infinite;/**第一个数字参数控制扫光速度,数字越大越慢**/
}
@-webkit-keyframes searchLights {
0% { left: -80px; top: 0; }
to { left: 130px; top: 0px; }
}
@-o-keyframes searchLights {
0% { left: -80px; top: 0; }
to { left: 130px; top: 0px; }
}
@-moz-keyframes searchLights {
0% { left: -80px; top: 0; }
to { left: 130px; top: 0px; }
}
@keyframes searchLights {
0% { left: -80px; top: 0; }
to { left: 130px; top: 0px; }
}
</style>
</head>
<body>
<div>
<img src='./a9522299699ef238479ad3db09f751b6.jpg'>
</div>
</body>
</html>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-09-25,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档