下面给你一个炫酷的 Material Design 风格「打开菜单」效果,适合网页使用(HTML + CSS + JS),包含:
- 悬浮圆形 FAB 按钮
- 点击后 波纹(Ripple)+ 菜单滑出
- 阴影、动效、Material 风格配色
- 可直接嵌入到你的网站或博客里使用
✨ 效果说明
- 右下角一个 Material Floating Action Button
- 点击后菜单从下向上弹出
- 带阴影、缩放、透明度过渡
- 风格类似 Android / Material You
✅ 完整示例代码(可直接用)
1️⃣ HTML
<div class="fab-container">
<button class="fab" id="fab">☰</button>
<div class="fab-menu" id="fabMenu">
<a href="#">🌌 宇宙文明</a>
<a href="#">🛰 深空探索</a>
<a href="#">📡 外星信號</a>
<a href="#">🔭 天文觀測</a>
</div>
</div>
2️⃣ CSS(Material Design 核心)
body {
font-family: Roboto, system-ui;
background: #0d1117;
}
.fab-container {
position: fixed;
bottom: 32px;
right: 32px;
z-index: 999;
}
/* FAB 主按钮 */
.fab {
width: 64px;
height: 64px;
border-radius: 50%;
background: linear-gradient(135deg, #3f51b5, #2196f3);
color: #fff;
font-size: 28px;
border: none;
cursor: pointer;
box-shadow: 0 12px 24px rgba(0,0,0,.4);
transition: transform .3s ease;
}
.fab:hover {
transform: scale(1.1);
}
/* 菜单 */
.fab-menu {
position: absolute;
bottom: 80px;
right: 0;
background: #ffffff;
border-radius: 16px;
overflow: hidden;
box-shadow: 0 16px 32px rgba(0,0,0,.3);
opacity: 0;
transform: translateY(20px) scale(0.9);
pointer-events: none;
transition: all .3s cubic-bezier(.4,0,.2,1);
}
/* 菜单展开 */
.fab-menu.active {
opacity: 1;
transform: translateY(0) scale(1);
pointer-events: auto;
}
/* 菜单项 */
.fab-menu a {
display: block;
padding: 14px 22px;
color: #333;
text-decoration: none;
font-weight: 500;
transition: background .2s;
}
.fab-menu a:hover {
background: #f0f2f5;
}
3️⃣ JavaScript(菜单开关)
<script>
const fab = document.getElementById('fab');
const menu = document.getElementById('fabMenu');
fab.addEventListener('click', () => {
menu.classList.toggle('active');
});
</script>
发表回复