4

I have a header, footer and two body sections. I wanted to do a full page scroll only to my parallax container. I managed to come up with markup and styling to the parallax but didn't have success with the script.


<div class="wrapper">
   <div class="top-content">
      <p>
         Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
      </p>
   </div>
   <div class="parallax">
      <div class="parallax__screen">
         <div class="parallax__image">
            <div class="parallax__illustration" style="background-image: url('https://picsum.photos/id/1/200/300');"></div>
         </div>
         <div class="parallax__copy">
            <p>
               Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
            </p>
         </div>
      </div>
      <div class="parallax__screen">
         <div class="parallax__image">
            <div class="parallax__illustration" style="background-image: url('https://picsum.photos/id/22/200/300');"></div>
         </div>
         <div class="parallax__copy">
            <p>
               Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled
            </p>
         </div>
      </div>
      <div class="parallax__screen">
         <div class="parallax__image">
            <div class="parallax__illustration" style="background-image: url('https://picsum.photos/id/15/200/300');"></div>
         </div>
         <div class="parallax__copy">
            <p>
               it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged
            </p>
         </div>
      </div>
      <div class="parallax__screen">
         <div class="parallax__image">
            <div class="parallax__illustration" style="background-image: url('https://picsum.photos/id/10/200/300');"></div>
         </div>
         <div class="parallax__copy">
            <p>
               It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, 
            </p>
         </div>
      </div>
   </div>
   <div class="bottom-content">
      <p>
         Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
      </p>
   </div>
</div>

Any help would be appreciated. Here is my fiddle

Amrit Subedi
  • 431
  • 3
  • 11
Benjamin
  • 2,612
  • 2
  • 20
  • 32

5 Answers5

0

Are you trying to avoid any library and do it by yourself? Either way I don't think you can do it with CSS only, you'll need some JS.

I recommend fullPage.JS, really easy to use.

iamdlm
  • 1,885
  • 1
  • 11
  • 21
0

Was this what you were aiming for?

* {
  margin: 0;
  padding: 0;
}

body {//you had a typo here
  background-color: #fff;
  font-size: 16px;
  color: #333;
}

.bottom-content {
  position: absolute;
}

.parallax {
  position: sticky;
  top: 96px;
  overflow: hidden;
  @include e(screen) {
    display: flex;
    justify-content: center;
    align-items: center;
    height: calc(100vh - 96px);
    width: 100vw;
  }
  @include e(image) {
    height: calc(100vh - 96px);
    border-radius: 0 rem(5) rem(5) 0;
    width: 100vw;
    z-index: 10;
  }
  @include e(illustration) {
    height: inherit;
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed;
    background-size: cover;
  }
  @include e(copy) {
    width: 100vw;
    z-index: 100;
    position: absolute;
  }
}

with this styling you achieve parallax with text on top

David Machado
  • 430
  • 2
  • 10
0

You can use something like below.

var slide = function() {
        $('.nextsection').show();
            $('mainsection').find('.currentsection').animate({
                marginLeft : '-100%'
            }, 500);
            $('mainsection').find('.nextsection').animate({
                marginLeft : '0%'
            }, 500, function() {
                if (!_.isUndefined(fn)) {
                    fn();
                }
            });
    };

Here 'nextsection' is what you want to slide to and 'currentsection' is what you slide from. 'mainsection' is like where both the 'nextsection' and 'currentsection' contains.

Anjana
  • 903
  • 1
  • 5
  • 13
-1

Are you trying to have the header fixed and the parallex section scroll? If so you can set the position and z-index of the header (top-content).

<style>.top-content {position: fixed; z-index: 100; background-color: white;} . 
</style>

Here is an example: Fiddle Here

Dave
  • 21
  • 2