Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Default option
Option 1
Option 2
Option 3
Option 4
Option 5
css
html { box-sizing: border-box; font-size: 62.5%; } html *, html *:before, html *:after { box-sizing: inherit; } body { display: flex; justify-content: center; align-items: center; width: 100vw; height: 100vh; background-color: #98DFFD; } .dropdown { width: 100%; margin: 0 20px; padding: 20px; background-color: white; box-shadow: 0 8px 10px 0 rgba(0, 0, 0, 0.3); font-family: 'Lato', sans-serif; } @media (min-width: 768px) { .dropdown { width: 600px; } } .dropdown__switch:checked + .dropdown__options-filter .dropdown__select { transform: scaleY(1); } .dropdown__switch:checked + .dropdown__options-filter .dropdown__filter:after { transform: rotate(-135deg); } .dropdown__options-filter { width: 100%; cursor: pointer; } .dropdown__filter { position: relative; display: flex; padding: 20px; color: #595959; background-color: #fff; border: 1px solid #d6d6d6; border-radius: 30px; font-size: 14px; text-transform: uppercase; transition: .3s; } .dropdown__filter:focus { border: 1px solid #918FF4; outline: none; box-shadow: 0 0 5px 3px #918FF4; } .dropdown__filter::after { position: absolute; top: 45%; right: 20px; content: ''; width: 10px; height: 10px; border-right: 2px solid #595959; border-bottom: 2px solid #595959; transform: rotate(45deg) translateX(-45%); transition: .2s ease-in-out; } .dropdown__select { position: absolute; top: 100%; left: 0; width: 100%; margin-top: 5px; overflow: hidden; box-shadow: 0 5px 10px 0 rgba(152, 152, 152, 0.6); transform: scaleY(0); transform-origin: top; font-weight: 300; transition: .2s ease-in-out; } .dropdown__select-option { padding: 20px; background-color: #fff; border-bottom: 1px solid #d6d6d6; transition: .3s; } .dropdown__select-option:last-of-type { border-bottom: 0; } .dropdown__select-option:hover { background-color: #f9f9f9; }
JavaScript
// Change option selected const label = document.querySelector('.dropdown__filter-selected') const options = Array.from(document.querySelectorAll('.dropdown__select-option')) options.forEach((option) => { option.addEventListener('click', () => { label.textContent = option.textContent }) }) // Close dropdown onclick outside document.addEventListener('click', (e) => { const toggle = document.querySelector('.dropdown__switch') const element = e.target if (element == toggle) return; const isDropdownChild = element.closest('.dropdown__filter') if (!isDropdownChild) { toggle.checked = false } })
粒子
时间
文字
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号