JavaScript Scrolling only selected content in the body document

I would like to use the page scroll effect so that only the content of the #right element is scrolled in the layout. A similar effect can be seen on Facebook when scrolling posts (posts are scrolled while the left panel and upper bar remain in place). Any of you have an idea how can I get the same effect for my #right container in the code?

#header,#footer{
  width:100%;
  height:80px;
  background:blue;
}

#content{
  width:1000px;
  margin:0 auto;
  overflow:hidden;
}

#left{
  width:200px;
  float:left;
  background:green;
  margin:20px 0;
  height:100vh;
}

#right{
  float:right;
  width:calc(100% - 220px);
}

.item{
  height:80px;
  margin:20px 0;
  background:red;
}
<div id="header">
    header
</div>

<div id="content">
    <div id="left">
        left
    </div>
    <div id="right"> 
    <!-- this content is scrolling-->
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
    </div>
</div>

<div id="footer">
    footer
</div>
Answer:1

Using JQuery you can add a class with style of position:fixed and top:0 and triggered using scroll function for better view/effect of the element on the side.

$(window).scroll(function(){
		var header_height = $('#header').height();
      if ($(this).scrollTop() > header_height) {
          $('#left').addClass('fixed');
      } else {
          $('#left').removeClass('fixed');
      }
});
#header,#footer{
  width:100%;
  height:80px;
  background:blue;
}

#content{
  width:1000px;
  margin:0 auto;
  overflow:hidden;
}

#left{
  width:200px;
  float:left;
  background:green;
  margin:20px 0;
  height:100vh;
}

#right{
  float:right;
  width:calc(100% - 220px);
}

.item{
  height:80px;
  margin:20px 0;
  background:red;
}

.fixed{
  position:fixed;
  top:0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="header">
    header
</div>

<div id="content">
    <div id="left">
        left
    </div>
    <div id="right"> 
    <!-- this content is scrolling-->
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
    </div>
</div>

<div id="footer">
    footer
</div>
Answer:2

Use position: fixed property in CSS

#header,#footer{
  width:100%;
  height:80px;
  background:blue;
}

#content{
  width:1000px;
  margin:0 auto;
  overflow:hidden;
}

#left{
  width:200px;
  float:left;
  background:green;
  /* Enter The Position Fixed Property Here! */
  position:fixed;
  margin:20px 0;
  height:100vh;
}

#right{
  float:right;
  width:calc(100% - 220px);
}

.item{
  height:80px;
  margin:20px 0;
  background:red;
}
<div id="header">
    header
</div>

<div id="content">
    <div id="left">
        left
    </div>
    <div id="right"> 
    <!-- this content is scrolling-->
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
    </div>
</div>

<div id="footer">
    footer
</div>
Answer:3

Alright, so my question is how I can add a prop to a component programmatically, here is my case, I have this in my render() for example: <TextField name="password" ...

Alright, so my question is how I can add a prop to a component programmatically, here is my case, I have this in my render() for example: <TextField name="password" ...

  1. jquery adding property to element

I've got a button, that when I click executes a js code. Like this. jQuery( ".button" ).on('click', function(){ var page = jQuery(this).attr('data-href');//Get data-href with permalink. ...

I've got a button, that when I click executes a js code. Like this. jQuery( ".button" ).on('click', function(){ var page = jQuery(this).attr('data-href');//Get data-href with permalink. ...

  1. before content height
  2. before content height css

I want show the price of the product when the customer select the type and size using the radio buttons and select options. lets say customer select type "single" and size "75X36" price should be ...

I want show the price of the product when the customer select the type and size using the radio buttons and select options. lets say customer select type "single" and size "75X36" price should be ...

  1. jquery show hide

I am new to Angular. How do I start a function from within a *ngIf= directive, when certain criterions are NOT met? Note that in my code, below, the first *ngIf successfully displays a {{...

I am new to Angular. How do I start a function from within a *ngIf= directive, when certain criterions are NOT met? Note that in my code, below, the first *ngIf successfully displays a {{...

  1. start function from another script unity
  2. start function from html
  3. start function in python
  4. start function in r
  5. start function in java
  6. _start function in c
  7. start function in javascript
  8. start function on page load
  9. start function in thread python
  10. start function in unity
  11. start function in new thread c#
  12. start function in new thread python
  13. start function in thread java
  14. start function on page load javascript
  15. start function in php
  16. start function in excel
  17. start function in thread c#
  18. start function in js
  19. start function in new thread java
  20. start function on load