Draggable+InertiaPlugin+gsap实现彩色便签纸纸条拖动可写记录效果代码
代码语言:html
所属分类:拖放
代码描述:Draggable+InertiaPlugin+gsap实现彩色便签纸纸条拖动可写记录效果代码
代码标签: Draggable InertiaPlugin gsap 彩色 便签纸 拖动 可写 记录 纸条
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url('https://fonts.googleapis.com/css2?family=Playpen+Sans:wght@400;500;600&display=swap'); :root { --pink: #f45891; --yellow: #fbee9d; --green: #a9ef58; --blue: #34add1; --purple: #c97fe5; } * { margin: 0; } #board { position: relative; width: 100vw; height: 100vh; background-color: #cd995f; overflow: hidden; perspective: 1600px; display: flex; justify-content: end; align-items: end; box-sizing: border-box; padding: 50px; } .stickynote { position: absolute; width: 200px; height: 200px; box-sizing: border-box; padding: 10px; transform: rotateX(5deg); box-shadow: -1px 10px 5px -4px rgba(0, 0, 0, 0.012), inset 0 24px 30px -12px rgba(0, 0, 0, 0.3); display: flex; justify-content: center; align-items: center; } .stickynote:nth-child(n) { background: var(--purple); } .stickynote:nth-child(2n) { background: var(--pink); } .stickynote:nth-child(3n) { background: var(--green); } .stickynote:nth-child(4n) { background: var(--blue); } .stickynote:nth-child(5n) { background: var(--yellow); } .stickynote-text { border-radius: 10px; color: #373C49; font-size: 18px; font-weight: 600; border: none; background: transparent; outline: none; text-align: center; resize: none; overflow: hidden; font-family: 'Playpen Sans', cursive; } .stickynote-text:focus { background-color: rgba(0,0,0,0.1); } .stickynote-text::placeholder { color: black; opacity: 30%; } </style> </head> <body > <main id="board"></main> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.9.1.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/Draggable3.min.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/InertiaPlugin.min.js"></script> <script > /// Create stack of sticky notes const board = document.querySelector("#board") for (let i = 0; i < 100; i++) { const sticky = document.createElement("div"); sticky.classList.add("stickynote"); const text = document.createElement("textarea"); text.type = "text"; text.placeholder = "Drag Me"; text.maxLength = 100; text.classList.add("stickynote-text"); sticky.appendChild(text); board.appendChild(sticky); } // Dynamically change height of textarea document.querySelectorAll('textarea').forEach(textarea => { function setHeight() { textarea.style.height = 'auto'; textarea.style.height = `${textarea.scrollHeight}px`; } setHeight(); textarea.addEventListener('input', setHeight); textarea.addEventListener('change', setHeight); }); /.........完整代码请登录后点击上方下载按钮下载查看
网友评论0