Pure CSS3 slide down toggle demo by Surjith

Posted on September 15th, 2019

A pure CSS3 slide down toggle demo created by Surjith. Just click on the button Run Pen below to see how it works:

How to create a pure CSS3 slide down toggle

Step 1: Add Html

<!-- Use a input to handle a click event -->
<input type="checkbox" name="toggle" id="toggle" />
<label for="toggle"></label>

<!-- Container which is opened by default -->
<div class="container">
  <h1>Pure CSS3 Slide Down Toggle Demo</h1>
  <h2>Click the Open button to see hidden mesage.</h2>

<!-- Message which is opened after user clicks on Open button -->
<div class="message">
  <h1>hello, I'm a hidden message. You found it.</h1>
  <h2>Now Click the Heart button in the bottom to support CSS3</h2>

Step 2: Add CSS

/* Default css to make the demo more pretty */
* {
  margin: 0;
  padding: 0;
  font-family: 'Helvetica Neue', Helvetica, Sans-serif;
  word-spacing: -2px;

h1 {
  font-size: 40px;
  font-weight: bold;
  color: #191919;
  -webkit-font-smoothing: antialiased;

h2 {
  font-weight: normal;
  font-size: 20px;
  color: #888;
  padding: 5px 0;

/* Style for the message. First, set the top value is -250px to hide it. */
.message {
  background: #181818;
  color: #fff;
  position: absolute;
  top: -250px;
  left: 0;
  width: 100%;
  height: 250px;
  padding: 20px;
  transition: top 300ms cubic-bezier(0.17, 0.04, 0.03, 0.94);
  overflow: hidden;
  box-sizing: border-box;

.message h1 {
  color: #fff;

/* Style for toggle button */
#toggle {
  position: absolute;
  appearance: none;
  cursor: pointer;
  left: -100%;
  top: -100%;

#toggle + label {
  position: absolute;
  cursor: pointer;
  padding: 10px;
  background: #26ae90;
  width: 100px;
  border-radius: 3px;
  padding: 8px 10px;
  color: #fff;
  line-height: 20px;
  font-size: 12px;
  text-align: center;
  -webkit-font-smoothing: antialiased;
  cursor: pointer;
  margin: 20px 50px;
  transition: all 500ms ease;
#toggle + label:after {
  content: 'Open';

.container {
  transition: margin 300ms cubic-bezier(0.17, 0.04, 0.03, 0.94);
  padding: 5em 3em;

Style when the input is checked.
Just set new top value for the message as 0 to show it on top.
#toggle:checked ~ .message {
  top: 0;

/* Set margin-top for the container to pull it down  */
#toggle:checked ~ .container {
  margin-top: 250px;

#toggle:checked + label {
  background: #dd6149;

#toggle:checked + label:after {
  content: 'Close';

Pure CSS Slide Down Toggle. No JS. Seriously
Inspired by Layervault