一款可拖动的个人信息卡片,在信息窗口长按鼠标左键可拖动卡片的位置,点击字母i的图标按钮,则会显示详细的联系信息等内容,再点击向下的箭头即可恢复原来的状态,喜欢的童鞋请收下吧。
页面的head部分,需远程调用reset.min.css样式文件和font-awesome图标字体库,并设置好页面元素的样式,代码如下:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<style type="text/css">
body {
background: url(images/bg.png) no-repeat center center fixed;
background-size: cover;
overflow: hidden;
cursor: default;
}
#card {
width: 400px;
height: 300px;
position: relative;
margin: 10% auto;
border-radius: 8px;
box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.2), 0px 2px 6px rgba(0, 0, 0, 0.4);
overflow: hidden;
}
#blur {
background: url(images/bg.png) no-repeat center center fixed;
background-size: cover;
width: 430px;
height: 330px;
position: relative;
top: -15px;
left: -15px;
border-radius: 8px;
-webkit-filter: blur(8px);
-moz-filter: blur(8px);
filter: blur(8px);
}
#color {
background: rgba(255, 255, 255, .60);
width: 430px;
height: 330px;
}
#profile {
cursor: grabbing;
width: 400px;
height: 300px;
position: relative;
top: -330px;
border-radius: 8px;
}
img {
width: 100px;
height: 100px;
border-radius: 100px;
position: relative;
top: 32px;
display: block;
margin: 0 auto;
-webkit-filter: sepia(.25);
-moz-filter: sepia(.25);
filter: sepia(.25);
}
h1 {
color: rgba(38, 50, 56, 1);
font-family: 'Microsoft YaHei','Lantinghei SC','Open Sans',Arial,'Hiragino Sans GB','STHeiti','WenQuanYi Micro Hei','SimSun',sans-serif;
font-size: 36px;
font-weight: 700;
text-align: center;
position: relative;
top: 48px;
}
p {
color: rgba(38, 50, 56, .87);
font-family: 'Microsoft YaHei','Lantinghei SC','Open Sans',Arial,'Hiragino Sans GB','STHeiti','WenQuanYi Micro Hei','SimSun',sans-serif;
font-size: 16px;
font-weight: 400;
text-align: center;
position: relative;
top: 56px;
}
a {
color: rgba(255, 255, 255, 1);
transition: color 0.4s;
text-decoration: none;
}
a:hover {
color: rgba(255, 255, 255, .70);
transition: color 0.4s;
}
.info {
text-align: center;
margin: 0 auto;
position: relative;
top: 86px;
background: rgba(38, 50, 56, 1);
width: 32px;
height: 32px;
border-radius: 100px;
background-position: center center;
background-size: cover;
transition: all 0.2s ease;
z-index: 0;
}
.info.active {
width: 100%;
height: 200%;
position: relative;
top: -100%;
background: rgba(38, 50, 56, 1);
transition: width .1s ease, height .2s ease, top .2s ease, z-index .2s ease;
z-index: 999;
}
.info i.block {
color: rgba(255, 255, 255, .6);
display: block;
}
.info .fa-info {
padding: 8px;
cursor: pointer;
visibility: visible;
opacity: 1;
transition: visibility 0s, opacity 0.4s ease;
}
.info.active .fa-info {
visibility: hidden;
opacity: 0;
transition: visibility 0s, opacity 0.4s ease;
}
.info .fa-angle-down {
cursor: pointer;
visibility: hidden;
}
.info.active .fa-angle-down {
position: relative;
margin: 0 auto;
width: 24px;
height: 24px;
padding: 4px;
visibility: visible;
position: relative;
top: 128px;
animation-name: visible;
animation-duration: 0.3s;
}
@keyframes visible {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.info p {
color: rgba(255, 255, 255, 1);
font-family: 'Microsoft YaHei','Lantinghei SC','Open Sans',Arial,'Hiragino Sans GB','STHeiti','WenQuanYi Micro Hei','SimSun',sans-serif;
font-size: 18px;
line-height: 110%;
font-weight: 400;
text-align: center;
padding: 24px;
position: relative;
top: 144px;
visibility: hidden;
}
.info.active p {
visibility: visible;
animation-name: entrance-first;
animation-duration: 0.4s;
line-height: 28px;
}
.info .link {
visibility: hidden;
margin: 24px 24px 0px 24px;
padding: 16px 4px 4px 4px;
cursor: pointer;
position: relative;
top: 144px;
}
.info.active .link {
visibility: visible;
animation-name: entrance-second;
animation-duration: 0.5s;
}
@keyframes entrance-first {
0% {
top: 200px;
}
100% {
top: 144px;
}
}
@keyframes entrance-second {
0% {
top: 200px;
}
100% {
top: 144px;
}
}
</style>
接着远程调用jQuery库和jquery-ui.js,并引入本地JS文件,代码如下:
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script type="text/javascript" src="js/index.js"></script>
页面的body部分,需要将不同的内容放入对应的div容器,代码如下:
<div id="card">
<div id="blur">
<div id="color"></div>
</div>
<div id="profile">
<img src="http://www.sucaihuo.com/other/avatar/dir/905.jpg" alt="User" />
<h1>Richer</h1>
<p>html + javascript + PHP + MySQL</p>
<div class="info">
<i class="fa fa-info fa-1x block"></i>
<i class="fa fa-angle-down fa-2x block"></i>
<p>UI设计其实挺重要的,有不同的想法可以 @ <a href="http://www.sucaihuo.com" target="_blank">Richer</a></p>
<p>联系方式</p>
<a class="link" href="http://www.sucaihuo.com" target="_blank"><i class="fa fa-qq"></i></a>
<a class="link" href="http://www.sucaihuo.com" target="_blank"><i class="fa fa-wechat"></i></a>
<a class="link" href="http://www.sucaihuo.com" target="_blank"><i class="fa fa-weibo"></i></a>
</div>
</div>
</div>
系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791