liveBook · Manning

Fixed positioning

As explained in Web Design Playground, Second Edition

Fixed positioning is a CSS positioning mode that places an element relative to the browser window and keeps it stationary during scrolling.

Fixed positioning places an element relative to the browser window and keeps it in place while the rest of the page scrolls. Think of a footer that refuses to leave the screen. section 8.10

Use fixed positioning to:

  • Set position: fixed to remove the element from normal page flow and anchor it in the viewport. section 8.7
  • Combine bottom: 0 or top: 0 with a fixed element to place it against a viewport edge. section 8.10 section 15.8
  • Adjust z-index when overlapping elements need a deliberate front-to-back order. section 8.10 section 8.7

A footer that stays put

In a photo gallery, set the footer to position: fixed and bottom: 0. Because the footer can cover the final content, give main padding-bottom equal to the footer height, such as 3.5em. section 15.8

main {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    align-content: flex-start;
    flex-grow: 1;
    max-width: 960px;
    padding-bottom: 3.5em;        #1
}
footer {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;              #2
    bottom: 0;                    #3
    width: 100%;
    text-transform: uppercase;
    background-color: #543437;
}

Browse the complete footer rule, including fixed positioning, bottom anchoring, full width, and the matching main-element clearance. section 15.8

How Web Design Playground, Second Edition covers it

How deep it goes
Explains viewport anchoring and scrolling, then demonstrates offsets, stacking, and content clearance with a fixed footer.
Examples
Uses a photo-gallery footer, a fixed navigation-bar possibility, overlapping elements, and z-index layering.
What you can do after
Apply it via CSS by anchoring an element to the viewport and preserving content visibility beneath it.
How it connects
Connects CSS positioning with absolute positioning, viewport offsets, z-index, fixed footers, and sticky navigation.

Also explained in

Compare how 2 books explain fixed positioning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground, Second Edition. The section links point to the parts of the book it draws on.