CSS3实现一束光划过图片、和文字特效

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
p{
width:15%;
margin:0 auto;
line-height:50px; 
font-size:30px; 
text-align:center;
transform-origin: 50px 50px;

transform: rotate(45deg) skew(-45deg);
/*-webkit-background-clip: text;*/ /*按文字裁剪 */
/* -webkit-text-fill-color: transparent; */ /*文字的颜色使用背景色*/ 

background-color:#C89845; /*设置一个背景色*/ 
background-image: -webkit-linear-gradient(-4deg, rgba(200,152,69,.6) 30%, #fff 50%, rgba(200,152,69, 0.6) 70%); /*设置渐变的背景,按对角线渐变*/

background-blend-mode: hard-light; /*设置背景为混合模式下的强光模式*/
background-size: 200%;

-webkit-animation: shine 2.5s infinite; /*给背景添加动画改变位置*/
}


@-webkit-keyframes shine {
from {background-position: 130%;}
to {background-position: -30%;}
}
</style>
</head>
<body><p>7折</p></body>
</html>
Paste_Image.png

另外还找了一种在图片中 光闪的效果:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
html,body{background-color:#333;}
.img { display:block; position: relative; width:800px; height:286px; margin:0 auto;overflow: hidden;}

.img:before { 
content: ""; position: absolute; width:200px; height: 100%; top: 0; left: -150px; overflow: hidden;

background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255,255,255,0)), color-stop(50%, rgba(255,255,255,.2)), color-stop(100%, rgba(255,255,255,0)));/*老式语法书写规则*/

background: -moz-linear-gradient(left, rgba(255,255,255,0)0, rgba(255,255,255,.2)50%, rgba(255,255,255,0)100%);
background: -webkit-linear-gradient(left, rgba(255,255,255,0)0, rgba(255,255,255,.2)50%, rgba(255,255,255,0)100%);
background: -o-linear-gradient(left, rgba(255,255,255,0)0, rgba(255,255,255,.2)50%, rgba(255,255,255,0)100%);

-webkit-transform: skewX(-25deg);
-moz-transform: skewX(-25deg)

}
.img:hover:before { left: 150%; transition: left 1s ease 0s; }

</style>
</head>
<body>
<a href="#" class="img">![](img/1.jpg)</a>
</body>
</html>
Paste_Image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,142评论 25 708
  • 作者:mjn 这期主要说说第一集出力的四个原画师,以及官方提供的原画摄影,最后简单提一下无纸作画。 原作:ONE、...
    AnimeTamashii阅读 614评论 0 3
  • 功能包括但不限于: 1.按轴自动或显式数据对齐功能的数据结构2.集成时间序列功能3.数学运算和约简4.灵活处理缺失...
    Shinichi新一君阅读 707评论 0 1
  • 生命里 你离我那么远 又离我那么近 你不在我眼前 却在我心里 你不在我怀里 却在我梦里 你倾城一笑 溶进了我血液里
    桐柏真人阅读 199评论 1 4