Home > front end >  Have done bosses can be drag type percentage more progress bar/slider
Have done bosses can be drag type percentage more progress bar/slider

Time:10-04



Vue or pure js

CodePudding user response:

Iview panel split this principle should be the same with you, you can change

CodePudding user response:

Made a, there is little problem, you see:

 & lt; ! DOCTYPE html> 


<meta charset="utf-8"/& gt;

<style>
The box {
Height: 50 px;
Overflow: hidden;
Display: table - cell;
Margin: 0 auto;
padding: 0;
position: absolute;
top: 0;
Left: 0;
The font - size: 40 px;
text-align: center;
vertical-align: middle;
Color: white.
The text - shadow: 3 px 3 px 2 p # 333;
}
</style>

<body>









<script SRC="https://bbs.csdn.net/Script/jquery-1.11.3.min.js" & gt; </script>
<script SRC="https://bbs.csdn.net/Script/jquery-easyui%201.4.4/jquery.easyui.min.js" & gt; </script>
<script SRC="https://bbs.csdn.net/Script/easyuiExtend.js" & gt; </script>
<script>
Var data=https://bbs.csdn.net/topics/[10, 20, 50, 11, 66].
Var sum=data. Reduce ((prev, item)=& gt; {return prev + item; }, 0);
Var boxs=$(' box ');
The function Init (I) {
Data. The forEach ((n, index, arr)=& gt; {
$(boxs [index]). CSS ({
Width: 1000 * n/sum + 'p',
Left: the index===0? 0: (boxs [index - 1]. The offsetLeft + boxs [index - 1]. OffsetWidth) + 'px'
});
The console. The log (JSON. Stringify ($(boxs [index]). The CSS (' width ')));
$(boxs [index]). The text (n/sum (100 *). ToFixed (0) + '%');
});
}
The Init ();
Boxs. The resizable ({
MaxWidth: 800,
MaxHeight: 600,
MinWidth: 20,
Handles: 'e, w,
OnResize: function (e) {
Var index=$(this). The index ();
Var dir=e.d ata. Dir==='e'? 1:1;
If (data [dir] index + + data [index] - e.d ata. Width * sum/1000 & lt; 20) return false.
Data [dir] index + +=data [index] - e.d ata. Width * sum/1000;
Data [index]=e.d ata. Width * sum/1000;
Init (index);
}, onStopResize: Init
});

</script>

CodePudding user response:

The slider validation: https://gitee.com/tcweidao/slide-verification
  • Related