JSFiddle - React, Tailwind, and code Playground

by Emmanuel Garcia

HTML

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<div class="content">
  <h1>Sticky Footer with Negative Margin 1</h1>
  <p><button id="add">Add Content</button></p>
  <div class="push"></div>
</div>

<footer class="footer">
  Footer 
</footer>

CSS

html, body {
  height: 100%;
  margin: 0;
}
.content {
  padding: 20px;
  min-height: 100%;
  margin: 0 auto -50px;
}











* {
  box-sizing: border-box;
}
body {
  font: 16px Sans-Serif;
}
h1 {
  margin: 0 0 20px 0;
}
p {
  margin: 20px 0 0 0;
}
footer {
  background: #42A5F5;
  color: white;
  line-height: 50px;
  padding: 0 20px;
}
.footer,
.push {
  height: 50px;
}

JavaScript

// Not required!
// This is just to demo functionality.

$("#add").on("click", function() {
  $("<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>").insertBefore(".push");
});