Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Upload
css
.button { --background: #275EFE; --background-hover: #2456E8; --text: #fff; --icon: #fff; display: -webkit-box; display: flex; outline: none; cursor: pointer; border: 0; min-width: 113px; padding: 8px 20px 8px 12px; border-radius: 9px; line-height: 24px; font-family: inherit; font-weight: 600; font-size: 14px; color: var(--text); background: var(--b, var(--background)); -webkit-transition: background .4s, -webkit-transform .3s; transition: background .4s, -webkit-transform .3s; transition: transform .3s, background .4s; transition: transform .3s, background .4s, -webkit-transform .3s; -webkit-transform: scale(var(--scale, 1)) translateZ(0); transform: scale(var(--scale, 1)) translateZ(0); } .button:active { --scale: .95; } .button:hover { --b: var(--background-hover); } .button .icon { --arrow-y: 0; --arrow-rotate: 45; width: 24px; height: 24px; position: relative; display: inline-block; vertical-align: top; margin-right: 8px; pointer-events: none; } .button .icon .arrow, .button .icon .line { position: absolute; } .button .icon .arrow { left: 11px; top: 4px; width: 2px; height: 12px; border-radius: 1px; background: var(--icon); -webkit-transform: translateY(calc(var(--arrow-y) * 1px)) translateZ(0); transform: translateY(calc(var(--arrow-y) * 1px)) translateZ(0); } .button .icon .arrow:before, .button .icon .arrow:after { content: ''; width: 2px; height: 7px; position: absolute; left: 0; top: 0; border-radius: 1px; background: inherit; -webkit-transform-origin: 1px 1px; transform-origin: 1px 1px; -webkit-transform: rotate(var(--r, calc(var(--arrow-rotate) * -1deg))); transform: rotate(var(--r, calc(var(--arrow-rotate) * -1deg))); } .button .icon .arrow:after { --r: calc(var(--arrow-rotate) * 1deg); } .button .icon .line { width: 24px; height: 24px; display: block; left: 0; top: 7px; fill: none; stroke: var(--icon); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; } html { box-sizing: border-box; -webkit-font-smoothing: antialiased; } * { box-sizing: inherit; } *:before, *:after { box-sizing: inherit; } body { min-height: 100vh; display: -webkit-box; display: flex; font-family: 'Inter', Arial; -webkit-box-pack: center; justify-content: center; -webkit-box-align: center; align-items: center; background: #ECEFFC; }
JavaScript
const $ = (s, o = document) => o.querySelector(s); const $$ = (s, o = document) => o.querySelectorAll(s); $$('.button').forEach(button => { let icon = $('.icon', button), line = $('.line', icon), svgPath = new Proxy({ y: null }, { set(target, key, value) { target[key] = value; if(target.y !== null) { line.innerHTML = getPath(target.y, .25, null); } return true; }, get(target, key) { return target[key]; } }), timeline = gsap.timeline({ paused: true }), interval; svgPath.y = 12; timeline.to(icon, { '--arrow-y': 6, '--arrow-rotate': 70, ease: "elastic.in(1.1, .8)", duration: .7 }).to(icon, { '--arrow-y': 0, '--arrow-rotate': 45, ease: "elastic.out(1.1, .8)", duration: .7 }); timeline.to(svgPath, { y: 15, duration: .15 }, .65).to(svgPath, { y: 12, ease: "elastic.out(1.2, .7)", duration: .6 }, .8); button.addEventListener('mouseover', e => { timeline.restart(); interval = setInterval(() => timeline.restart(), 1500); }); button.addEventListener('mouseout', e => clearInterval(interval)); }); function getPoint(point, i, a, smoothing) { let cp = (current, previous, next, reverse) => { let p = previous || current, n = next || current, o = { length: Math.sqrt(Math.pow(n[0] - p[0], 2) + Math.pow(n[1] - p[1], 2)), angle: Math.atan2(n[1] - p[1], n[0] - p[0]) }, angle = o.angle + (reverse ? Math.PI : 0), length = o.length * smoothing; return [current[0] + Math.cos(angle) * length, current[1] + Math.sin(angle) * length]; }, cps = cp(a[i - 1], a[i - 2], point, false), cpe = cp(point, a[i - 1], a[i + 1], true); return `C ${cps[0]},${cps[1]} ${cpe[0]},${cpe[1]} ${point[0]},${point[1]}`; } function getPath(update, smoothing, pointsNew) { let points = pointsNew ? pointsNew : [ [5, 12], [12, update], [19, 12] ], d = points.reduce((acc, point, i, a) => i === 0 ? `M ${point[0]},${point[1]}` : `${acc} ${getPoint(point, i, a, smoothing)}`, ''); return `
`; }
粒子
时间
文字
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号