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>
    

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

  • 相关阅读:
    3.7号一周学习
    3.6号
    人月神话01
    课堂测试之全国疫情统计可视化地图第一阶段完成
    课堂测试之全国疫情统计可视化地图
    2.25号课堂作业
    2.29一周学习
    软件工程第二周开课博客
    2.25号课堂测试
    Mysql+Mycat实现数据库主从同步与读写分离
  • 原文地址:https://www.cnblogs.com/reaf/p/5825838.html
Copyright © 2011-2022 走看看