仿layui可拖动目录
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>可拖动导航</title>
<link rel="stylesheet" type="text/css" href="../layui/css/layui.css" />
<script language="javascript" src="../layui/layui.js"></script>
<script src="js/jquery-1.8.3.min.js" type="text/javascript"></script>
<style>
.menu-fire {
width:100px;
height:200px;
position:fixed;
top:340px;
left:60px;
/*background:url(../images/news-d.png) no-repeat;*/
cursor:move;
border: 1px solid black;
}
*html .menu-fire {
position:absolute;
top:expression(eval(document.documentElement.scrollTop));
margin-top:340px;
border: 1px solid black;
}
.layui-layer-title {
padding: 0 60px 0 60px;
height: 42px;
line-height: 42px;
border-bottom: 1px solid #eee;
font-size: 14px;
color: #333;
overflow: hidden;
background-color: #F8F8F8;
border-radius: 2px 2px 0 0;
}
.layui-layer-content {
background-color: white;
padding: 10px;
position: relative;
overflow: auto;
font-size: 10px;
}
</style>
</head>
<body style="height:1000px">
111
<div class="menu-fire" id="fd">
<div class="layui-layer-title" style="cursor: move;">目录</div>
<div id="" class="layui-layer-content">
<ul class="site-dir layui-layer-wrap" style="display: block;">
<li><a href="#use"><cite>消防设计审核公示</cite></a></li>
<li><a href="#table"><cite>竣工消防验收公示</cite> <span class="layui-badge-dot"></span></a></li>
<li><a href="#access"><cite>消防安全检查公示</cite></a></li>
<li><a href="#access"><cite>行政处罚公示</cite></a></li>
<li><a href="#access"><cite>重大火灾隐患公示</cite></a></li>
</ul>
</div>
</div>
</body>
<script type="text/javascript">
$(function () {
var box = $('.menu-fire .box');
$('.menu-fire').hover(function () {
box.stop().show(300);
}, function () {
box.stop().hide(150);
})
})
$(function () {
var box = document.getElementById('fd');
box.onmousedown = function (event) {
var e = event || window.event,
t = e.target || e.srcElement,
x1 = e.clientX,
y1 = e.clientY,
dragLeft = this.offsetLeft,
dragTop = this.offsetTop;
document.onmousemove = function (event) {
var e = event || window.event,
t = e.target || e.srcElement,
x2 = e.clientX,
y2 = e.clientY,
x = x2 - x1,
y = y2 - y1;
box.style.left = (dragLeft + x) + 'px';
box.style.top = (dragTop + y) + 'px';
}
document.onmouseup = function () {
this.onmousemove = null;
}
}
})
</script>
</html>