Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
name
comment
submit
css
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300&display=swap'); * { box-sizing: border-box; } body { padding: 0; margin: 0; font-family: 'Nunito', sans-serif; background-color: #262527; overflow:hidden; } input, textarea, button { font-family: 'Nunito', sans-serif; } .wrapper { width: 100%; height: 100vh; color: #fae881; overflow:hidden; } .flex_box { display: flex; justify-content: center; align-items: center; flex-direction: column; } .box { position: absolute; background-color: black; width: 50px; height: 50px; transition: 0.2s; } form { position: absolute; padding: 30px 20px; width: 320px; border-radius: 7px; background-color: white; backdrop-filter: blur(5px); background-color: rgba(158, 189, 199, 0.288); overflow: hidden; } .input { display: flex; flex-direction: column; } input, textarea { padding: 8px 10px; margin: 3px 8px 16px 8px; background-color: rgba(222, 239, 248, 0.877); border: 0px transparent; border-radius: 5px; color:rgb(97, 4, 184); font-size: 16px; word-break: break-all; /* haven't found the best solution here yet, paragraphs are difficult to deal with */ hyphens: auto; z-index: 1; } label { margin: 0 8px; font-size: 14px; color: white; } .button_wrapper { display: flex; justify-content: flex-end; } button { padding: 8px 14px; margin: 20px 8px 0 0; border-width: 0px; border-radius: 5px; color: white; background-color: #b69269; transition: 0.3s; z-index: 1; } button:hover { color: rgb(60, 35, 153); background-color: white; } .star { position: absolute; transition: 1s; overflow: hidden; opacity: 1; height: 15px; width: 15px; border-radius: 50%; z-index: -90; } .star svg { height: 100%; width: auto; } .star_inner { height: 15px; } .cover { position: fixed; top: 0px; left: 0px; pointer-events: none; height: 100vh; width: 100%; z-index: 999; overflow: hidden; } .ghost { position: absolute; padding: 8px 10px; border: 0px transparent; border-radius: 5px; z-index: 1; color:rgb(97, 4, 184); font-size: 16px; display: flex; flex-wrap: wrap; } .ghost > div { margin: 0; padding: 0; transition: 5s; } .blank { width: 4px; } form.fade { animation: fade forwards ease 5s; } @keyframes fade { 0% { opacity: 1; transform: translate(0vw, 0) skew(0); } 20% { opacity: 0.8; transform: translate(0vw, 0) skew(0); } 100% { opacity: 0; transform: translate(50vw, -50vh) skew(-45deg); } } form.fade_in { animation: fade_in forwards ease 6s; } @keyframes fade_in { 0% { opacity: 0; transform: translate(-50vw, 150vh) skew(-45deg); } 50% { opacity: 0; } 100% { opacity: 1; transform: translate(0) skew(0); } } ::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */ color: rgb(140, 145, 216); } :-ms-input-placeholder { /* Internet Explorer 10-11 */ color: rgb(140, 145, 216); } ::-ms-input-placeholder { /* Microsoft Edge */ color: rgb(140, 145, 216); } .sign { position: absolute; color: white; bottom: 10px; right: 10px; font-size: 10px; } a { color: white; text-decoration: none; } a:hover { text-decoration: underline; }
JavaScript
function init() { //animating form const button = document.querySelector('button') const name = document.querySelector('.name') const comment = document.querySelector('.comment') const cover = document.querySelector('.cover') const form = document.querySelector('form') let letterCount = 0 const createGhostLetters = (text, className) =>{ return text.split('').map( letter =>{ return `
${letter}
` }).join('') } const createGhostDiv = (target, className) =>{ if (!target.value) return target.placeholder = '' const ghostDiv = document.createElement('div') const targetSpec = target.getBoundingClientRect() ghostDiv.classList.add('ghost') ghostDiv.innerHTML = createGhostLetters(target.value, className) ghostDiv.style.top = `${targetSpec.y}px` ghostDiv.style.left = `${targetSpec.x}px` ghostDiv.style.height = `${targetSpec.height}px` ghostDiv.style.width = `${targetSpec.width}px` cover.appendChild(ghostDiv) target.value = '' } const setupGhostLetterMotion = (target, className)=>{ createGhostDiv(target, className) const letters = document.querySelectorAll(`.${className}`) letters.forEach((letter,i)=>{ const letterSpec = letter.getBoundingClientRect() letter.style.top = `${letterSpec.y}px` letter.style.left = `${letterSpec.x}px` letter.style.color = 'white' letter.style.transition = '1s' setTimeout(()=>{ letter.style.position = 'fixed' letter.style.transition = '5s' letter.style.top = `-${window.innerHeight / 2}px` letter.style.left = `${letterSpec.x + window.innerWidth / 2}px` },(letters.length - i) * 150) }) letterCount = letterCount < letters.length ? letters.length : letterCount } const handleSubmit = e =>{ e.preventDefault() form.classList.remove('fade_in') form.classList.add('fade') setupGhostLetterMotion(name,'name_letter') setupGhostLetterMotion(comment,'comment_letter') setTimeout(()=>{ form.classList.remove('fade') form.classList.add('fade_in') name.placeholder = 'your name...?' comment.placeholder = 'enter whatever you feel like...' letterCount = 0 },3000 + (letterCount * 100)) } button.addEventListener('click', (e)=>handleSubmit(e)) const starSvg = `
` const animationPatterns = [ ['0','1'],['0','1'],['0','1'],['0','1'],['0','1'], ['1','1'],['1','1'],['1','1'],['1','1'], ['2','2'],['2','2'], ['0','2'],['0','2'], ['3','5'],['3','5'], ['8','9'],['8','9'], ['3','6'],['3','6'], ['9','10'],['9','10'], ['10','10'],['10','10'], ['3','7'], ['6','7'] ] const wrapper = document.querySelector('.wrapper') const frameSize = 15 //star blinking animation const animateStar = (target, start, end, speed) => { let i = start setInterval(function () { target.style.margin = `0px ${-(i * frameSize)}px` if (i >= end) { i = start } else { i++ } }, speed) } //position stars const stars = new Array(70).fill('') stars.forEach(()=>{ const animationPattern = animationPatterns[Math.floor(Math.random() * animationPatterns.length)] const speed = Math.random() < 0.1 ? 140 : 300 const starDiv = document.createElement('div') starDiv.classList.add('star') const starInside = document.createElement('div') starInside.classList.add('star_inner') starInside.innerHTML = starSvg starInside.style.width = `${frameSize * 11}px` starDiv.appendChild(starInside) starDiv.style.top = `${Math.ceil(Math.random() * 100)}%` starDiv.style.left = `${Math.ceil(Math.random() * 100)}%` wrapper.appendChild(starDiv) animateStar(starInside, animationPattern[0], animationPattern[1], speed) }) } window.addEventListener('DOMContentLoaded', init)
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>神秘的表单提交动画效果-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号