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

              
                <div id='myApp'>
</div>
<p>My <a target="blank" href="https://codepen.io/gokemon/"><i class="fa fa-codepen"></i></a></p>

              
            
!

CSS

              
                
@import url(//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css);

.heroHeader {
  height: 200px;
  max-height: 200px;
  min-height: 50px;
  background: url('http://portfolio.gokemon.xyz/wp-content/uploads/2016/08/web-code.gif') no-repeat center;
  background-size: cover;
  left: 0;
  right: 0;
  position: fixed;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  &-content {
    position: relative;
    z-index: 1;
  }
  &::before {
    content: "";
    background: rgba(#000, 0.45);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transition: background 400ms;
    z-index: 0;
  }
}

/* Lets make the page a little interesting */
@import 'https://fonts.googleapis.com/css?family=Montserrat:400,7000';



body,
html {
  font-family: 'Montserrat', sans-serif;
  margin: 0;
  padding: 0;
  -webkit-overflow-scrolling: touch;
}

h1 {
  margin: 0;
  padding: 0;
}

p {
  margin: 0;
  padding: 0 0 25px 0;
}

.title {
  color: #fff;
  text-align: center;
  font-size: 40px;
  font-weight: 600;
}

section {
  width: 600px;
  max-width: 100%;
  padding: 225px 20px 20px 20px;
  margin: 0 auto;
  display: block;
  line-height: 150%;
}
              
            
!

JS

              
                
class HeroHeader extends React.Component {  
  constructor (...args) {
    super(...args);
    this.state = { height: undefined }
    this._containerDOM = null;
    this._scrollPosition = 0;
    this.onScroll = this.onScroll.bind(this);
  }
  
  componentDidMount () {
    window.addEventListener('scroll', this.onScroll)
  }
  
  onScroll () {
    const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
    if (this.props.scrollAction >= scrollTop) {
      const step = this._scrollPosition - scrollTop;
      const actualHeight = this._containerDOM.offsetHeight;
      const height = actualHeight + step;
      this.setState({ height });
      this._scrollPosition = scrollTop;
    }
  }

  render () {
    return (
      <header
        className='heroHeader'
        ref={n => this._containerDOM = n}
        style={{height: this.state.height }}>
          <div className='heroHeader-content'>
            {this.props.children}
          </div>
      </header>
    );
  }
}

HeroHeader.propTypes = {
  scrollAction: React.PropTypes.string
};

HeroHeader.defaultProps = {
  scrollAction: 250
};

function DummyContent () {
  return (
    <section>
     <p> Bacon ipsum dolor amet shank t-bone swine, porchetta pig in exercitation. Shoulder chuck pork belly reprehenderit ut laboris exercitation. Do incididunt spare ribs andouille, filet mignon esse sint ex ribeye. Ham in nulla eu rump, ut ut meatloaf.
</p><p>
      Learning React on a Hero Header Component so I can change the height of the header after scrolling. <code>scrollAction</code> defines where it changes the height of the header. If the scroll is after this point, it won't do anything.
      </p><p>
Strip steak shank officia fatback bacon eu frankfurter adipisicing beef ribs. Voluptate in strip steak alcatra, pork belly kielbasa commodo rump dolor pig meatloaf cupidatat cillum nulla pastrami. Ut pork belly lorem aute id ham hock, mollit in sint. Tail ea andouille laboris. Exercitation shoulder brisket <a target="blank" href="https://codepen.io/gokemon/"><i class="fa fa-codepen"></i></a>enim. Voluptate kevin aliquip culpa sunt tri-tip. Porchetta culpa in ullamco hamburger pariatur picanha cillum fugiat meatball aute swine et. 
      
</p><p>
Et qui ut quis tongue esse, hamburger veniam dolor. Cow sed ground round sunt. Tenderloin aute ham, turducken ut doner sausage leberkas spare ribs minim beef quis kielbasa biltong. Short ribs ad qui, pork loin nisi pastrami nostrud laborum brisket pork belly incididunt magna voluptate ham hock.
</p><p>
Spare ribs tongue pork chop, quis ex sirloin consequat turducken lorem short loin. Filet mignon alcatra shank cillum consectetur, jerky corned beef. Laboris doner biltong ipsum pastrami shoulder brisket cupidatat esse pork. Pariatur est andouille adipisicing esse biltong.
</p><p>
Eiusmod anim enim magna picanha reprehenderit chicken in dolore leberkas do ham hock meatloaf. Pork chop pancetta ham magna, mollit commodo ut labore officia beef ribs turducken incididunt voluptate lorem. Andouille adipisicing id, salami ea reprehenderit pig elit hamburger nisi ex cupidatat. Ut ea in et magna sausage leberkas ipsum pork belly landjaeger id elit pancetta. Cillum jowl in eu. In andouille laborum fugiat laboris rump tri-tip picanha beef ribs spare ribs salami jerky excepteur sint shank.</p>
    </section>
  );
}

function App () {
  return (
    <div>
      <HeroHeader>
        <h1 className='title'>Why We Like Pure HTML5</h1>
      </HeroHeader>
      <DummyContent />
    </div>
  )
}

ReactDOM.render(<App />, document.querySelector('#myApp'));
              
            
!
999px

Console