'How to move the left div container in a container when moving scroll up and down

#main-container {
    contain: content;
  }
  #left-container-float {
    position: fixed;
    top: 0%;
    right: 0;
    left: 0;
    max-width: 400px;
    width: 100%;
   
  }

enter image description here

here in this pic. I want to move the div container when moving the scroll up to the height of the main container. Please help me with how to solve this.

css


Solution 1:[1]

try:

#left-container-float{
   position:sticky;
   top:0;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 designer132