天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

js 分欄效果實現代碼

網上我也見到一些分欄效果,也有一個jquery的插件jquery.splitter.js, 但是他們基本都沒有解決一個問題:如果頁面上有iframe, 當拖動分割線經過iframe的時候,鼠標不聽使喚了,我曾經開過帖子討論過這個問題。本例采用一個小技巧解決了這個問題,使拖動流暢。
復制代碼 代碼如下:
<html>
<head>
<title>Splitter demo</title>
<style>
            #splitter_container{
             width: 100%;
             height: 100%;
             border: solid #eee 1px;
             margin: 0px;
             padding: 0px;
             overflow: hidden;
            }
            #splitter_left_panel{
             width: 300px;
             height: 100%;
             float: left;
             border: solid blue 0px;
            }
            #splitter_bar{
             width: 8px;
             height: 100%;
             float: left;
             background-color: #ccc;
             cursor: col-resize;
            }
            #splitter_right_panel{
             height: 100%;
             padding-top: 10px;
            }
</style>
<script>
/*
* splitter.js
* author: sunxing007
* http://blog.csdn.NET/sunxing007
* date: 08/26/2009

**************************************************************************************
The css script below is needed for the html page when using splitter.js, please save
it as splitter.css, and modify it carefully.
**************************************************************************************
#splitter_container{
width: 100%;
height: 100%;
border: solid #eee 1px;
margin: 0px;
padding: 0px;
overflow: hidden;
}
#splitter_left_panel{
width: 300px;
height: 100%;
float: left;
border: solid blue 0px;
}
#splitter_bar{
width: 8px;
height: 100%;
float: left;
background-color: #ccc;
cursor: col-resize;
}
#splitter_right_panel{
height: 100%;
padding-top: 10px;
}
**************************************************************************************
How to use this splitter?
**************************************************************************************
<!--
     <html>
<head>
<title>Splitter demo</title>
<link href="splitter.css" type="text/css" rel="stylesheet" />
<script src="splitter.js"></script>
</head>
<body onload="Splitter.init({id: 'splitter_Container'});">
<div id="splitter_container">
<div id="splitter_left_panel">
left panel
<!--you can put any html code here-->
</div>
<div id="splitter_bar"></div>
<div id="splitter_right_panel">
right panel
<!--you can put any html code here-->
</div>
</div>
</body>
</html>
-->
**************************************************************************************
*/

/** this is a helper function used to get the dom element specified by id **/

function $(id){return document.getElementById(id);}

/** the main functionality of splitter **/

var Splitter = {
    container: null,
    lPanel: null,
    rPanel: null,
    bar: null,
movingBar: null,
//左面板初始,最大,最小寬度
    lPanelInitWidth: '250px',
    lPanelMaxWidth: '500px',
    lPanelMinWidth: '200px',
    rPanelInitWidth: '800px',
    rPanelMaxWidth: '999px',
    rPanelMinWidth: '500px',
    //分隔線被拖動的時候的顏色
    barActiveColor: '#0080ff',
    //左面的面板是否設置最大/最小寬度
    isWidthLimit: true,
    init: function(config){
if(!config.id){
alert('Can not initialize splitter.');
return;
}
if($(config.id)){
this.container = $(config.id);
if(!($('splitter_left_panel')&&$('splitter_right_panel')&&$('splitter_bar'))){
alert('Can not initialize splitter.');
return;
}
else{
this.lPanel = $('splitter_left_panel');
this.rPanel = $('splitter_right_panel');
this.bar = $('splitter_bar');
}
}

if(config.lPanelMaxWidth){
this.lPanelMaxWidth = config.lPanelMaxWidth;
}
if(config.lPanelMinWidth){
this.lPanelMinWidth = config.lPanelMinWidth;
}
if(config.rPanelMaxWidth){
this.rPanelMaxWidth = config.rPanelMaxWidth;
}
if(config.rPanelMinWidth){
this.rPanelMinWidth = config.rPanelMinWidth;
}
if(config.lPanelInitWidth){
this.lPanelInitWidth = config.lPanelInitWidth;
}
if(config.rPanelInitWidth){
this.rPanelInitWidth = config.rPanelInitWidth;
}
if(config.barActiveColor){
this.barActiveColor = config.barActiveColor;
}
//alert(typeof(config.isWidthLimit));
if(config.isWidthLimit!=undefined){
this.isWidthLimit = config.isWidthLimit;
}
var mask = document.createElement('div');
document.body.appendChild(mask);
with(mask.style){
position = 'absolute';
left = '0px';
top = '0px';
zIndex = 900;
width = '100%';
height = '100%';
display = 'none';
backgroundColor = '#ccc';
filter = 'alpha(opacity=10)';
}
//background-color:red;filter:alpha(opacity=60)
Splitter.mask = mask;
this.bar.onmousedown = Splitter.start;
    },
    start: function(){
var o = Splitter.container;
o.lastMouseX = event.x;
Splitter.mask.style.display = '';
var movingBar = document.createElement('div');
Splitter.container.appendChild(movingBar);
with(movingBar.style){
position = 'absolute';
left = Splitter.bar.offsetLeft + 'px';
top = '0px';
width = Splitter.bar.currentStyle.width;
height = '100%';
backgroundColor = Splitter.barActiveColor;
zIndex = 999;
cursor = 'col-resize';
}
movingBar.dx = 0;
Splitter.movingBar = movingBar;
document.onmousemove = Splitter.move;
document.onmouseup = Splitter.end;
    },
    move: function(){
var o = Splitter.container;
var dx = event.x - o.lastMouseX;
Splitter.movingBar.dx = Splitter.movingBar.dx + dx;
var left = parseInt(Splitter.movingBar.style.left) + dx;
Splitter.movingBar.style.left = left;
o.lastMouseX = event.x;
    },
    end: function(){
document.onmousemove = null;
document.onmouseup = null;
Splitter.mask.style.display = 'none';
var dx = Splitter.movingBar.dx;
Splitter.container.removeChild(Splitter.movingBar);
var w = parseInt(Splitter.lPanel.currentStyle.width) + dx;
if(Splitter.isWidthLimit){
        var _width = (w > parseInt(Splitter.lPanelMaxWidth) ? Splitter.lPanelMaxWidth : (w < parseInt(Splitter.lPanelMinWidth) ?
Splitter.lPanelMinWidth : w));
        w = _width;
}
Splitter.lPanel.style.width = w;
    }
};
</script>
</head>
<body onload="Splitter.init({id: 'splitter_Container', isWidthLimit: true});">
    <div id="splitter_container">
            <div id="splitter_left_panel">
                <iframe frameborder="0" height="100%" id="" width="100%" src="http://www.jb51.NET"></iframe>
            </div>
            <div id="splitter_bar"></div>
            <div id="splitter_right_panel">
                    在此處右鍵察看源代碼并把其中的js保存為splitter.js<br>
                    splitter.js使用方法:<br>
                    頁面上需要有一個div作為容器(id=splitter_container): 可拖動效果就在這個容器里面進行<br>
                    容器里面需要有3個div,分別代表左欄(id=splitter_left_panel),分割線(id=splitter_bar), 右欄(id=splitter_right_panel)<br>
                    這4個div需要用css修飾一下<br>
                    <code>
#splitter_container{
width: 100%;
height: 100%;
border: solid #eee 1px;
margin: 0px;
padding: 0px;
overflow: hidden;
}<br>
#splitter_left_panel{
width: 300px;
height: 100%;
float: left;
border: solid blue 0px;
}<br>
#splitter_bar{
width: 8px;
height: 100%;
float: left;
background-color: #ccc;
cursor: col-resize;
}<br>
#splitter_right_panel{
height: 100%;
padding-top: 10px;
}
</code>
<br><br>
給body加上onload事件處理函數,以觸發splitter: <br>
onload="Splitter.init({id: 'splitter_Container', isWidthLimit: true});" <br>
Splitter的init方法傳入一個json對象作為配置參數,其中容器id是必需的.<br>
還可以配置更多的參數, 比如:<br>
isWidthLimit: 可選值true, false, 設置左面板是否限制寬度;<br>
lPanelMaxWidth: 左面板最大寬度,比如: 500px;<br>
lPanelMinWidth: 左面板最小寬度,比如: 100px;<br>
barActiveColor: 分割線拖動的時候的顏色: 比如'red', '#0080ff';<br>
更多web開發相關的內容就在<a href='http://blog.csdn.NET/sunxing007'>blog.csdn.NET/sunxing007</a>    
            </div>
    </div>
</body>
</html>

JavaScript技術js 分欄效果實現代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 青青青青久久久久国产的 | 99视频一区 | 久久免费看视频 | 国产探花在线精品一区二区 | 国产又粗又黄又爽的大片 | 最近中文字幕在线中文高清版 | 亚洲欧美色综合影院 | 国产在线一区观看 | 一本之道高清在线观看免费 | 国语自产精品一区在线视频观看 | 一本一本之道高清在线观看 | 亚洲欧美日韩国产另类电影 | 辣文肉高h粗暴 | 年轻老师毛茸茸自由性 | 高H纯肉NP 弄潮NP男男 | 精品久久久无码21P发布 | 色色色999| 亚洲综合色在线视频久 | 日本最新免费区中文 | 久久久久久久免费 | 广播电台在线收听 | 王雨纯羞羞 | 久久日本精品在线热 | 久久亚洲一级α片 | 色情www日本欧美 | 久久精品国产亚洲AV影院 | 浴室里强摁做开腿呻吟的漫画男男 | 中文字幕亚洲无线码在线 | 国产白丝精品爽爽久久久久久蜜臀 | 国产精品高潮AV久久无码 | 强上轮流内射高NP男男 | 国精品产露脸偷拍视频 | 久久精品九九亚洲精品天堂 | 亚洲色大成网站www久久九九 | 亚洲视频中文字幕在线观看 | 色AV色婷婷96人妻久久久 | 免费看a毛片 | 全黄h全肉细节全文 | 99久久人妻无码精品系列性欧美 | 日本高清免费在线观看 | 日本经典片免费看 |