zoukankan      html  css  js  c++  java
  • 运动的border,仿当当简易效果

    突然想到以前看到当当上有个效果,当鼠标移上去,图片边框是运动添加上的,还以为是css3或者是canvas做的呢,做完幽灵按钮后,才知道,so  easy,只不过是animate+position的杰作。附上代码

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    *{margin: 0;padding: 0}
    
    div.child{
    	position: relative;
    	margin: 100px auto;
    	 200px;
    	height: 200px;
    	border: 2px solid #bbb;
    	box-sizing:border-box;
    	-webkit-box-sizing:border-box;
    	background: #ccc;
    }
    .line{
    	position: absolute;
    	display: block;
    	 0;
    	height: 0;
    	background: red;
    }
    .line-top{
    	/* 200px;
    	height: 2px;*/
    	left: -2px;
    	top: -2px;
    }
    .line-right{
    	/* 2px;
    	height: 200px;*/
    	right: -2px;
    	top: -2px;
    }
    .line-bottom{
    	/* 200px;
    	height: 2px;*/
    	right: -2px;
    	bottom: -2px;
    
    }
    .line-left{
    	/* 2px;
    	height: 200px;*/
    	left: -2px;
    	bottom: -2px;
    }
    </style>
    <script src="js/jquery-1.7.2.js"></script>
    <script>
    $(function(){
    	$('.child').hover(function(){
    		$('.line-top').animate({
    			 '200px',
    			height: '2px'
    		},1000);
    		$('.line-right').animate({
    			 '2px',
    			height: '200px'
    		},1000);
    		$('.line-bottom').animate({
    			 '200px',
    			height: '2px'
    		},1000);
    		$('.line-left').animate({
    			 '2px',
    			height: '200px'
    		},1000);
    	},function(){
    		$('.line').animate({
    			 '0px',
    			height: '0px'
    		},1000);
    	});
    });
    </script>
    </head>
    <body>
    <div class="child">
    	<span class="line line-top"></span>
    	<span class="line line-right"></span>
    	<span class="line line-bottom"></span>
    	<span class="line line-left"></span>
    </div>
    </body>
    </html>
    

      当然,其他的你想要的样式,不妨举一反三做一下,也很简单,只是个运动而已

  • 相关阅读:
    PHP中如何防止跨域调用接口
    301、404、200、304、500HTTP状态
    多表联合查询
    put方式提交上传图片
    获取样式属性getComputed,currentStyle
    AjaxPro异步加载服务器的时间
    在 ASP.NET 中执行 URL 重写
    ASP.NET 的前世今生 之 .NET Framework
    asp.net 读写 XML 转载自 yiki'space
    可爱的人人
  • 原文地址:https://www.cnblogs.com/reaf/p/5825838.html
Copyright © 2011-2022 走看看