css3-animation-外边框闪烁警告

本文介绍了如何使用CSS3的animation属性结合box-shadow和outline创建外边框闪烁警告效果。讨论了animation的相关属性,如animation、box-shadow、box-sizing,以及使用outline和outline-offset的技巧。同时,指出了在Chrome中处理动画兼容性问题的复杂性,特别是关于animation-iteration-count属性的前缀需求。

相关属性

1.animation

animation
animation的属性值非常多

2.box-shadow
box-shadow: h-shadow v-shadow blur spread color inset;
css3: 属性值–*水平阴影的位置,*垂直阴影的位置,模糊距离,阴影的大小,阴影的颜色,从外侧阴影改变内侧阴影`
四周阴影的示例:
3.box-sizing

box-sizing: content-box|border-box|inherit:
4.另一种写法:利用 outline:2px dashed black; 与 outline-offset:4px;

相关示例

闪烁边框静态图
没有截动图,但是描述地来讲就是红色边框闪烁的样子。

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>css3动画闪烁框</title>
		<style type="text/css">
			.box-content {
				position: relative;
				margin: 0 auto;
				margin-top: 100px;
				width: 210px;
				height: 34px;
				background-color: #fff;
			}
			.box-wrapper {
				position: absolute;
				box-sizing: border-box;
				top: -2px;
				left: -2px;
				width: 214px;
				height: 38px;
				background-color: #F56C6C;
				/* border: 4px dashed black; */
				box-shadow:#F56C6C 0px 0px 4px;
				z-index: -9;
				box-shadow: #000;
			}
			.animation-flash {
				animation: myfirst 0.5s linear;
				-webkit-animation: myfirst 0.5s linear;
				animation-iteration-count:infinite;
				-webkit-animation-iteration-count:infinite;
			}
			@keyframes myfirst{
				0%   { opacity:1; }
				25%  { opacity:0.85; }
				50%  { opacity:0.75; }
				75%  { opacity:0.65; }
				100% { opacity:0.25; }
			}
			@-webkit-keyframes myfirst{
				0%   { opacity:1; }
				25%  { opacity:0.85; }
				50%  { opacity:0.65; }
				75%  { opacity:0.65; }
				100% { opacity:0.25; }
			}
			/* 兼容性前缀
			 ** Firefox: -moz
			 ** Safari & Chrome: -webkit
			 ** Opera: -o
			 */
		</style>
	</head>
	<body>
		<div class="box-content">
			<div class="box-wrapper animation-flash">	
			</div>
		</div>
	</body>
</html>

遇到的问题

1.四周阴影
2.在Chrome中 animation: myfirst 0.5s linear; animation的前三个属性不需要加浏览器的兼容性前缀,但是 animation-iteration-count 属性开始就要写兼容性前缀了。比较麻烦的是不同浏览器不同属性的兼容情况不同。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值