抓住Pan金莲-悬停会跑开的按钮效果【原创

来源:https://www.sucaihuo.com/js/2424.html 2017-07-15 23:11浏览(361) 收藏

一款抓住Pan金莲-悬停会跑开的按钮效果,鼠标悬停在置顶的按钮上,会触发按钮跑开移位的动画,也就时说按钮无法被鼠标固定住,效果还时不错的,喜欢的童鞋请收下吧。
抓住Pan金莲-悬停会跑开的按钮效果
分类:html/css > 按钮 难易:初级
查看演示 下载资源 下载积分: 20 积分

页面的head部分,先引入jQuery库,然后设置好页面元素的样式,代码如下:

<script type="text/javascript" src="js/jquery.min.js"></script>
<style type="text/css">
body {
  position: fixed;
  height: 100%;
  width: 100%;
  background: #446CB3;
  font-family: 'Microsoft YaHei','Lantinghei SC','Open Sans',Arial,'Hiragino Sans GB','STHeiti','WenQuanYi Micro Hei','SimSun',sans-serif;
}
body > div {
  position: absolute;
  top: 20%;
  right: 20%;
  left: 20%;
  bottom: 20%;
}

p {
  position: absolute;
  bottom: 60%;
  left: 25%;
  right: 25%;
  line-height: 1.5em;
  text-align: center;
  font-weight: 900;
  /*text-transform: uppercase;*/
  font-size: 30px;
  color: white;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
}
p > span {
  font-size: 14px;
  font-weight: 200;
  text-transform: none;
  display: block;
  padding-top: 15px;
  letter-spacing: 0.5px;
  font-weight: 400;
  color: #E4F1FE;
}
p > span > a {
  color: #E4F1FE;
  position: relative;
  font-weight: 900;
  text-decoration: none;
  border-bottom: 2px solid #E4F1FE;
  /*text-transform: uppercase;*/
  padding-bottom: 2px;
  margin: 0 2px;
  transition: .75s;
}
p > span > a:hover {
  padding-bottom: 4px;
  transition: .25s;
}

a.link {
  position: absolute;
  width: 20%;
  top: 60%;
  transition: 0.5s;
  display: block;
  border: 1px solid #BDC3C7;
  background: #fff;
  text-decoration: none;
  padding: 30px 0;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
}
a.link > span {
  display: block;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  /*text-transform: uppercase;*/
}

#catchme {
  left: 25%;
  z-index: 99;
  color: #D91E18;
  border-radius: 6px;
}

.no {
  right: 25%;
  color: black;
}
</style>

页面的body部分,设置好说明文字的容器和按钮的容器即可,代码如下:

<div>
	<p>抓住Ta,<br/>Pan金莲<span>证据确凿 - Wu松满心怒火!<br/>却不知为何,百般拼命仍抓不住Ta?</span></p>
	<a href="#" class="link" id="catchme"><span>我不是Pan金莲</span></a>
  <a href="#" class="link no"><span>吃瓜🍉群众😋</span></a> 
</div>

接着设置好鼠标的悬停事件响应,代码如下:

$('#catchme').hover(function(){  
  $(this).css('position','absolute').css('top', Math.random()*90 + '%').css('left', Math.random()*90 + '%');
});
声明:本文为原创文章,如需转载,请注明来源sucaihuo.com并保留原文链接:https://www.sucaihuo.com/js/2424.html
评论0
头像

系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791

1 2