Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Easy
Normal
Hard
Expert
css
.select-menu { --background: #242836; --text: #fff; --icon: #fff; --icon-active: #3F4656; --list: #1C212E; --list-text: rgba(255, 255, 255, .2); --list-text-hover: rgba(255, 255, 255, .5); position: relative; z-index: 1; font-weight: 500; font-size: 14px; line-height: 25px; } .select-menu select, .select-menu .button { font-family: inherit; margin: 0; border: 0; text-align: left; text-transform: none; -webkit-appearance: none; } .select-menu select { pointer-events: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; opacity: 0; padding: 8px 36px 8px 12px; visibility: hidden; font-weight: 500; font-size: 14px; line-height: 25px; } .select-menu ul { margin: 0; padding: 0; list-style: none; position: absolute; left: 0; top: 0; right: 0; transform: translateY(var(--t)); transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.2, 0.9, 0.4, 1.1); } .select-menu ul li { padding: 8px 36px 8px 12px; cursor: pointer; } .select-menu > ul { background: var(--list); color: var(--list-text); border-radius: 6px; } .select-menu > ul li { transition: color 0.3s ease; } .select-menu > ul li:hover { color: var(--list-text-hover); } .select-menu .button { position: absolute; left: 0; top: 0; right: 0; bottom: 0; padding: 0; z-index: 1; width: 100%; display: block; overflow: hidden; border-radius: 6px; color: var(--text); background: var(--background); } .select-menu .button em { --r: 45deg; display: block; position: absolute; right: 12px; top: 0; width: 7px; height: 7px; margin-top: 13px; -webkit-backface-visibility: hidden; } .select-menu .button em:before, .select-menu .button em:after { --o: .4; content: ""; width: 7px; height: 7px; opacity: var(--o); display: block; position: relative; transition: opacity 0.2s ease; transform: rotate(var(--r)) scale(0.75); } .select-menu .button em:before { border-left: 2px solid var(--icon); border-top: 2px solid var(--icon); top: 1px; } .select-menu .button em:after { border-right: 2px solid var(--icon); border-bottom: 2px solid var(--icon); bottom: 1px; } .select-menu:not(.open) > ul { opacity: 0; pointer-events: none; } .select-menu.open.tilt-up { -webkit-animation: tilt-up 0.4s linear forwards; animation: tilt-up 0.4s linear forwards; } .select-menu.open.tilt-up .button em:before { --o: 1; } .select-menu.open.tilt-down { -webkit-animation: tilt-down 0.4s linear forwards; animation: tilt-down 0.4s linear forwards; } .select-menu.open.tilt-down .button em:after { --o: 1; } @-webkit-keyframes tilt-up { 40%, 60% { transform: perspective(500px) rotateX(8deg); } } @keyframes tilt-up { 40%, 60% { transform: perspective(500px) rotateX(8deg); } } @-webkit-keyframes tilt-down { 40%, 60% { transform: perspective(500px) rotateX(-8deg); } } @keyframes tilt-down { 40%, 60% { transform: perspective(500px) rotateX(-8deg); } } html { box-sizing: border-box; -webkit-font-smoothing: antialiased; } * { box-sizing: inherit; } *:before, *:after { box-sizing: inherit; } body { min-height: 100vh; display: flex; justify-content: center; align-items: center; font-family: "Roboto", Arial; background: #171C28; }
JavaScript
$('select[data-menu]').each(function() { let select = $(this), options = select.find('option'), menu = $('
').addClass('select-menu'), button = $('
').addClass('button'), list = $('
'), arrow = $('
').prependTo(button); options.each(function(i) { let option = $(this); list.append($('
').text(option.text())); }); menu.css('--t', select.find(':selected').index() * -41 + 'px'); select.wrap(menu); button.append(list).insertAfter(select); list.clone().insertAfter(button); }); $(document).on('click', '.select-menu', function(e) { let menu = $(this); if(!menu.hasClass('open')) { menu.addClass('open'); } }); $(document).on('click', '.select-menu > ul > li', function(e) { let li = $(this), menu = li.parent().parent(), select = menu.children('select'), selected = select.find('option:selected'), index = li.index(); menu.css('--t', index * -41 + 'px'); selected.attr('selected', false); select.find('option').eq(index).attr('selected', true); menu.addClass(index > selected.index() ? 'tilt-down' : 'tilt-up'); setTimeout(() => { menu.removeClass('open tilt-up tilt-down'); }, 500); }); $(document).click(e => { e.stopPropagation(); if($('.select-menu').has(e.target).length === 0) { $('.select-menu').removeClass('open'); } })
粒子
时间
文字
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号