Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <main>
  <h1>Fighting the Flying Footer</h1>
  <section>
    <p>Using <strong>CSS Grid</strong> to position the footer at the bottom - allowing for a variable footer height.</p>
    <hr>
    <h2>Join the Fight!</h2>
    <p>Read the blog post:<br> <a href="https://redonion.se/en/fighting-the-flying-footer/" title="Read the blog post">redonion.se</a></p>
  </section>
</main>

<footer>
  <p>I'm the footer. And I'm happy where I am.</p>
</footer>

            
          
!
            
              /*Layout styles*/
body{
  display:grid;
  grid-template-columns: 1fr;
  grid-template-rows:1fr auto;
  min-height:100vh;
}

//main{
  /*use margin 0 to have the element take up all space down to the footer*/
  /*margin:0 0 auto 0; /*use margin-bottom auto if you don't want the element to cover the length of the body*/  
//}

footer{
  margin:0;
}

//----------------------------------------------
/*Cosmetic styles*/
:root{
    --modular1: 1.125;
    --modular2: 1.414;

    --startwidth: 30;
    --endwidth:105;

    //need these numbers for h6 and p without units for calc.
    --base-min: 1;
    --base-max:1.25;

    --h1-responsive: calc(var(--h1-size) + ((var(--modular2) * var(--modular2) * var(--modular2) * var(--modular2) * var(--modular2)) - (var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));
  
      --h2-responsive:calc(var(--h2-size) + ((var(--modular2) * var(--modular2)) - (var(--modular1) * var(--modular1))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));  
  
    --p-responsive:calc(var(--p-size) + ((var(--base-max)) - (var(--base-min))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));

    --h1-size: calc(var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * 1em);
  
    //--h2-size: calc(var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * 1em);
    --h2-size: calc(var(--modular1) * var(--modular1) * 1em);

    --p-size:calc(var(--base-min) * 1em);
}

body{
  background-color:green;
  text-align:center;
  font-family:/*ios*/ "HelveticaNeue", /*android*/ "Roboto", /*fallbacks*/ Arial, Verdana, "Trebuchet MS", sans-serif;
  color:#584d4d;
}

main{
  background-color:#fffaf8;
  padding:3em 1em 0 1em;
  box-sizing:border-box;
}

footer{
  background-color:aliceblue;
  padding:0 1em;
  box-sizing:border-box;
  background-image:linear-gradient(to right, #ff885d 0%,#ff5062 100%);
  color:#FFF;
}

h1{
  font-family: 'Great Vibes', Arial, Helvetica, sans-serif;
  background-image:linear-gradient(to right, #ff885d 0%,#ff5062 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: rgba(0, 0, 0, 0);  
  color:#2f2f2f;
  font-size: var(--h1-size);
  line-height: 1.45669;//42px;
  margin:(12/28.8325)+em 0;
}

h2{
   font-size: var(--h2-size);
   line-height: 1.629629629629; //33
   margin:(9/20.25)+em 0;
   letter-spacing: 3px;
   text-transform: uppercase;
}

p{ 
  line-height:1.5;
  margin: 0.75em auto;
  font-size:var(--p-size);
}

a{
  color: #FFF;
  background-image:linear-gradient(to right, #ff7644 0%, #f94456 100%);
  text-decoration:none;
  padding:0 0.25em;
  opacity:0.85;
  transition:0.5s opacity;
  display:inline-block;
  margin:0.5em auto 0;
  
  &:hover, &:focus, &:active{
    opacity:1;
  }
}

hr{
  width:5em;
  margin:3em auto;
}

@media only screen and (min-width: 30em) {
  h1, h2{
    //expression for responsive margins
    --margin-responsive: calc((var(--margin-min, 1) * 1rem) + (var(--margin-max, 1.125) - var(--margin-min, 1)) * ((100vw - (var(--startwidth) * 1rem)) / (var(--endwidth) - var(--startwidth))));
    margin:var(--margin-responsive) auto;

    //expression for responsive line-heights
    --lineheight-responsive:calc((var(--lineheight-min) * 1rem) + (var(--lineheight-max) - var(--lineheight-min)) * ((100vw - (var(--startwidth) * 1rem)) / (var(--endwidth) - var(--startwidth))));
    line-height: var(--lineheight-responsive);
  }

  h1{
    --margin-min:0.75; //12
    --margin-max: 1.875; //30;
    --lineheight-min:2.625; //42
    --lineheight-max:7.03125;//112.5
    font-size:var(--h1-responsive);
  }
  
  h2{
    font-size:var(--h2-responsive);
    --margin-min:0.5625;//9
    --margin-max:0.9375;// 15
    --lineheight-min: 2.0625;//33px
    --lineheight-max: 3.28125;//52.5
  }
  
  p{
    font-size: var(--p-responsive);
  }
}

@media only screen and (min-width: 105em) {
  :root{
    //changing scales and base
    --modular1: var(--modular2);
    --base-min: var(--base-max);
  }
  
  h1{
    font-size: var(--h1-size);
    line-height: (112.5/90.4413);
    margin: 0.331706864em auto;//30px
  }
  
  h2{
    font-size: var(--h2-size);
    line-height:(52.5/31.9903);
    margin:(15/31.9903)+em auto;
  }
  
  p{
    font-size: var(--p-size);
  }
}

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console