JS-152-AdvancedCSS
  • Introduction
  • CSS: OVERVIEW
    • 0.01: Selectors and Combinators
    • 0.02: Measurements
    • 0.03: Design
    • 0.04: User Experience
    • 0.05: User Interface
  • Part 1: Flexbox and Grids
    • 1.0: Intro
    • 1.1: Parents with Many Children
    • 1.2: Grids
    • 1.3: Layouts
    • 1.4: Mastering the Concepts
    • 1.5: Resources
    • 1.6: Glossary
  • Part 2: Borders and Shapes
    • 2.0: Borders
    • 2.1: Borders
    • 2.2: Borders
  • Part 3: Colors
    • 3.0: Colors
    • 3.1: Gradients
  • Part 4: Shadow and Transforms
    • 4.0: Shadows
  • Part 5: Positioning
    • 5.0: Intro
    • 5.1: Static
    • 5.2: Relative
    • 5.3: Fixed
    • 5.4: Sticky
    • 5.5: Absolute
    • 5.6: Z-index
    • 5.7: Glossary
  • Part 6: Media Queries
  • Part 7: Transitions
    • 7.0: Transitions
  • Part 8: Animations
    • 8.0: Animations
  • Part 9: Shadows and Transforms
    • 9.0: Module 9.0
  • Eleven Fifty Style Guide
Powered by GitBook
On this page
  1. Part 5: Positioning

5.4: Sticky

A sticky element combines the values of relative and fixed.

  • starts with a position value of relative

  • position value switches to fixed when it reaches a set scroll location

Make the following changes to the code.

.squareGreen
    position: sticky;
    margin: 100px;
    top: -1;

Change class squareBlue to

.barBlue{
position: relative;
width: 70em;
height: 100px;
margin: 0px;
background: #154360
}

Scroll up. Keep an eye on the squareGreen and barBlue. static

Previous5.3: FixedNext5.5: Absolute

Last updated 7 years ago