【html】可拖动导航(菜单,广告的嵌入)

6 篇文章 0 订阅

仿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>

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值