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

              
                <body>
  
  <section class="mini-page first-method">
    <section class="content">
      <h3>Fixed footer by setting positions.</h3>
      <article>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vitae odit nesciunt totam excepturi alias, nam enim eveniet natus omnis molestias. Cum saepe, nemo perferendis et maiores explicabo labore, necessitatibus sequi?</article>
    </section>
    <footer>This is footer!</footer>
  </section>
  
  <section class="mini-page second-method">
    <section class="content">
      <h3>Fixed footer by setting negative margin-top to the footer.</h3>
      <article>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vitae odit nesciunt totam excepturi alias, nam enim eveniet natus omnis molestias. Cum saepe, nemo perferendis et maiores explicabo labore, necessitatibus sequi?</article>
    </section>
    <footer>This is footer!</footer>
  </section>
  
  <section class="mini-page third-method">
    <section class="content">
      <h3>Fixed footer without define height.</h3>
      <article>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vitae odit nesciunt totam excepturi alias, nam enim eveniet natus omnis molestias. Cum saepe, nemo perferendis et maiores explicabo labore, necessitatibus sequi?</article>
    </section>
    <footer>This is footer!</footer>
  </section>
  
  <section class="mini-page fourth-method">
    <section class="content">
      <h3>Fixed footer by using calc() function.</h3>
      <article>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vitae odit nesciunt totam excepturi alias, nam enim eveniet natus omnis molestias. Cum saepe, nemo perferendis et maiores explicabo labore, necessitatibus sequi?</article>
    </section>
    <footer>This is footer!</footer>
  </section>
  
  <section class="mini-page fifth-method">
    <section class="content">
      <h3>Fixed footer by flexboxes.</h3>
      <article>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vitae odit nesciunt totam excepturi alias, nam enim eveniet natus omnis molestias. Cum saepe, nemo perferendis et maiores explicabo labore, necessitatibus sequi?</article>
    </section>
    <footer>This is footer!</footer>
  </section>
  
</body>
              
            
!

CSS

              
                $pageHeight: 300px;
$footerHeight: 50px;

* {
  box-sizing: border-box;
}

body {
  height: 100%;
}

.mini-page {
  width: 90%;
  margin: 0 auto;
  height: $pageHeight;
  outline: 1px solid black;
  padding: 10px;
  margin-bottom: 10px;
  
  footer {
    text-align: center;
  }
}

.content h3 {
  text-align: center;
}

.first-method {
  position: relative;
  min-height: 100%;
  
  .content {
    padding-bottom: $footerHeight;
  }
  
  footer {
    height: $footerHeight;
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
  }
}

.second-method {
  height: $pageHeight;
  
  .content {
    min-height: 100%;
    padding-bottom: $footerHeight;
  }
  
  footer {
    height: $footerHeight;
    margin-top: -$footerHeight;
  }
}

.third-method {
  display: table;
  height: $pageHeight;
  
  .content {
    display: table-row;
    height: 100%;
  }
}

.fourth-method {
  .content {
    min-height: calc(100% - 50px); // doesn't work with SASS variables, 50px is footer's height
  }
}

.fifth-method {
  display: flex;
  flex-direction: column;
  height: $pageHeight;
  
  .content {
    flex: 1 0 auto;
  }
  
  footer {
    flex: 0 0 auto;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console