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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <link href="https://fonts.googleapis.com/css?family=Boogaloo|Open+Sans" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<div class="container">
  <h1>Random Quotes Machine</h1>

  <div class="card">
    <div class="card-block">
      <div class="card-text" id="quote-content"></div>
      <div class="card-title" id="quote-title"><p>Loading quotes, please wait...</p></div>
      <button id="twitterBtn" class="btn btn-lg btn-primary"><i class="fa fa-twitter" aria-hidden="true"></i></button>
      <button id="getQuote" class="btn btn-lg btn-danger">Get Another Quote</button>

    <div class="card-footer text-muted" id="quote-source">
      Designed & Coded by Elliot

              body {
  text-align: center;
  font-family: 'Open Sans', sans-serif;
  background-color: #e1e8f0;
  padding: 40px 0;
  margin: 40px 0 80px;
  font-family: 'Boogaloo', cursive;
#jsonStrBox {
  border: 1px solid #ccc;
  background-color: #d8d8d8;
  font-size: 14px;
  padding: 20px;
  margin: 40px 0;
.card {
  background-color: #6ED3CF;
  border: none;
  color: #fff;
  max-width: 480px;
  margin: 0 auto;
  box-shadow: 0px 5px 50px rgba(85, 89, 93, .35);
.card-text {
  font-size: 32px;
  padding: 10px;
  font-family: 'Boogaloo', cursive;
  letter-spacing: 0.75px;
  text-shadow: 0px 2px 5px rgba(0, 0, 0, .15);
.card-footer {
  font-size: 13px;
.card-title {
  font-size: 16px;
  margin-bottom: 40px;
#getQuote {
  cursor: pointer;
  font-family: 'Boogaloo', cursive;
  box-shadow: 0px 2px 5px rgba(0, 0, 0, .15);
#getQuote:hover {
  opacity: 1;
  box-shadow: none;
#twitterBtn {
  cursor: pointer;
  box-shadow: 0px 2px 5px rgba(0, 0, 0, .15);
              var quotesArr = [];
var quoteIndex = 0;

//Hide all content before JSON load

function getQuote() {
  quoteIndex = Math.floor(Math.random() * 30);

  //Change Content
  $("#quote-title").html("- " + quotesArr[quoteIndex][1]);
  //Show Quote

$("#getQuote").on("click", function(){
  //Hide Quote

$("#twitterBtn").on("click", function(){
  //tried to use array content, changed to directly use html tag content
  var twitterContent = $("#quote-content").text();
  var otherTextLength = $("#quote-title").text().length + 4 + 6;
  var fullTwitterContent = $("#quote-content").text().length + otherTextLength;
  if (fullTwitterContent > 140) {
    twitterContent = twitterContent.substr(0, 140 - otherTextLength);
    twitterContent += "... ";
  twitterContent = encodeURIComponent(twitterContent);
  window.open("https://twitter.com/intent/tweet?hashtags=ERQM&text=" + twitterContent + $("#quote-title").text(), "_blank");

//Clear AJAX cache to request new quotes every time
$.ajaxSetup({cache: false});

$.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=30", function(json) {
  //Add JSON content into an array to load faster
    quotesArr.push([val.content, val.title]);
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.