Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                <main class='main'>
  
  <section class='section section--one' id='section1'>
    <div class='section__bg'></div>
    <button class='button--close'>x</button>
    <div class='section__content'>
      <div class='section__bg image'></div>
      <h2 class="section__title">Cras ornare tristique elit</h2>
      <div class="section__content__body">
      <p>Curabitur quis odio neque. Nulla ac ipsum felis. Suspendisse arcu libero, consequat id varius sed, suscipit non ipsum. Vivamus nec feugiat turpis, sed luctus metus. Vivamus vel libero id augue tempus aliquet. Vestibulum facilisis ante quis consectetur commodo. Praesent molestie odio vel varius rutrum. Proin eget magna a sapien accumsan bibendum et ac augue. Vivamus sed justo a nulla posuere eleifend. Duis ut vulputate risus. Proin mauris arcu, malesuada at dictum ut, pharetra sit amet orci. Donec rutrum porta libero nec aliquet. Vivamus dignissim tortor ut ipsum tempor, in fermentum ipsum rhoncus.</p>
       </div> 
    </div>
  </section>
  <section class='section section--two is-active' id='section2'>
    <div class='section__bg'></div>
    <button class='button--close'>x</button>
    <div class='section__content'>
      <div class='section__bg image'></div>
      <h2 class="section__title">Ut aliquam sollicitudin leo</h2>
      <div class="section__content__body">
     <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed fermentum molestie nisl. Aliquam suscipit sed ante a egestas. Suspendisse mi elit, porttitor id suscipit id, convallis ac massa. Nulla tincidunt, felis in tincidunt fermentum, ligula risus aliquet dolor, id vestibulum augue augue eu lacus. Mauris ornare ante erat, id pretium nisl faucibus vel. Praesent pellentesque dolor at porta consectetur. Pellentesque eget lacus scelerisque mauris volutpat maximus vel auctor nibh. Suspendisse quis lacus at orci ornare varius. Pellentesque tincidunt id ex sed fermentum. Cras eget urna ac arcu auctor tempor. Cras malesuada convallis faucibus.</p>
       </div> 
    </div>
  </section>
  <section class='section section--three' id='section3'>
    <div class='section__bg'></div>
    <button class='button--close'>x</button>
    <div class='section__content'>
      <div class='section__bg image'></div>
      <h2 class="section__title">Cras iaculis ultricies nulla</h2>
      <div class="section__content__body">
      <p>Cras nec ante in augue bibendum bibendum. Praesent pellentesque leo porttitor elementum gravida. Phasellus felis sem, interdum eu metus tempus, lacinia venenatis ligula. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus facilisis, ante sed efficitur porta, leo odio tempor erat, ac rhoncus sapien orci a tortor. Maecenas porttitor, mauris in vestibulum pharetra, tellus urna finibus lorem, id condimentum mi magna id erat. Nunc laoreet, neque nec varius aliquet, enim tortor facilisis magna, at dignissim nibh mi eu massa. Aliquam ultricies purus in lacus egestas, sit amet maximus lacus luctus. Pellentesque a nulla sed massa lacinia condimentum. Praesent sagittis venenatis nisi sit amet consequat. In venenatis purus risus, a tempus ligula euismod et. Fusce eu molestie quam, at vehicula massa. Praesent commodo risus sit amet nisi lacinia sagittis.</p>
       </div> 
    </div>
  </section>
  <section class='section section--four' id='section4'>
    <div class='section__bg'></div>
    <button class='button--close'>x</button>
    <div class='section__content'>
      <div class='section__bg image'></div>
      <h2 class="section__title">Vivamus molestie gravida turpis</h2>
      <div class="section__content__body">
      <p>Etiam nibh felis, malesuada nec nisi nec, luctus mattis risus. Vivamus id ipsum lacus. Morbi sed ligula id quam faucibus maximus vel nec ante. Donec sem risus, interdum a massa bibendum, accumsan dapibus felis. Vivamus non sem ullamcorper, pellentesque libero ut, maximus felis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec volutpat tincidunt dapibus. Sed et nunc cursus, pulvinar urna a, consectetur erat. Ut dignissim felis lobortis, consequat nibh ac, sagittis sem. Quisque id sodales tortor. Praesent lobortis elit ante, id bibendum lorem ornare eu. Duis quis mi sed velit interdum maximus. Nam venenatis libero quis arcu sagittis efficitur. Donec euismod mauris nec lacus ultrices sollicitudin. Suspendisse egestas purus vel scelerisque luctus.</p>
       </div> 
    </div>
  </section>
  
</main>
              
            
!

CSS

              
                //---------------------------
//  SECTIONS
//---------------------------

* {
  box-sizing: border-box;
}

html {
  background-color: #333;
}
body {
  margin: 0 auto;
  overflow: hidden;
}

$total-sections: 4;
$section-rotate: 11;
.clipped {
  height: 100vh;
  background-color: red;
  background-image: url(https://images.pexels.com/photos/165875/pexels-photo-165875.jpeg?w=940&h=650&auto=compress&cs=tinysrgb);
  -webkit-clip-path: polygon(25% 0%, 100% 0%, 75% 100%, 0 100%);
  clip-path: polygon(25% 0%, 100% 0%, 75% 100%, 0 100%);
  width: 25%;
  float: left;
}

html {
  font-size: 16px;
}

body {
  overflow: hidden;
  min-width: 1200px;
  background-color: black;
  font-family: 'Playfair Display', serif;
}

.main {
  overflow: hidden;
  position: relative;
  height: 100vh;
  display: flex;
  flex-flow: row nowrap;
  width: 100vw;
  transition: all 0.05s ease-out;
}

.section {
  flex: 1;
  position: relative;
  width: 100%;
  overflow: hidden;
  z-index: 1;
  height: 100vh;
  //transform: skewX(#{$section-rotate}deg) translateZ(0);
  margin-right: -1px;
  cursor: pointer;
  transition: all 0.3s ease-out;
  -webkit-clip-path: polygon(100px 0%, 100% 0%, 100% 100%, 0 100%);
  clip-path: polygon(100px 0%, 100% 0%, 100% 100%, 0 100%);
  margin-left: -11%;

  &:first-child {
    -webkit-clip-path: none;
  }
  &:last-child {
      margin-right: -11%;
  }

  &__bg {
    content: "";
    position: absolute;
    background-position: center;
    background-size: auto 100%;
    width: 100%;
    left: 0;
    height: 100vh;
    width: 100%;
    
    @media screen and (min-width: 1500px) {
      background-size: cover;
    }
  }
  &__content {
    padding: 2rem;
    width: 80%;
    width: 20vw;
    height: 100%;
    z-index: 1;
    display: flex;
    flex-direction: column;
    //align-items: center;
    justify-content: center;
    margin: auto;
    position: absolute;
    top: 0;
    left: 18%;
    color: black;
    opacity: 0;
    background: rgba(255,255,255,0.75);
    
    &__body {
      padding-left: calc(40% + 50px);
      font-size: 18px;
      line-height: 1.8;
      padding-right: 50px;
    }
  }
  &--one {
    .section__bg {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/180245/food1.jpeg");
    }
  }
  &--two {
    .section__bg {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/180245/food2.jpeg");
    }
  }
  &--three {
    .section__bg {
  background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/180245/food3.jpeg");
    }
  }
  &--four {
    .section__bg {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/180245/food4.jpeg");
    }
  }
  
  &__title {
    font-family: 'Cookie', cursive;
    font-size: 100px;
    text-align: left;
    padding-left: 30%;
    color: black;
    text-shadow: 0px 0px 10px rgba(255,255,255,0.7);
    margin: 0 0 30px;
  }
}

.button {
  &--close {
    position: absolute;
    top: 15px;
    left: 15px;
    background-color: transparent;
    color: black;
    border: none;
    cursor: pointer;
    z-index: 10;
    padding: 10px;
    transition: all 0.15s ease-out;
    outline: 0;
    
    &:hover,
    &:focus {
      transform: scale(1.2);
    }
  }
}

.image {
  z-index: -1;
  clip-path: polygon(10% 20%, 40% 20%, 40% 80%, 10% 80%);
}

              
            
!

JS

              
                // -------- on page load, hide content -------- //

$(document).ready(function() {
    $('.section__content').fadeOut();
});


// -------- HOVERS -------- //

$(".section").mouseover(function() {

    var $this = $(this);
    var mouseOver = new TimelineMax();

    mouseOver
        .to($this, 0.15, {
            css: {
                flex: 1.3
            },
            ease: Linear.easeOut
        })
}).mouseout(function() {

    var $this = $(this);
    var mouseOut = new TimelineMax();

    mouseOut
        .to($this, 0.15, {
            css: {
                flex: 1
            },
            ease: Linear.easeOut
        })

});



// -------- CLICK TO EXPAND -------- //

$(".section").click(function(e) {

    var button = $('.button--close');
    if (!button.is(e.target)) {
        $(this).removeClass('is-inactive').addClass('is-active').siblings().removeClass('is-active').addClass('is-inactive');

        var $this = $(this),
            $bg = $(this).find('.section__bg'),
            $content = $(this).find('.section__content'),
            $siblings = $(this).siblings(),
            $main = $('.main');

        $this.find('.button--close').fadeIn();
        $content.fadeIn();

        var activate = new TimelineMax();

        activate
            .to($siblings, 0.3, {
                css: {
                    flex: 0,
                },
                ease: Linear.easeOut
            }, 0)

        .to($content, 0.3, {
            css: {
                width: '100%',
                left: '0'
            },
            ease: Linear.easeOut
        }, 0)

        .to($content, 0.3, {
            css: {
                opacity: 1
            },
            ease: Linear.easeOut
        }, 0.35)

        .to($this, 0, {
            css: {
                position: 'static'
            },
            ease: Linear.easeOut
        }, 0.45);

    }

});



// -------- CLICK TO CLOSE -------- //

$(".button--close").click(function(e) {
  
    var $this = $(this),
        $sections = $('.section'),
        $content = $('.section__content'),
        $bg = $('.section__bg');

    $this.fadeOut();
    $content.fadeOut();

    var deActivate = new TimelineMax();

    deActivate
        .to($sections, 0.3, {
            css: {
                flex: 1
            },
            ease: Linear.easeOut
        }, 0)

    .to($sections, 0.3, {
        css: {
            position: 'relative'
        },
        ease: Linear.easeOut
    }, 0.15)

    .to($content, 0.3, {
        css: {
            width: '20vw',
            left: '18%'
        },
        ease: Linear.easeOut
    }, 0.3)

    .to($content, 0.25, {
        css: {
            opacity: 0
        },
        ease: Linear.easeOut
    }, 0);

});
              
            
!
999px

Console