用css3实现惊艳面试官的背景即背景动画(高级附源码)

我们传统的前端更多的是用javascript实现各种复杂动画,自从有了Css3 transition和animation以来,前端开发在动画这一块有了更高的自由度和格局,对动画的开发也越来越容易。这篇文章就让我们汇总一下使用Css3实现的各种特效。

 

这篇文章参考《css揭秘》这本书,并作出了自己的总结,希望能让大家更有收获,也强烈推荐大家看看这本书,你值得拥有。我们将学到

  • Css3

  • outline

  • radial-gradient

  • linear-gradient

  • box-shadow

1.实现内部虚线边框

知识点:outline

640?wx_fmt=other

核心代码

.dash-border{	
  width: 200px;	
  height: 100px;	
  line-height: 100px;	
  outline: 1px dashed #fff;	
  outline-offset: -10px;	
}

2.边框内圆角的实现

知识点:box-shadow

640?wx_fmt=other

核心代码

.radius-border{	
  margin-top: 20px;	
  width: 180px;	
  height: 80px;	
  box-shadow: 0 0 0 10px gray;	
}

3.实现条纹背景与进度条

知识点:linear-gradient,repeating-linear-gradient

640?wx_fmt=other

核心代码

/* 上 */	
background: linear-gradient(to right,#fb3 50%,#58a 0);	
background-size: 40px 100%;	
box-shadow: inset 0 0 3px #555;	

	
/* 中 */	
background: linear-gradient(45deg,#fb3 25%,#58a 0,#58a 50%,#fb3 0,#fb3 75%,#58a 0);	
background-size: 40px 40px;	

	
/* 下 (可以实现任意角度的渐变,45°时显示效果最好) */	
background: repeating-linear-gradient(60deg,#fb3,#fb3 15px,#58a 0,#58a 30px);

4.复杂的背景图案

知识点:linear-gradient,repeating-linear-gradient,radial-gradient

640?wx_fmt=other

由于第二个图会有复杂的随机动画,建议大家可以亲自尝试看看效果,核心代码

<style>	
.bg-grid{	
  margin-top: 20px;	
  width: 200px;	
  height: 200px;	
  background-image: linear-gradi
  • 24
    点赞
  • 81
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值