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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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">
  <h1>Random Quote Generator</h1>
  <button onclick="newQuote()">Click me!</button>
  <div id="qDisplay"></div>
  <button id="tQuote" onclick="tQuote()">Tweet this quote!</button>
</div>
              
            
!

CSS

              
                html, body {
  background: black;
  color: yellow;
  text-align: center;
  font-family: "Rubik", sans-serif
}

.container {
  margin: auto;
  margin-top: 30px;
  width: 90%;
  min-width: 100px;
  border: 7px solid yellow;
  padding: 10px;
  border-radius: 15px;
}

#qDisplay {
  border-radius: 10px;
  border: 4px solid yellow;
  min-height: 20px;
  margin: 10px auto;
  padding: 20px;
  width: 60%;
  font-size: 7vw;
  font-weight: 400;
  font-style: italic;
}

.dsgif {
  background: url("https://media.giphy.com/media/SVhnmDDdOzrZC/giphy.gif") no-repeat center;
  background-size: contain;
  height: 200px;
}

h1 {
  font-size: 10vw;
  text-transform: uppercase;
}

button {
  color: yellow;
  background-color: black;
  border: 2px solid yellow;
  border-radius: 5px;
  padding: 5px;
  font-size: 10vw;
  font-family: "Rubik", sans-serif;
  text-transform: uppercase;
}

#tQuote {
  font-size: 7vw;
}

button:hover, button:focus {
  text-shadow: 0 0 2px #fff;
  box-shadow: 0 0 15px blue;  
}

button:active {
  text-shadow: 0 0 5px #fff;
  box-shadow: 0 0 15px red;
}

@media only screen and (min-width: 500px) {
  button {
    font-size: 1.5em;
  }
  #tQuote {
    font-size: 1em;
  }   
  #qDisplay {
    font-size: 1.5em;
  }
  .container {
     width: 70%;
     max-width: 600px;
  }
  h1 {
     font-size: 3em;
  }
}

              
            
!

JS

              
                var quotes = ["I find your lack of faith disturbing.", " ", "Use the Force, Luke.", "You don’t need to see his identification … These aren’t the droids you’re looking for … He can go about his business … Move along.", "Help me Obi-Wan Kenobi. You’re my only hope.", "May the Force be with you.", "This will be a day long remembered. It has seen the end of Kenobi, and will soon see the end of the rebellion.", "What a piece of junk!", "Don’t call me a mindless philosopher, you overweight glob of grease.", "I’m Luke Skywalker, I’m here to rescue you.", "Watch your mouth kid, or you’ll find yourself floating home.", "Evacuate in our moment of triumph? I think you overestimate their chances.", "If this is a consular ship, where is the ambassador? — Commander, tear this ship apart until you’ve found those plans. And bring me the passengers, I want them alive!", "Look, good against remotes is one thing, good against the living, that’s something else.", "Aren’t you a little short for a stormtrooper?", "What are we going to do? We’ll be sent to the spice mines of Kessel and smashed into who knows what.", "That’s no moon, it’s a space station.", "Mos Eisley spaceport. You will never find a more wretched hive of scum and villainy.", "Into the garbage chute, flyboy!", "This is Red 5, I’m going in.", "Boring conversation anyway. Luke, we’re gonna have company!", "The Force is strong with this one.", "I suggest a new strategy, R2. Let the wookiee win.", "You’re all clear, kid! Now let’s blow this thing and go home!", "These blast points — too accurate for sandpeople. Only imperial stormtroopers are so precise.", "I’ve got a very bad feeling about this.", "You’ve never heard of the Millennium Falcon? … It’s the ship that made the Kessel run in less than 12 parsecs."];
  
var i = 0;
document.getElementById("qDisplay").innerHTML = '"' + quotes[i] + '"';

function getRandomIntInclusive(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

function newQuote() {
  i = getRandomIntInclusive(0, (quotes.length-1));
 
  if (i === 1) {
    document.getElementById("qDisplay").innerHTML =" ";
    document.getElementById("qDisplay").className += ("dsgif");
  }
  else {
    if (document.getElementById("qDisplay").classList.contains("dsgif")) {
      document.getElementById("qDisplay").classList.remove("dsgif");
      document.getElementById("qDisplay").innerHTML = '"' + quotes[i] + '"';
    } else {
      document.getElementById("qDisplay").innerHTML = '"' + quotes[i] + '"';
    }
  }
}
    
function tQuote() {
  window.open('https://twitter.com/home/?status=' + '"' + quotes[i] + '" - via @freecodecamp project: https://bit.ly/1X4Jewe');
}

              
            
!
999px

Console