Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

dragTest.html 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <title>Title</title>
  8. <style type="text/css">
  9. body{
  10. margin: 0 auto;
  11. padding: 100px 100px;
  12. }
  13. #app{
  14. width: 500px;
  15. height: 500px;
  16. border: 1px solid darkgray;
  17. }
  18. #tp{
  19. overflow-y: auto;
  20. width: 100%;
  21. height: 50px;
  22. border: 1px solid red;
  23. }
  24. #bt{
  25. width: 100%;;
  26. height: 450px;
  27. border: 1px solid red;
  28. }
  29. #bd{
  30. border: 1px solid #7f7f7f;
  31. cursor: s-resize;
  32. }
  33. /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
  34. ::-webkit-scrollbar {
  35. width: 10px;
  36. background-color: #fff;
  37. }
  38. /*定义滚动条轨道 内阴影+圆角*/
  39. /*::-webkit-scrollbar-track {
  40. display: none;
  41. }*/
  42. /*定义滑块 内阴影+圆角*/
  43. ::-webkit-scrollbar-thumb {
  44. border-radius: 10px;
  45. -webkit-box-shadow: inset 0 0 6px rgba(253, 253, 253, 0.3);
  46. background-color: #919191;
  47. }
  48. /*定义最上方和最下方的按钮*/
  49. /*::-webkit-scrollbar-button{
  50. display: none;
  51. }*/
  52. </style>
  53. </head>
  54. <body>
  55. <div id="app">
  56. <div id="tp" contenteditable='true'>/*/798787888888888888888888888888888888</div>
  57. <div id="bd"></div>
  58. <div id="bt"></div>
  59. </div>
  60. </body>
  61. <script>
  62. window.onload = function () {
  63. var bd = document.getElementById('bd')
  64. var tp = document.getElementById('tp')
  65. var bt = document.getElementById('bt')
  66. var initY = 0, tph = 0, bth = 0
  67. bd.onmousedown = function (ev) {
  68. tph = tp.offsetHeight
  69. bth = bt.offsetHeight
  70. initY = (ev||event).clientY
  71. console.log('点击:上高' + tph + ' 下高'+ bth + ' 初始y'+initY)
  72. document.onmousemove = function (ev2) {
  73. tp.style.cursor = 's-resize'
  74. var y = (ev2||event).clientY
  75. tp.style.height = (tph + (y - initY)) +'px'
  76. bt.style.height = (bth - (y - initY)) +'px'
  77. console.log('移动 y='+ y + '差值' + (y - initY) + '上高'+tp.style.height + '下高'+bt.style.height)
  78. }
  79. }
  80. document.onmouseup=function(){
  81. document.onmousedown=null;
  82. document.onmousemove=null;
  83. };
  84. }
  85. </script>
  86. </html>