【100dayscss#88】燃烧的蜡烛

Day #88
Candle: Thanks to the magic of border-radius, this flame is animated by CSS only. It looks way better than I would have imagined.

<div class="frame">
  <div class="center">
		<div class="flame"></div>
		<div class="wick"></div>
		<div class="candle"></div>
		<div class="table"></div>
  </div>
</div>
// delete the following line if no text is used
// edit the line if you wanna use other fonts
@import url(https://fonts.googleapis.com/css?family=Open+Sans:700,300);

// use only the available space inside the 400x400 frame
.frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 400px;
  height: 400px;
  margin-top: -200px;
  margin-left: -200px;
  border-radius: 2px;
	box-shadow: 4px 8px 16px 0 rgba(0,0,0,0.1);
	overflow: hidden;
  background: #2c3e50;
  color: #333;
	font-family: 'Open Sans', Helvetica, sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}
@keyframes move {
	0% {
	  border-radius: 26px 80px 26px 26px/5px 80px 26px 26px;
		transform: scale(1.3,1)
	}
	25% {
		border-radius: 26px 96px 36px 36px/96px 5px 36px 36px;
		transform: scale(1,1.3)
	}
	75% {
		border-radius: 35px 35px 26px 26px/70px 100px 26px 26px;
		transform: scale(1.3,1)
	}
	100% {
		border-radius: 35px 35px 26px 26px/100px 70px 26px 26px;
		transform: scale(1,1.3)
	}
}
.flame {
	width: 16px;
	height: 26px;
	background: orange;
	margin: 0 auto;
	border-radius: 35px 35px 26px 26px/70px 70px 26px 26px;
	animation: move 3.5s infinite alternate;
}
.wick {
	width: 4px;
	height: 6px;
	background: brown;
	margin:0 auto;
} 
.candle {
	 width: 60px;
	 height: 100px;
	 background: #fff;
	 border-radius: 3px;
	 margin: 0 auto;
	 box-shadow: -10px 0 0 0  #e0e5ff inset;
}
.table {
	 width: 200px;
	 height: 8px;
	 background: #1b233e;
	 border-radius: 4px;
}

效果

燃烧的蜡烛

标签:border-radius、@keyframes

答案中,将动画拆分成3个,通过阴影显示照明效果

/*初始烛焰*/
border-radius: 8px 8px 8px 8px / 20px 20px 8px 8px;
@keyframes wind {
	0%, 22%, 49%, 62%, 81%, 100% {
		border-radius: 2px 14px 8px 8px / 20px 20px 8px 8px;
	}
	14%, 32%, 56%, 70%, 89% {
		border-radius: 14px 2px 8px 8px / 20px 20px 8px 8px;
	}
}

@keyframes size {
	0%, 22%, 49%, 62%, 81%, 100% {
		transform: scale(1,1);
	}
	14%, 32%, 56%, 70%, 89% {
		transform: scale(0.9, 1.2);
	}
}

@keyframes flickr {
	0%, 22%, 49%, 62%, 81%, 100% {
		box-shadow: 0 0 20px 0 rgba(255,202,0,0.7);
	}
	14%, 32%, 56%, 70%, 89% {
		box-shadow: 0 0 20px 0 rgba(255,202,0,.8);
	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值