美化左侧div宽度拖拉 按钮

This commit is contained in:
WangHao 2020-10-03 17:38:46 +08:00
parent d869b770e3
commit 96186a3b07
3 changed files with 775 additions and 525 deletions

View File

@ -14,7 +14,7 @@
.header-listtxet{
display: none;
}
.transition-box{
.main-right{
width: 250px!important;
}
.tabBar{
@ -52,6 +52,9 @@
.transition-box{
display: none;
}
.isresize{
display: none;
}
.sousouleft-switch{
display: block;
}

View File

@ -1,37 +1,119 @@
<template>
<div>
<div style="width: 500px">
<tags-input
v-model="tagList"
:defaulList="defaulList"
:listFilter=true
placeholder="按enter键创建标签"
@tagClose="tagClose"></tags-input>
<template>
<div class="box" ref="box">
<div class="left">
<!--左侧div内容-->
</div>
<div class="resize" title="收缩侧边栏">
</div>
<div class="mid">
<!--右侧div内容-->
</div>
</div>
</template>
<script>
import TagsInput from '../../../components/TagsInput'
export default {
components: {
TagsInput
},
data() {
return {
// list
tagList: null,
//
defaulList:[],
//
listFilter:false
}
name: 'Dashboard',
mounted () {
this.dragControllerDiv();
},
methods: {
//
tagClose(tag){
console.log(tag)
}
dragControllerDiv: function () {
var resize = document.getElementsByClassName('resize');
var left = document.getElementsByClassName('left');
var mid = document.getElementsByClassName('mid');
var box = document.getElementsByClassName('box');
for (let i = 0; i < resize.length; i++) {
//
resize[i].onmousedown = function (e) {
//
resize[i].style.background = 'red';
var startX = e.clientX;
console.log("鼠标按下后:"+e.clientX)
resize[i].left = resize[i].offsetLeft;
console.log("鼠标按下后:"+resize[i].left)
console.log("鼠标按下后:"+resize[i].offsetLeft)
//
document.onmousemove = function (e) {
var endX = e.clientX;
var moveLen = resize[i].left + (endX - startX); // endx-startx=resize[i].left+=
var maxT = box[i].clientWidth - resize[i].offsetWidth; // - =
if (moveLen < 32) moveLen = 32; // 32px
if (moveLen > maxT - 150) moveLen = maxT - 150; //150px
resize[i].style.left = moveLen; //
for (let j = 0; j < left.length; j++) {
left[j].style.width = moveLen + 'px';
mid[j].style.width = (box[i].clientWidth - moveLen - 10) + 'px';
}
};
//
document.onmouseup = function (evt) {
//
resize[i].style.background = '#d6d6d6';
document.onmousemove = null;
document.onmouseup = null;
resize[i].releaseCapture && resize[i].releaseCapture(); //ReleaseCapture()
};
resize[i].setCapture && resize[i].setCapture(); //线
return false;
};
}
},
}
}
</script>
<style lang="scss" scoped>
/* 拖拽相关样式 */
/*包围div样式*/
.box {
width: 100%;
height: 100%;
margin: 1% 0px;
overflow: hidden;
box-shadow: -1px 9px 10px 3px rgba(0, 0, 0, 0.11);
}
/*左侧div样式*/
.left {
width: calc(32% - 10px); /*左侧初始化宽度*/
height: 100%;
background: #FFFFFF;
float: left;
}
/*拖拽区div样式*/
.resize {
cursor: col-resize;
float: left;
position: relative;
top: 45%;
background-color: #d6d6d6;
border-radius: 5px;
margin-top: -10px;
width: 10px;
height: 50px;
background-size: cover;
background-position: center;
/*z-index: 99999;*/
font-size: 32px;
color: white;
}
/*拖拽区鼠标悬停样式*/
.resize:hover {
color: #444444;
}
/*右侧div'样式*/
.mid {
float: left;
width: 68%; /*右侧初始化宽度*/
height: 100%;
background: #fff;
box-shadow: -1px 4px 5px 3px rgba(0, 0, 0, 0.11);
}
</style>

File diff suppressed because it is too large Load Diff