zoukankan      html  css  js  c++  java
  • 幽灵按钮实例

    幽灵按钮,听名字有点不解?无碍,简单的来说就是一个按钮,移上去背景动一下,然后弹出个提示框,提示框在按钮的正上方而且居中,按钮上方有个图片,移上去有旋转360deg效果。不多说了,还是附上代码吧。由于采用了css3属性,所以,只兼容高级浏览器

    主要知识点:
    transform
    transition
    box-sizing
    border-radius

    html:

    <!doctype html>
    <html lang="en">
    <head>
    	<meta charset="UTF-8">
    	<title>幽灵按钮</title>
    	<link rel="stylesheet" href="style.css">
    </head>
    <body>
    <!-- 
    主要知识点:
    transform
    transition
    box-sizing
    border-radius
     -->
    <div class="box">
    	<div class="link link-miss">
    		<span class="icon"></span>
    		<a href="#" class="button" data-title="my mission is clear">
    			<span class="line line-top"></span>
    			<span class="line line-left"></span>
    			<span class="line line-right"></span>
    			<span class="line line-bottom"></span>
    			MISSION
    		</a>
    	</div>
    	<div class="link link-play">
    		<span class="icon"></span>
    		<a href="#" class="button" data-title="this is my playground">
    			<span class="line line-top"></span>
    			<span class="line line-left"></span>
    			<span class="line line-right"></span>
    			<span class="line line-bottom"></span>
    			MISSION
    		</a>
    	</div>
    	<div class="link link-touch">
    		<span class="icon"></span>
    		<a href="#" class="button" data-title="lets to something together">
    			<span class="line line-top"></span>
    			<span class="line line-left"></span>
    			<span class="line line-right"></span>
    			<span class="line line-bottom"></span>
    			MISSION
    		</a>
    	</div>
    	<div class="tip">
    		<em></em>
    		<span></span>
    	</div>
    </div>
    <script src="js/jquery-1.7.2.js"></script>
    <script>
    $(function(){
    	$('.link .button').hover(function(){
    		var title=$(this).attr('data-title');
    		$('.tip em').text(title);
    		var pos=$(this).offset().left;
    		var dis=($('.tip').outerWidth()-$(this).outerWidth())/2;
    		$('.tip').css({
    			left:(pos-dis)+'px',
    			opacity:1
    		}).animate({
    			top:'200',
    			opacity:1
    		},300);
    
    	},function(){
    		$('.tip').animate({
    			top:160,
    			opacity:0
    		});
    	},300);
    });
    </script>
    </body>
    </html>
    

    css:

    *{
    	margin: 0;
    	padding: 0;
    }
    body{
    	background: #333;
    }
    .box{
    	 1000px;
    	height: 280px;
    	margin: 50px auto;
    }
    .box .link{
    	 205px; 
    	height: 280px;
    	margin: 0 20px;
    	float: left; 
    	position: relative;
    }
    /*span*/
    .link .icon{
    	 100%;
    	height: 190px; 
    	display: inline-block;
    	transition:0.2s linear;
    	-webkit-transition:0.2s linear;
    	-ms-transition:0.2s linear;
    	-o-transition:0.2s linear;
    	-moz-transition:0.2s linear;
    }
    .link-miss .icon{
    	background:url(img/0.jpg) no-repeat center center;
    }
    .link-play .icon{
    	background:url(img/1.jpg) no-repeat center center;
    }
    .link-touch .icon{
    	background:url(img/2.jpg) no-repeat center center;
    }
    .link .icon:hover{
    	tansform:rotate(360deg) scale(1.2);
    	-ms-transform:rotate(360deg) scale(1.2);
    	-webkit-transform:rotate(360deg) scale(1.2);
    	-o-transform:rotate(360deg) scale(1.2);
    	-moz-tansform:rotate(360deg) scale(1.2);
    }
    .button{
    	position: relative; 
    	display: block;
    	 180px;
    	height: 50px;
    	text-decoration: none;
    	line-height: 50px;
    	color: #2bcb70;
    	font-family: sans-serif;
    	font-weight: bold;
    	border: 2px solid rgba(255,255,255,0.8);
    	padding-left: 20px;
    	margin: 0 auto;
    	box-sizing:border-box;
    	-webkit-box-sizing:border-box;
    	background: url(img/right.jpg) no-repeat 130px center;
    	transition:0.2s ease;
    	-webkit-transition:0.2s ease;
    	-ms-transition:0.2s ease;
    	-o-transition:0.2s ease;
    	-moz-transition:0.2s ease;
    }
    .button:hover{
    	border: 2px solid rgba(255,255,255,1);
    	background-position: 140px center; 
    }
    .button .line{
    	display: block;
    	position: absolute;
    	background: none;
    	transition:0.2s ease;
    	-webkit-transition:0.2s ease;
    	-ms-transition:0.2s ease;
    	-o-transition:0.2s ease;
    	-moz-transition:0.2s ease;
    }
    .button:hover .line{
    	background: #fff;
    }
    /*top 高度不变,宽度在变,位置从左到右*/
    .button .line-top{
    	 0px; 
    	height: 2px;
    	left: -110%;
    	top: -2px;
    }
    .button:hover .line-top{
    	 180px;
    	left: -2px;
    }
    .button .line-bottom{
    	 0px; 
    	height: 2px;
    	right: -110%;
    	bottom: -2px;
    }
    .button:hover .line-bottom{
    	 180px;
    	right: -2px;
    }
    .button .line-left{
    	 2px; 
    	height: 0px;
    	bottom: -110%;
    	left: -2px;
    	
    }
    .button:hover .line-left{
    	 2px;
    	height: 50px;
    	bottom: -2px;
    	left: -2px;
    }
    .button .line-right{
    	 2px; 
    	height: 0px;
    	top: -110%;
    	right: -2px;
    	
    }
    .button:hover .line-right{
    	 2px;
    	height: 50px;
    	top: -2px;
    	right: -2px;
    }
    .box .tip{
    	position: absolute;
    	padding: 0 14px;
    	height: 35px;
    	line-height: 35px;
    	background: #2dcb70;
    	top: 160px;
    	font-size: 16px;
    	font-weight: normal;
    	text-transform: none;
    	margin: 0 auto;
    	border-radius: 3px;
    	opacity: 0;
    
    }
    .tip em{
    	font-style: normal;
    
    }
    .tip span{
    	position: absolute;
    	 0;
    	height: 0;
    	overflow: hidden;
    	border: 7px solid transparent;
    	border-top-color: #2dcb70;
    	left: 50%;
    	margin-left: -3px;
    	bottom:-14px;
    }
    

      

  • 相关阅读:
    20191112 Spring Boot官方文档学习(4.5-4.6)
    20191112 Spring Boot官方文档学习(4.4)
    (转)service apache2 restart失败
    (mark)ubuntu16.04下安装&配置anaconda+tensorflow新手教程
    解决ssh连接中断程序终止的问题——tmux
    Tensorflow取消占用全部GPU
    Linux大文件split分割以及cat合并
    常用压缩/解压操作
    HM16.0帧内预测重要函数笔记
    GIT LFS 使用笔记
  • 原文地址:https://www.cnblogs.com/reaf/p/5825808.html
Copyright © 2011-2022 走看看