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 class="container">
  <button title="refresh"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 174.7 174.7"><path d="M166.6 13.8l-13.8 13.8c-.4-.6-.9-1.2-1.4-1.7C134.9 9.3 113.1.3 89.9.3c-23.2 0-45 9.1-61.5 25.6C11.9 42.3 2.8 64.1 2.8 87.3s9.1 45 25.6 61.5 38.3 25.6 61.5 25.6c23.2 0 45-9.1 61.5-25.6 4.7-4.7 4.7-12.3 0-17-4.7-4.7-12.3-4.7-17 0-11.9 11.9-27.8 18.5-44.5 18.5s-32.6-6.6-44.5-18.5S26.9 104 26.9 87.3c0-16.8 6.6-32.6 18.5-44.5s27.8-18.5 44.5-18.5 32.6 6.6 44.5 18.5c.5.5 1.1 1 1.7 1.4l-16.4 16.4c-2 2-.4 5.3 2.2 5.3h46.8c1.5-.2 2.9-1.5 2.9-3.3l.2-46.6c.1-2.7-3.3-4.2-5.2-2.2z"/></svg></button>
  <div class="joke">
    <details>
      <summary class="setup">what do you get when you cross a t-rex and a chicken
      </summary>
      <span class="punchline">
        nothing but death
      </span>
    </details>
  </div>
</div>

<div class="credit">
  <a href="http://badkidsjokes.tumblr.com/">@KidsWriteJokes</a>
</div>
              
            
!

CSS

              
                html {
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  font: normal 100% "Muli", Arial;
  background: #654491;
  
}

.container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 36rem;
  @media screen and (max-width: 36rem) {
    width: 90%;
  }
}

.credit {
  position: absolute;
  top: 5px; 
  right: 5px;
  a {
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 85%;
    text-decoration: none;
    opacity: 0.5;
    &:hover {
      opacity: 1;
      text-decoration: underline;
    }
  }
}

button {
  border: 0;
  padding: 20px 20px 16px 20px;
  border-radius: 10px;
   outline: none;
  -webkit-appearance: none;
  line-height: 1;
  background-color: rgba(255,255,255,0.3);
  box-shadow: 
    inset 0 2px 0 rgba(255,255,255,0.15),
    0 4px 20px rgba(0,0,0,0.2);
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 100ms ease-in-out;
  svg {
    display: inline-block;
    width: 24px;
    height: 24px;
    fill: #fff;
  }
  &:hover,
  &:focus {
    background-color:  rgba(255,255,255,0.35);
    box-shadow: 
      inset 0 2px 0 rgba(255,255,255,0.3),
      0 4px 20px rgba(0,0,0,0.35);
  }
  &:active {
    transform: translateY(-2px);
    box-shadow: 
      inset 0 2px 0 rgba(0,0,0,0.1),
      0 2px 0 rgba(0,0,0,0.3),
      0 4px 10px rgba(0,0,0,0.5);   
  }
}

.joke {
  width: 100%;
  min-height: 200px;
}

details {
  text-align: center;
  color: #fff;
  font-size: 200%;
  overflow: none;
}

summary {
  font-size: 1;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
}

details[open] summary {
  opacity: 0.8;
	animation-name: fadeOut;
  animation-duration: 150ms;
}

details span {
  display: inline-block;
  margin-top: 1rem;
}

@keyframes tinyGrow {
	0% {
    font-size: 0;
    opacity: 0;
	}
	100% {
    font-size: 1em;
    opacity: 0;
	}
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }
	100% {
		opacity: 1;
	}
}

@keyframes fadeOut {
  0% {
    opacity: 1;
  }
	100% {
		opacity: 0.8;
	}
}

details span {
	animation-name: tinyGrow, fadeIn;
  animation-duration: 350ms, 150ms;
  animation-delay: 0ms, 200ms;
}
              
            
!

JS

              
                // thank you:
// https://codepen.io/alamm/pen/bExmvp 
// ♥ 

const jokes = [
  ["what did the colour orenge say to the fruit orenge ? ", "im calling the cops cose you stole my name"],
  ["why wolves howl?", "because they have no idea what are they doing"],
	["do you no what", "get out of my house"],
	["what is funny and has eight legs", "a clown"],
	["why does the crow laugh", "beacause they are mad ha ha ha I am also mad"],
	["gess how many snakes there are", "13"],
	["my friend thought that a onion was the only food that makes you cry so what did i do?", "i threw a water melon at his face"],
	["​who is the old man that have six eyes", "it is you"],
	["what do spys eat instead of mcdonalds?", "spydonalds"],
  ["​what is the best part of bread……", "bread"],
  ["I have a butt", "Sir we all have butts"],
  ["why did the banana eat himself", "he had nothing"],
  ["What do you call a ufo that looks like a butt?", "A buttfo"],
  ["how do you stop a zombie from eating your hed", "you dont"],
  ["HEY WHATS FOR DINNER COW", "POO SIR IT IS THE FRENCH WAY"],
  ["​whats round fat and is sticky", "a greedy bee"]
];

var colors = [
  "#7E57C2",
  "#9C27B0",
  "#F012BE",
  "#E91E63",
  "#C2185B",
  "#FF4136",
  "#E65100",
  "#FF8F00",
  "#AFB42B",
  "#558B2F",
  "#43A047",
  "#009688",
  "#0097A7",
  "#0074D9",
  "#607D8B",
];

function timeToLaugh() {
	randomJoke = Math.floor(Math.random() * jokes.length);
  jokeSetup = jokes[randomJoke][0];
  jokePunchline = jokes[randomJoke][1];

	$(document).ready(function () {
    $('body').animate({
      backgroundColor: colors[Math.floor(Math.random() * colors.length)]
    }, 200);
    $('.setup').text(jokeSetup);
    $('.punchline').text(jokePunchline);
  });    
}

document.querySelector('button').addEventListener('click', timeToLaugh);
              
            
!
999px

Console