<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<div class="main">
<div class="div_left">
例
一些不同的光标:
span.crosshair {cursor:crosshair;}
span.help {cursor:help;}
span.wait {cursor:wait;}
亲自试一试
浏览器支持
IE Firefox Chrome Safari Opera
所有主流浏览器都支持 cursor 属性。
</div>
<div class="div_right">
例
一些不同的光标:
span.crosshair {cursor:crosshair;}
span.help {cursor:help;}
span.wait {cursor:wait;}
亲自试一试
浏览器支持
IE Firefox Chrome Safari Opera
所有主流浏览器都支持 cursor 属性。
</div>
<div class="border">
<div class="line"></div>
</div>
</div>
</body>
</html>
.main{
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
background-color:#9ff;
}
.div_left{
padding:5px;
position:absolute;
top:0;
bottom:0;
left:0;
right:50%;
background-color:#99f;
}
.div_right{
padding:5px;
position:absolute;
top:0;
bottom:0;
left:50%;
right:0;
background-color:#f9f;
}
.border{
padding:0 10px;
z-index:100;
position:absolute;
top:0;
bottom:0;
left:calc(50% - 12px);
cursor:w-resize ;
}
.line{
display:block;
position:relative;
width:4px;
height:100%;
box-shadow:0 0 7px 0 rgba(30,30,30,0.1);
background-color:#ff9;
}
let flag = 0;
let iX;
let BR;
let dw;
$(".border").mousedown(function(e){
iX = e.clientX - this.offsetLeft;
BR = e.clientX - $(".div_left").outerWidth();
//左div的宽度,也就是right到left的值
dw = $(".main").outerWidth(); //外div的宽度
flag = 1;
return false;
})
$("body").mouseup((e)=>{
flag = 0;
})
$("body").mousemove(function(e){
if(flag){
let f= $(".div_left").width();
$(".border").css("left",e.clientX-iX+"px")
$(".div_left").css("right",dw-(e.clientX-BR)+"px")
//根据鼠标事件相对位置计算出div的position
$(".div_right").css("left",(e.clientX-BR)+"px")
return false;
}
})
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |