mamimi

custom + draggable chatbox

Oct 22nd, 2022
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. <style>
  2. @font-face {
  3. font-family: sant joan;
  4. src: url(https://dl.dropbox.com/s/iwvkrg8ccgd1pf4/SantJoanDespi-Regular.otf);
  5. }
  6. </style>
  7. <style>
  8. #mydiv {
  9. position: absolute;
  10. background: white;
  11. height:312px;
  12. border:3.4px double #E4A8CA;
  13. border-radius:15px 15px 1px 1px;
  14.  
  15. }
  16.  
  17. #mydivheader {
  18. cursor: move;
  19. background: white;
  20. font-family: sant joan;
  21. text-shadow: -1px 0 #CC9FCA, 0 1px #CC9FCA, 1px 0 #CC9FCA, 0 -1px #CC9FCA;
  22. height:40px;
  23. font-size:35px;
  24. border-radius:15px 15px 1px 1px;
  25. color: #fff;
  26. }
  27. </style>
  28. <body>
  29. <div id="mydiv">
  30. <div id="mydivheader"><marquee> o draggable! o</marquee></div>
  31. <iframe src="https://www5.cbox.ws/box/?boxid=938082&boxtag=YRWGwr" width="250" height="270" allowtransparency="yes" allow="autoplay" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto"></iframe>
  32. </div>
  33.  
  34. <script>
  35. //Make the DIV element draggagle:
  36. dragElement(document.getElementById("mydiv"));
  37.  
  38. function dragElement(elmnt) {
  39. var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  40. if (document.getElementById(elmnt.id + "header")) {
  41. /* if present, the header is where you
  42. move the DIV from:*/
  43. document.getElementById(elmnt.id +
  44. "header").onmousedown = dragMouseDown;
  45. } else {
  46. /* otherwise, move the DIV from anywhere inside the DIV:*/
  47. elmnt.onmousedown = dragMouseDown;
  48. }
  49.  
  50. function dragMouseDown(e) {
  51. e = e || window.event;
  52. e.preventDefault();
  53. // get the mouse cursor position at startup:
  54. pos3 = e.clientX;
  55. pos4 = e.clientY;
  56. document.onmouseup = closeDragElement;
  57. // call a function whenever the cursor moves:
  58. document.onmousemove = elementDrag;
  59. }
  60. function elementDrag(e) {
  61. e = e || window.event;
  62. e.preventDefault();
  63. // calculate the new cursor position:
  64. pos1 = pos3 - e.clientX;
  65. pos2 = pos4 - e.clientY;
  66. pos3 = e.clientX;
  67. pos4 = e.clientY;
  68. // set the element's new position: elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  69. elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  70. }
  71.  
  72. function closeDragElement() {
  73. /* stop moving when mouse button is released:*/
  74. document.onmouseup = null;
  75. document.onmousemove = null;
  76. }
  77. }
  78. </script>
  79. </body>
  80. </html>
Advertisement
Add Comment
Please, Sign In to add comment