What causes the CSS Sticky property to override neighboring elements as it moves?

My Goal: I am attempting to create a scrolling list on the page. Everything works fine until the last element, which seems to erase all the other elements.

* {
  margin: 0;
  padding: 0;
  font-family: 'Ubuntu';
  box-sizing: border-box;
}

body {
  background-color: #15192c;
  color: #fff;
}

.content {
  width: 80%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  text-align: center;
}

.list {
  margin: 10em 5em;
  font-size: 200%;
}

aside {
  flex: 1;
  font-size: 500%;
  position: sticky;
  top: 25%;
  height: 100%;
}

.aside h1 {
  font-weight: bolder;
  font-size: 500%;
}

article {
  flex: 2;
  height: 120%;
}

#developer {
  position: sticky;
  top: 4em;
}

#designer {
  position: sticky;
  top: 6em;
}

#student {
  position: sticky;
  top: 8em;
}

#learner {
  position: sticky;
  top: 10em;
}

#entrepreneur {
  position: sticky;
  top: 12em;
}

#programmer {
  position: sticky;
  top: 14em;
}

#champion {
  position: sticky;
  top: 16em;
}

#risk-taker {
  position: sticky;
  top: 18em;
}

#mistake-maker {
  position: sticky;
  top: 20em;
}
<div class="content">
  <aside>
    <h1>Hello.</h1>
    <p>I'm a</p>
  </aside>
  <article>
    <section class="list" id="developer">
      <h2>Developer</h2>
    </section>
    <section class="list" id="designer">
      <h2>Designer</h2>
    </section>
    <section class="list" id="student">
      <h2>Student</h2>
    </section>
    <section class="list" id="learner">
      <h2>Learner</h2>
    </section>
    <section class="list" id="entrepreneur">
      <h2>Entrepreneur</h2>
    </section>
    <section class="list" id="programmer">
      <h2>Programmer</h2>
    </section>
    <section class="list" id="champion">
      <h2>Champion</h2>
    </section>
    <section class="list" id="risk-taker">
      <h2>Risk-Taker</h2>
    </section>
    <section class="list" id="mistake-maker">
      <h2>Mistake-Maker</h2>
    </section>
  </article>
</div>

View it on CodePen: https://codepen.io/jason43/pen/oNvJWYQ

Answer №1

Adjust the position properties to resolve; like so

position: fixed;
top: 0;

give this a try

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieve the total count of tables within a specific div element

If I have an unspecified amount of tables within a div, how can I determine the total number of tables using either plain JavaScript or jQuery? ...

The height of the div unexpectedly adjusts after content is displayed on hover

Within my anchor tag, there are two elements: a fontawesome Icon and a hidden span that only appears when the anchor is hovered over. The problem arises on my website when the hidden span is displayed inline causing the parent anchor to increase in height. ...

Display the form-control field only when a selection has been made in the previous form-control using HTML and PHP

I'm in the process of developing a webpage with form controls (2 in this example). Here's my code: <body> <div class="option_choice_global"> Select your options <div class="col-xs-2"> <lab ...

Tips for preventing CORS errors while rendering an image on a canvas

Working on a project for my coding bootcamp where I need to overlay bandaids on an image of a bear using canvas. The main challenge is to check the color of the area that users click to ensure they don't put bandaids on the white space around the actu ...

Using Google Maps within a Bootstrap modal window that is only partially loaded

The maps display perfectly fine in a regular div, but when placed inside a Bootstrap modal, only half or part of the map is visible. However, when I open the console, the issue resolves itself and the entire map is shown. Photo without console opened Pho ...

Align pictures in the middle of two divisions within a segment

This is the current code: HTML: <section class="sponsorSection"> <div class="sponsorImageRow"> <div class="sponsorImageColumn"> <img src="img/kvadrat_logo.png" class="sponsorpicture1"/> </div& ...

What do you think about removing the Bootstrap styling from the design?

As a newcomer to Bootstrap and currently working on my second project using this framework, I find myself struggling with overriding CSS styles. It can be time-consuming to locate the specific style that needs to be changed rather than starting from scratc ...

jQuery neglecting events of child elements

I am facing an issue with the following list structure: <ul id="menu"> <li style="background-image:url('Images/X-AFH-Company-Office-Background.png')" id="office"> <div >Company / Office</div> ...

Execute various settimeout or display functions on various elements of a webpage

Just a heads up, I'm not really experienced in development. More on the newbie side of things, but eager to learn. I've been looking for an answer to my question, but so far haven't come across anything that fits my specific situation. It m ...

Webpack version 4.6.0 is currently loading a CSS file and it's suggesting the need for a suitable loader to manage this specific file

I have been encountering an issue with webpack 4.6.0 during compilation: Uncaught Error: Module parse failed: Unexpected token (1:4) You may need an appropriate loader to handle this file type. | div { | background-color: yellow; | color: red; He ...

Tips for displaying a refresh indicator while making an ajax call for refreshing data:

I have successfully implemented jQuery code that refreshes a specific div every 10 seconds without reloading the entire page. However, during this refresh process, the user does not visually perceive any changes happening in the browser. While there are n ...

What is the best way to synchronize loading dynamic data with static content while loading an HTML document?

When I visit a web page that contains both static and dynamic text (using AngularJS), I notice that the static data loads first, followed by the dynamic data after a few seconds. This causes a noticeable change in the alignment of the text. Code Sample: ...

``To ensure Google Maps fills the entire height of its parent div, set the

Is there a way to display a Google Map at 100% of the parent div's height? I've noticed that setting the height to 100% makes the map not visible, but if I use a pixel value for the height, the map displays correctly. Are there any tricks or solu ...

The removal of the div element doesn't seem to be functioning properly

I am struggling with adding and removing div elements using jQuery. While adding a div element is working fine, I am facing issues with removing a div element. Here is the implementation: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...

Guide to adding text descriptions for synchronized media as outlined in WCAG 2.0 Success Criterion 1.2.2

Based on the guidelines of WCAG 2.0 success criterion 1.2.2: 1.2.2 Captions (Prerecorded) Level A Captions are provided for all prerecorded audio content in synchronized media, except when the media is a media alternative for text and is clearly labeled ...

``Is there a way to position an image at the center in Python dash?

Can someone help me with centering an image in my Flask dash app? Here is the code I have: import dash from dash import html, dcc import dash_bootstrap_components as dbc app = dash.Dash(__name__) app.layout = html.Div([ dbc.CardImg(src=r'assets/ ...

Adding an image in HTML from a different drive - step-by-step guide!

Currently, I am immersing myself in HTML, CSS, and JavaScript as I gear up for my upcoming school project centered around frontend development. Here's the issue I encountered. While attempting to insert an image into one of my HTML files, I ran into ...

What is the best way to design a page with a fixed dimension element and a flexible liquid element?

Is there a way to achieve the layout described below without relying on tables? Left element (100px) | Right element (occupies remaining space, even with no content) Thank you! Edit: Here's the link to the code: http://pastebin.com/vU33jNxD ...

Applying CSS to both pop-up and desktop interfaces can be achieved through the use of media queries or alternative solutions

I am facing a dilemma where I need to display the same content on both a pop-up and desktop view. While I have already implemented media queries to adjust the content for desktop and mobile views, I am struggling with displaying the same content on a pop ...

The error message "ERR_CONNECTION_TIMED_OUT when trying to access Google APIs fonts

Upon deploying my web project on the client server, I encountered an error and noticed slow page loading. GET https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic net::ERR_CONNECTION_TIMED_OUT The browser ...