Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!doctype html>
<html>
    <head>
        <title>
            Sticky Sidebar
        </title>
    <link href="https://www.acropolisinfotech.com/assets/css/web-development.css" rel="stylesheet" />


    </head>
    <body>
        <div class="container-fluid">
            <div class="row normal-section bg-gray">

            </div>
            <div class="row sidebar-container normal-section flex">
                <div class="col-md-6 col-sm-6 col-xs-6 text-container bg-white pd-0-0" >
                    <div class="text-box bg-green flex all-center pd-0-0">
                        <h3>One</h3>

                    </div>
                    <div class="text-box bg-gray flex all-center pd-0-0">
                        <h3>Two</h3>
                        
                    </div>
                    <div class="text-box bg-green flex all-center pd-0-0">
                        <h3>Three</h3>
                        
                    </div>
                    <div class="text-box bg-gray flex all-center pd-0-0">
                        <h3>Four</h3>
                        
                    </div>
                    <div class="text-box bg-green flex all-center pd-0-0">
                        <h3>Five</h3>
                        
                    </div>
                    <div class="text-box bg-gray flex all-center pd-0-0">
                        <h3>Six</h3>
                        
                    </div>


                </div>
                <div class="col-md-6 col-sm-6 col-xs-6 image-container bg-gradient pd-0-0 flex">
                    <div class="image-box-container pd-0-0 flex">
                    <div class="image-box pd-0-0">
                      <img src="https://homepages.cae.wisc.edu/~ece533/images/airplane.png" alt="One" />
                    </div>
                    <div class="image-box pd-0-0">
                      <img src="https://homepages.cae.wisc.edu/~ece533/images/arctichare.png" alt="One" />
                    </div>
                    <div class="image-box pd-0-0">
                      <img src="https://homepages.cae.wisc.edu/~ece533/images/baboon.png" alt="One" />
                    </div>
                    <div class="image-box pd-0-0">
                      <img src="https://homepages.cae.wisc.edu/~ece533/images/boat.png" alt="One" />
                    </div>
                    <div class="image-box pd-0-0 ">
                      <img src="https://homepages.cae.wisc.edu/~ece533/images/monarch.png" alt="One" />
                    </div>
                    <div class="image-box pd-0-0 ">
                      <img src="https://homepages.cae.wisc.edu/~ece533/images/pool.png" alt="One" />
                    </div>
                    </div>
                    

                </div>
            </div>
            <div class="row normal-section next-section bg-green" id="next-section">

            </div>
            <div class="row normal-section bg-white">

            </div>
            <div class="row normal-section footer-section bg-gray">

            </div>
        </div>
    </body>
</html>

              
            
!

CSS

              
                .container-fluid>div,
.sidebar-container>div,
.text-box,
.image-box {
  min-height: 100vh;
}

.image-container {
  overflow: hidden;
}

.container-fluid>.footer-section {
  position: relative;
  z-index: 10;
}

.fixed-section {
  position: fixed;
  top: 0;
  width: 50%;
  height: 100vh;
  right: 0;
  z-index: 5;
  overflow: hidden;
}

.mgt-100 {
  margin-top: 100vh;
}

#next-section {
  position: relative;
  z-index: 10;
}

.image-box {
  height: 100vh;
  overflow: hidden;
}

.image-box img {
  width: 50vw;
  height: 100vh;
  -o-object-fit: cover;
  object-fit: cover;
}

.image-box-container {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 300vw;
  height: 100vh;
  z-index: 3;
  white-space: nowrap;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-flex-wrap: nowrap;
  -ms-flex-wrap: nowrap;
  flex-wrap: nowrap;
}
              
            
!

JS

              
                $(document).ready(function() {
          var sidebar = $(".image-container");
          var sectionPosition = sidebar.offset().top;
          var next = $(".next-section");
          var nextTop = $(next).offset().top;
          var targetElement = document.querySelectorAll(".normal-section");
          var classOf = false;
          var sectionHeight = parseFloat(sidebar.css("height"));
          var translatingValue = 0;
          var imageBoxWidth = $(".image-box:first-child").css("width");
          var textBoxHeight = $(".text-box:first-child").css("height");
          $(".image-container").css("width", textBoxHeight * 6 + "px");
      
          function setFixedPosition(position, elementPosition, element, next) {
              if (position >= elementPosition && position < nextTop) {
                  $(element).addClass("fixed-section");
                  //$(next).addClass("mgt-100");
              } else {
                  $(element).removeClass("fixed-section");
                  //$(next).removeClass("mgt-100");
              }
          }
          $(window).on("scroll", function() {
              let top = $(this).scrollTop();
              
              // Update calculation position of translatingValue 
              let textBoxHeightInNumber = parseInt(textBoxHeight.replace('px', ''));
              let scrollOffset = top - sectionPosition;
              let slideNumber = 0;
              if (scrollOffset >= 0) {
                slideNumber = Math.ceil(scrollOffset / textBoxHeightInNumber);
                slideWidth = $(".image-box-container .image-box:nth-child("+slideNumber+")").width()
                translatingValue = scrollOffset * slideWidth / textBoxHeightInNumber;
              }

              setFixedPosition(top, sectionPosition, sidebar, next);
              let fixedStatus = $(".image-container").hasClass("fixed-section");
              if (fixedStatus) {
                moveImageSlider(-(translatingValue));
              } else {}
      
          })
      
          function moveImageSlider(val) {
              $(".image-box-container").css("transform", "translateX(" + val + "px" + ")");
          }
      
      })
              
            
!
999px

Console