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


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


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.


                <div id="magic8ball">
  <div id="window">
    <div id="message">
<button type="button" onclick="shake()">Shake</button>


  box-sizing: border-box;

  height: 100vh;
  background-image: url(;
  background-size: cover;

  width: 500px;
  height: 500px;
  background-color: black;
  position: absolute;
  left: calc(50% - 250px);
  top: calc(50% - 250px);
  border-radius: 250px;

  width: 200px;
  height: 200px;
  background-color: darkblue;
  position: absolute;
  left: calc(50% - 100px);
  top: calc(50% - 100px);
  border-radius: 100px;  

#message span{
  width: 150px;
  height: 150px;
  opacity: 0;
  background-color: white;
  position: absolute;
  left: calc(50% - 75px);
  top: calc(50% - 85px);
  clip-path: polygon(50% 0%, 100% 90%, 0% 90%);
  shape-outside: polygon(0% 0%, 50% 0%, 0% 90%);
  display: flex;
  text-align: center;
  align-items: center;
  justify-content: center;
  padding: 85px 45px 45px 45px;
  transition: opacity 1s ease-in-out;



                const answers = `It is certain
It is decidedly so
Without a doubt
Yes - definitely
You may rely on it
As I see it, yes
Most likely
Outlook good
Signs point to yes
Reply hazy, try again
Ask again later
Better not to tell you now
Cannot predict now
Concentrate and ask again
Don't count on it
My reply is no
Sources say no
Outlook not so good
Very doubtful`.split("\n");

const choice = () => answers[Math.floor(Math.random() * answers.length)];

const message = document.querySelector("span");

const show = () => {
  message.innerText = choice(answers); = 1;
  document.body.removeEventListener("transitionend", show, true);

function shake() {
  document.body.addEventListener("transitionend", show, true); = 0;

window.addEventListener('load', show, true);