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.


                <link href="|Open+Sans" rel="stylesheet">
<link href="" 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);"" + twitterContent + $("#quote-title").text(), "_blank");

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

$.getJSON("[orderby]=rand&filter[posts_per_page]=30", function(json) {
  //Add JSON content into an array to load faster
    quotesArr.push([val.content, val.title]);