Why Is My Logo Not Centered in the Header?

Logo not centered in header problems usually happen when the logo is centered inside the remaining space, not the real header width. Unequal nav items, CTA buttons, flex spacing, absolute positioning, or mobile menu icons can make the logo look pushed to one side.

Header Alignment Fix

Why is my logo not centered in the header?

A logo can look mathematically centered in your CSS and still look visually off in the header. The most common reason is that the left and right sides of the header do not have equal width. A menu on one side, a CTA button on the other, mobile icons, or a wrong transform can shift the visual center.

  • Header layout
  • Logo alignment
  • Flexbox header
  • Mobile navbar

What the bug looks like

The logo looks slightly left or right of the true page center, especially when the header has nav links, a CTA, or a hamburger icon.

Why it happens

The header uses uneven columns, flex spacing, manual margins, or absolute positioning that centers the logo relative to the wrong thing.

What usually fixes it

Use balanced grid columns, true absolute centering, or a mobile header pattern with equal left and right control areas.

Error 1

The logo is centered between uneven header sides

This happens when the left side and right side of the header have different widths. The logo may be centered in the grid cell, but the whole header still feels visually unbalanced.

Broken code

Uneven columns
.header {
  display: grid;
  grid-template-columns: 1fr auto 1.65fr;
  align-items: center;
}

Broken visual result

Looks off-center
visual offset
HomeWork
LOGO
SearchContact
The right side is wider, so the logo is not aligned with the true header center.

Correct code

Balanced columns
.header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.logo {
  justify-self: center;
}

Fixed visual result

Centered in header
HomeWork
LOGO
Contact
Equal side columns let the center column sit on the real visual center.
Error 2

The logo uses left:50% with the wrong transform

Absolute centering is useful for logos, but only when the transform matches the element itself. A guessed transform value may look okay at one width and break at another.

Broken code

Bad transform
.logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-35%, -50%);
}

Broken visual result

Transform guess
wrong center
LOGO
The logo starts at 50%, but it is not pulled back by half of its own width.

Correct code

True absolute center
.logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

Fixed visual result

Centered by itself
LOGO
translate(-50%, -50%) centers the logo based on its own size.
Error 3

The mobile menu icon changes the visual center

On mobile, a hamburger icon appears on one side and the logo suddenly looks off. That usually means the opposite side has no matching space, so the center column is not truly centered.

Broken code

Unbalanced mobile header
.mobile-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
}

.logo {
  justify-self: start;
  margin-left: 18px;
}

Broken visual result

Mobile offset
hamburger shift
LOGO
The left control affects the logo because the columns are not balanced.

Correct code

Equal mobile controls
.mobile-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
}

.logo {
  justify-self: center;
}

Fixed visual result

Balanced mobile header
LOGO
The empty right column balances the hamburger icon so the logo can sit on the true center.
Premium pattern

A production-minded centered header logo pattern

A stronger header pattern uses a three-column grid. The left and right columns are equal, the logo lives in the center, and mobile controls keep the same balance instead of relying on magic margins.

Premium code

Balanced header system
.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding-inline: clamp(16px, 4vw, 32px);
}

.site-logo {
  justify-self: center;
}

.header-left {
  justify-self: start;
}

.header-right {
  justify-self: end;
}

@media (max-width: 768px) {
  .site-header {
    grid-template-columns: 44px 1fr 44px;
  }

  .site-logo {
    justify-self: center;
  }
}

Premium visual result

Centered without guessing
Home
LOGO
Contact
The logo is centered because the layout system is balanced, not because a pixel value was guessed.

Fast practical rule

If your logo is not centered in the header, measure the left side and right side first. If they are not balanced, the logo will look off even if the CSS says it is centered.

Debug checklist

  • Check whether the logo is centered inside the header or only inside one grid/flex area.
  • Compare the width of the left navigation area with the right action area.
  • Look for manual margin-left, margin-right, or transform values applied to the logo.
  • If using absolute positioning, pair left:50% with transform:translateX(-50%).
  • Use grid-template-columns:1fr auto 1fr when the logo must sit in the true center.
  • On mobile, balance the hamburger icon with an equal placeholder or right-side control area.
  • Check if a breakpoint hides menu items but leaves old spacing behind.
  • Inspect the header wrapper padding and max-width if the logo is centered inside a shifted container.
Best first move Draw a center line through the viewport and compare it with the logo center.
Most common cause Unequal left and right header content makes the logo appear pushed to one side.
Most sneaky cause A mobile hamburger icon appears, but the opposite side has no matching space.
Better mindset Do not center the logo with a guessed margin. Center it with a balanced layout system.

Final takeaway

A logo not centered in the header is usually not a logo problem. It is usually a header layout problem. The logo is being centered inside a space that is not actually the visual center of the full header.

Start by checking the left and right sides of the header. If they are uneven, use balanced grid columns, correct absolute centering, or equal mobile control areas. Once the header is balanced, the logo stops drifting.

Want more fixes like this?

Browse more CSS, header, and responsive layout debugging guides in the FrontFixer library.

Why Is My Mobile Menu Not Opening?

Mobile menu not opening problems usually happen when the button and menu are not connected correctly, the wrong class is being toggled, the menu is still hidden in CSS, or another element is sitting on top of it.

Mobile Navigation Fix

Why is my mobile menu not opening?

A mobile menu can look like it should work but still stay closed when you tap the hamburger button. The cause is usually not random. The button may be toggling the wrong class, the checkbox label may not match the input ID, the menu may still be hidden by a stronger CSS rule, or an overlay may be blocking the menu completely.

  • Hamburger menu
  • HTML structure
  • CSS classes
  • Mobile navigation

What the bug looks like

You tap the hamburger icon, but the navigation stays closed, appears behind the page, flashes for a second, or opens but cannot be clicked.

Why it happens

The menu’s open state is not connected to the CSS rule that actually reveals the navigation.

What usually fixes it

Make the trigger, menu, open class, selector, z-index, and breakpoint rules all point to the same state.

Error 1

The button toggles one class, but the CSS expects another

This is one of the most common reasons a mobile menu is not opening. The HTML or JavaScript adds one class, but the CSS selector is written for a different class name.

Broken code

Class mismatch
/* The button adds .active */
.menu-button.active {
  color: orange;
}

/* But the CSS opens only .is-open */
.mobile-menu.is-open {
  display: block;
}

Broken visual result

Button changed, menu closed
menu still closed
Page content

The icon changed state, but the navigation never received the class that reveals it.

The CSS and the menu state are speaking different languages.

Correct code

Same state name
.mobile-menu {
  display: none;
}

.mobile-menu.is-open {
  display: block;
}

Fixed visual result

Menu state matches CSS
menu open
Page content

The menu opens because the class used by the state matches the class used by the CSS.

Use one clear open state and reuse that exact name everywhere.
Error 2

The checkbox and label are not connected

CSS-only hamburger menus often use a hidden checkbox. If the label’s for value does not match the checkbox id, tapping the hamburger does nothing.

Broken code

Wrong ID
<input id="mobile-toggle" type="checkbox">
<label for="menu-toggle">Menu</label>

<nav class="mobile-menu">...</nav>

Broken visual result

Tap does not toggle
wrong target
No checkbox state

The hamburger label points to an ID that does not exist, so the menu never receives an open state.

The trigger exists, but it is connected to the wrong element.

Correct code

Matching ID
<input id="menu-toggle" type="checkbox">
<label for="menu-toggle">Menu</label>

<nav class="mobile-menu">...</nav>

Fixed visual result

Trigger connected
checkbox toggled
Connected menu

The label toggles the right checkbox, and the CSS can reveal the navigation.

For CSS-only menus, the label and checkbox must be wired perfectly.
Error 3

The menu opens behind an overlay or another layer

Sometimes the mobile menu is technically open, but you cannot see or click it because an overlay, header, section, or transformed parent creates a stronger stacking layer above it.

Broken code

Layer problem
.overlay {
  position: fixed;
  z-index: 1000;
}

.mobile-menu {
  position: absolute;
  z-index: 10;
}

Broken visual result

Menu hidden behind layer
Overlay is above the menu
The menu exists, but another layer wins the stacking order.

Correct code

Menu above overlay
.site-header {
  position: relative;
  z-index: 1001;
}

.mobile-menu {
  position: absolute;
  z-index: 1002;
}

Fixed visual result

Menu visible and clickable
Overlay behind menu
The header and menu need a deliberate stacking plan.
Error 4

A media query keeps the menu hidden

A mobile menu can fail because the open selector is correct, but a later mobile rule still says display:none. In CSS, the rule that wins is the one with the right specificity and order.

Broken code

Later rule wins
.mobile-menu.is-open {
  display: block;
}

@media (max-width: 768px) {
  .mobile-menu {
    display: none;
  }
}

Broken visual result

Open rule overridden
hidden by CSS
Rule conflict

The menu has an open class, but the breakpoint still hides it.

The open state loses because a later CSS rule keeps the menu hidden.

Correct code

Open state inside breakpoint
@media (max-width: 768px) {
  .mobile-menu {
    display: none;
  }

  .mobile-menu.is-open {
    display: block;
  }
}

Fixed visual result

Open rule wins
visible
Rule order fixed

The hidden state and open state live in the same breakpoint, so the open state can win.

Put the mobile open selector where it can actually override the mobile hidden selector.
Premium pattern

A production-minded mobile menu pattern

A stronger mobile menu pattern uses clear HTML, a single open state, an accessible button, and CSS that reveals the navigation only when the parent state says the menu is open.

Premium code

State on the parent
<header class="site-header" data-menu="closed">
  <a class="logo" href="/">Site</a>

  <button class="menu-button"
    aria-controls="mobile-menu"
    aria-expanded="false">
    Menu
  </button>

  <nav id="mobile-menu" class="mobile-menu">
    <a href="/">Home</a>
    <a href="/services/">Services</a>
    <a href="/contact/">Contact</a>
  </nav>
</header>

.mobile-menu {
  display: none;
}

.site-header[data-menu="open"] .mobile-menu {
  display: grid;
}

.site-header {
  position: relative;
  z-index: 1000;
}

Premium visual result

Clear state, clear menu
Stable navigation

The menu opens from one parent state, sits above content, and stays easy to debug.

Premium mobile menus avoid scattered states. One parent state controls the whole navigation.

Fast practical rule

If your mobile menu is not opening, do not start by changing random z-index values. First check whether the trigger changes the exact state that the CSS uses to reveal the menu. Then check rule order, structure, and layers.

Debug checklist

  • Check whether the hamburger button is actually being clicked or tapped.
  • Confirm the open class name in HTML, CSS, and any menu script is exactly the same.
  • For CSS-only menus, make sure the label for value matches the checkbox id.
  • Inspect the menu in DevTools and see whether it is hidden by display:none, opacity:0, visibility:hidden, or transform.
  • Check whether a media query overrides the open state after it is declared.
  • Check whether an overlay, header, or parent stacking context is covering the menu.
  • Confirm the menu is inside the parent expected by the selector.
  • Use aria-expanded and aria-controls so the menu state is easier to maintain.
Best first move Inspect the menu element and see whether the open class appears after tapping the button.
Most common cause The button toggles one class while the CSS is written for another class.
Most sneaky cause The menu opens, but it is behind an overlay or hidden by a later mobile rule.
Better mindset A mobile menu should have one obvious state that controls visibility, position, and layering.

Final takeaway

A mobile menu not opening is usually a connection problem, not a mystery. The button, menu, class name, selector, breakpoint, and layer order all need to agree on what “open” means.

Start by checking whether the open state appears in DevTools. If it does not, the trigger is not connected correctly. If it does appear but the menu is still hidden, inspect CSS order, display rules, z-index, overlays, and parent structure.

Want more fixes like this?

Browse more HTML, CSS, and responsive debugging guides in the FrontFixer library.