• 鼠标拖动,改变列表宽度


    参考:

    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>左右可拖动的内容显示区</title>
        <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
        <style>
            ul,li{margin:0;padding:0;}
            body{font:14px/1.5 Arial;color:#666;}
            #box{position:relative;width:600px;height:400px;border:2px solid #000;margin:10px auto;overflow:hidden;}
            #box ul{list-style-position:inside;margin:10px;}
            #top,#bottom{color:#FFF;width:300px;height:400px;overflow:hidden;}
            #top{background:green; float:left;}
            #bottom{background:skyblue;float:right}
            #line{position:absolute;top:0;left:50%;height:100%;width:4px;overflow:hidden;background:red;cursor:w-resize;}
            /*p { cursor: text; } !* css注释: 设置鼠标移动到html p对象时鼠标变为文本选择样式 *!*/
            /*a { cursor: pointer; } !* css注释: 设置鼠标移动到a超链接对象时鼠标变为手指形状(链接选择) *!*/
            /*body { cursor: url("小图片地址")} !* 设置鼠标指针默认为一个小图片 *!*/
        </style>
        <script>
            function $(id) {
                return document.getElementById(id)
            }
            window.onload = function() {
                var oBox = $("box"), oTop = $("top"), oBottom = $("bottom"), oLine = $("line");
                oLine.onmousedown = function(e) {
                    var disX = (e || event).clientX;
                    oLine.left = oLine.offsetLeft;
                    document.onmousemove = function(e) {
                        var iT = oLine.left + ((e || event).clientX - disX);
                        var e=e||window.event,tarnameb=e.target||e.srcElement;
                        var maxT = oBox.clientWight - oLine.offsetWidth;
                        oLine.style.margin = 0;
                        iT < 0 && (iT = 0);
                        iT > maxT && (iT = maxT);
                        oLine.style.left = oTop.style.width = iT + "px";
                        oBottom.style.width = oBox.clientWidth - iT + "px";
                        $("msg").innerText='top.'+oLine.style.width+'---bottom.'+oBottom.style.width+'---oLine.offsetLeft:'+oLine.offsetLeft+'---disX:'+disX+'---tarnameb:'+tarnameb.tagName;
                        return false
                    };
                    document.onmouseup = function() {
                        document.onmousemove = null;
                        document.onmouseup = null;
                        oLine.releaseCapture && oLine.releaseCapture()
                    };
                    oLine.setCapture && oLine.setCapture();
                    return false
                };
            };
        </script>
    </head>
    <body>
    <center>左右拖动红条改变显示区域宽度<span id="msg"></span></center>
    <div id="box">
        <div id="top">
            <ul>
                <li><a href="#" target="_blank">jQuery初学实例代码集</a></li><li><a href="#" target="_blank">100多个ExtJS应用初学实例集</a></li>
                <li><a href="#" target="_blank">基于jQuery的省、市、县三级级联菜单</a></li>
                <li><a href="#" target="_blank">一个类似QQ网的JS相册展示特效</a></li>
                <li><a href="#" target="_blank">eWebEditor v4.60 最新通用精简版</a></li>
                <li><a href="#" target="_blank">FCKeditor 2.6.4.1 网页编辑器</a></li>
                <li><a href="#" target="_blank">jQuery平滑图片滚动</a></li>
                <li><a href="#" target="_blank">Xml+JS省市县三级联动菜单</a></li>
                <li><a href="#" target="_blank">jQuery 鼠标滑过链接文字弹出层提示的效果</a></li>
                <li><a href="#" target="_blank">JS可控制的图片左右滚动特效(走马灯)</a></li>
            </ul>
        </div>
        <div id="bottom">
            <ul>
                <li><a href="#" target="_blank">网页上部大Banner广告特效及图片横向滚动代码</a></li>
                <li><a href="#" target="_blank">FlexSlider网页广告、图片焦点图切换插件</a></li>
                <li><a href="#" target="_blank">兼容IE,火狐的JavaScript图片切换</a></li>
                <li><a href="#" target="_blank">jQuery仿ios无线局域网WIFI提示效果(折叠面板)</a></li>
                <li><a href="#" target="_blank">TopUp js图片展示及弹出层特效代码</a></li>
                <li><a href="#" target="_blank">jQuery仿Apple苹果手机放大镜阅读效果</a></li>
                <li><a href="#" target="_blank">Colortip 文字title多样式提示插件</a></li>
                <li><a href="#" target="_blank">网页换肤,Ajax网页风格切换代码集</a></li>
                <li><a href="#" target="_blank">超强大、漂亮的蓝色网页弹出层效果</a></li>
                <li><a href="#" target="_blank">jQuery 图像预览功能的代码实现</a></li>
            </ul>
        </div>
        <div id="line"></div>
    </div>
    </body>
    </html>
  • 相关阅读:
    Codeforces Round #678 (Div. 2)
    #Dijkstra#洛谷 4943 密室
    #线性基,点分治#洛谷 3292 [SCOI2016]幸运数字
    #线性基#LOJ 114 k大异或和
    #2-SAT,Tarjan,前缀优化建边#洛谷 6378 [PA2010]Riddle
    #树形dp,二次扫描换根法#洛谷 4284 [SHOI2014]概率充电器
    #dp#洛谷 5774 [JSOI2016]病毒感染
    #Tarjan,拓扑排序#洛谷 3436 [POI2006]PRO-Professor Szu
    #差分约束,Floyd#洛谷 2474 [SCOI2008]天平
    #Tarjan,SPFA,差分约束系统#BZOJ 2330 AcWing 368 银河
  • 原文地址:https://www.cnblogs.com/wang715100018066/p/6101811.html
Copyright © 2020-2023  润新知