您现在的位置:首页 >> 前端 >> 内容

clip属性使用小Demo

时间:2017/2/17 9:24:01 点击:

  核心提示:!DOCTYPE htmlhtml head meta charset=UTF-8 title/title style type=text/css img{ position: abs...
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			img{
				position: absolute;
				display: block;
				left: 50%;
				top: 50%;
				margin-left: -165px;
				margin-top: -110px;
				/*clip: rect(0px,50px,200px,0px);*/
			}
			body{
				padding-top: 200px;
			}
		</style>
	</head>
	<body>
		<img src="4.jpg" alt="" />
	</body>
	<script type="text/javascript">
		var img=document.getElementsByTagName("img")[0],p=20
		
		img.onclick=function(){
//			img.style.width=0
			var a=setInterval(function(){
				img.style.clip="rect(0,"+p+"px,220px,auto)"
			    p++
			    if(p==330){
			    	p=20
//			    	clearInterval(a)

			    }
			},10)
			
			console.log(p)
		}
	</script>
</html>

Tags:CL LI IP P属 
作者:网络 来源:qq_3596076