About this snippet

Enhance mobile navigation with a Floating Action Button (FAB). The main button expands into a menu when hovered over or clicked, which provides quick access to essential actions without cluttering the interface.

Size
1.7 KB
Uses
HTML, CSS
Loads
Nothing external
Views
536
<div class="fab-container">
  <div class="fab-menu">
    <button class="fab-action" aria-label="Edit">&#9998;</button>
    <button class="fab-action" aria-label="Like">&#9829;</button>
    <button class="fab-action" aria-label="Share">&#10148;</button>
  </div>
  <button class="fab-main" aria-label="Open Menu">&#43;</button>
</div>
.fab-container {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 999;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 15px;
}
.fab-main {
  width: 60px;
  height: 60px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 2rem;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab-menu {
  display: flex;
  flex-direction: column-reverse;
  gap: 15px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
}
.fab-action {
  width: 45px;
  height: 45px;
  background: #fff;
  color: #4b5563;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.fab-action:hover {
  background: #f3f4f6;
}
.fab-container:hover .fab-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.fab-container:hover .fab-main {
  transform: rotate(45deg);
  background: #1d4ed8;
}
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save