Bottom tab bar CSS: fix safe-area-inset-bottom on mobile

PublishedToolMobile Tab Bar Designer

Contents
  1. Common mistakes when building a bottom tab bar yourself
  2. Building a bottom tab bar that handles safe areas
  3. Bottom tab bar CSS properties at a glance
  4. Wrapping up
  5. Frequently asked questions

When you build a bottom tab bar in CSS for mobile web on iPhone (iOS) and Android, you often run into two problems: the bar overlaps the home indicator area, or it stretches to the full width of the screen on desktop. This post covers the CSS rules for pinning a bottom tab bar safely to the screen, how to handle safe areas, and how to adjust the bar's visual design — tab count, layout, active state style, colors — on screen instead of writing it by hand, then export it straight to HTML/CSS.

Summary ① Pin the bottom tab bar with position: fixed, but add env(safe-area-inset-bottom) to padding-bottom so it doesn't overlap the iPhone home indicator area. ② On wide screens such as desktop, limit the tab bar width to the mobile viewport size with max-width, left: 50%, and transform: translateX(-50%) so the layout doesn't break. ③ Each tab item should have a touch target of at least 44px × 44px, per Apple Human Interface Guidelines.

Common mistakes when building a bottom tab bar yourself

In mobile web apps, shopping sites, and social platforms, the bottom tab bar is core navigation placed where the user's thumb reaches most easily. But if you simply pin it with position: fixed; bottom: 0;, two problems appear.

First, iPhone X and later models have a home indicator (home bar) at the bottom of the screen. If tab icons overlap that area, taps misfire or content looks cut off. Second, when you open a mobile-only layout in a desktop browser, the tab bar stretches across the full width of the screen and the balance breaks.

Building a bottom tab bar that handles safe areas

You can fix both problems with a few lines of CSS. Start with these rules for the fixed bottom position.

  • Fixed position (position: fixed): Declare position: fixed; bottom: 0; left: 0; width: 100%; so the tab bar stays pinned to the bottom of the screen regardless of scrolling.
  • Safe-area padding (env(safe-area-inset-bottom)): Add padding-bottom: calc(12px + env(safe-area-inset-bottom)); so icons don't get buried in that area on devices with a home indicator. As a formula: "tab bar height = base height + env(safe-area-inset-bottom)".
  • z-index layering: Set z-index: 1000; or higher so the tab bar always sits above the scrolling page content.

Here's a real HTML/CSS example of a bottom tab bar where the active tab lifts up slightly.

<nav class="mobile-tabbar">
  <a href="#home" class="tab-item active">
    <span class="tab-icon">🏠</span>
    <span class="tab-label">Home</span>
  </a>
  <a href="#search" class="tab-item">
    <span class="tab-icon">🔍</span>
    <span class="tab-label">Search</span>
  </a>
  <a href="#add" class="tab-item center-fab">
    <span class="fab-icon">➕</span>
  </a>
  <a href="#notification" class="tab-item">
    <span class="tab-icon">🔔</span>
    <span class="tab-label">Alerts</span>
  </a>
  <a href="#profile" class="tab-item">
    <span class="tab-icon">👤</span>
    <span class="tab-label">MY</span>
  </a>
</nav>
.mobile-tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px; /* limit width to the mobile viewport */
  height: 64px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(15, 23, 42, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1000;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-item.active {
  color: #38bdf8;
  transform: translateY(-4px);
}

.tab-item.active .tab-icon {
  transform: scale(1.15);
}

/* center floating action button (FAB) */
.center-fab {
  position: relative;
  top: -18px;
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.4);
}

Note Whenever you change the tab count, the layout (standard or floating), the active tab indicator style (pill, dot, top line), or the background and icon colors, editing the code above by hand one change at a time and rechecking on a mobile screen gets tedious. You can adjust these visual combinations on screen without writing code, preview them instantly, and export the HTML/CSS. However, the placement CSS — position: fixed, safe-area handling, z-index, and the desktop width limit — still has to be written by hand. Try it in our tool.

Mobile Tab Bar Designer

Pick 3 to 5 tabs for your mobile bottom tab bar, choose a layout (standard or floating), an active tab style (pill, dot, or top line), plus background and icon colors, then copy the HTML/CSS.

Bottom tab bar CSS properties at a glance

PropertyRecommended valuePurpose
positionfixedPins the bar to the bottom of the screen regardless of scrolling
padding-bottomcalc(12px + env(safe-area-inset-bottom))Prevents overlapping the iPhone home indicator area
z-index1000 or higherKeeps the bar above the page content at all times
max-width / left / transformAround 480px / 50% / translateX(-50%)Limits width on wide screens such as desktop
Touch target44px × 44px or largerPrevents mistaps, per Apple Human Interface Guidelines

Wrapping up

Pin the bottom tab bar with position: fixed, but avoid the home indicator area with env(safe-area-inset-bottom). On wide screens such as desktop, limit the width with max-width and center it, and give each tab item a touch target of at least 44px × 44px. You do have to write this placement CSS into your project code, but for the tab bar's visual design — tab count, layout, active indicator style, colors — you can swap combinations in the tool, see the result right away, and copy the HTML/CSS.

Mobile Tab Bar Designer

Pick 3 to 5 tabs for your mobile bottom tab bar, choose a layout (standard or floating), an active tab style (pill, dot, or top line), plus background and icon colors, then copy the HTML/CSS.

Frequently asked questions

Can I use the generated HTML/CSS in my project as is?

Yes. It's plain HTML and CSS, so you can paste it straight into your project without any extra libraries. If you need it, you just add a small script to switch screens on click.

How many tabs can I create?

Right now you can choose 3, 4, or 5 tabs, and you can set the icon, label, and badge for each tab individually.

Is the design information I enter saved on a server?

No. All previews and code generation happen in your browser only. Nothing is saved or sent anywhere.

This article was adapted from our Korean original. Read the Korean original

Related articles

  1. Multi-Layer Box Shadow: Build a 6-Layer CSS ShadowLearn how stacked CSS box-shadow layers work, with offsets and blur doubling per layer, and copy a 6-layer shadow that looks smooth instead of harsh.
  2. Neumorphism Shadows: Why They Look Flat and How to Fix ThemWhy neumorphism shadows look flat, and how light and dark shadows come from one base color, plus the background color rule that makes them work.
  3. Harmonious 5-Color Palette Formula and 60-30-10 Color GuideHow to calculate complementary, analogous and triadic palettes with HSL hue formulas, apply the 60-30-10 ratio, and get HEX codes for UI and web design.
  4. CSS Stripe Pattern Background: repeating-linear-gradient GuideHow to build a 45-degree diagonal stripe background in CSS with repeating-linear-gradient color stops, plus a tool to dial in angle, width, and colors.
  5. Image Color Extraction: Why the Dominant Color Is WrongAuto-extracted photo colors often don't match what you see. Here's how pixel resizing, color quantization, and frequency sorting decide which colors win.
  6. radial-gradient circle vs ellipse: why it looks stretchedCSS radial-gradient circle vs ellipse: see how each follows the element's aspect ratio, why your gradient looks stretched, and how to check it.

Related tools