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

              
                <link href='https://fonts.googleapis.com/css?family=Lobster|Pacifico|Shadows+Into+Light|Dancing+Script|Righteous' rel='stylesheet' type='text/css'>
<!-- HTML -->
<div class="container">
  <h1 class="text-center">Random Quote Generator</h1>
  <br>
  <div class="jumbotron">
    <blockquote>
      <p class="quote text-center"></p>
      <footer class="author text-center"></footer>
    </blockquote>
    <div class="text-center">
      <div class="section">
        <button id="getQuote" class="btn btn-primary"><i class="fa fa-quote-left"></i> New Quote <i class="fa fa-quote-right"></i></button>
        <a class="btn btn-primary" id="tweet" target="_blank" href=""><i class="fa fa-twitter"></i> Tweet This Quote!</a>
      </div>
    </div><!--row-->
  </div><!--jumbotron-->
</div>
<footer class="text-center">
  &copy <a href="https://www.linkedin.com/in/matthew-corby-64b205a6?trk=nav_responsive_tab_profile_pic" target="_blank">2016 Matt Corby</a>
</footer>
              
            
!

CSS

              
                body {
  background-color:lightskyblue;
  background-repeat: repeat;
}
h1 {
  font-family: 'Righteous', cursive;
  color: black;
}
.quote {
  font-family: 'Pacifico', cursive;
}
.author {
  font-family: 'Shadows into light', cursive;
}
.btns {
  margin-left: 190px;
}



              
            
!

JS

              
                var quotes = [ 
  {
    quote: "\"Alright, alright, alright.\"",
    author: "Matthew McConaghey"
  },
  {
    quote: "\"You're not wrong...\"",
    author: "Andrew Nave"
  },
  {
    quote: "\"This thing doesn't have enough jiggly-bits...\"",
    author: "Aaron Sperbeck"
  },
  {
    quote: "\"Look at my unnecessarily tall hat. How absurd!\"",
    author: "Abraham Lincoln"
  },
  {
    quote: "\"GRASS TASTES BAD.\"",
    author: "Rick Sanchez"
  },
  {
    quote: "\"Hello IT, have you tried turning it off and on again?\"",
    author: "Roy Trenneman"
  },
  {
    quote: "\"Eat beans and stay out of jail.\"",
    author: "Flea"
  },
  {
    quote: "\"Don't sweat the petty things and don't pet the sweaty things.\"",
    author: "George Carlin"
  },
  {
    quote: "\"TREAT YO SELF\"",
    author: "Tom Haverford"
  },
  {
    quote: "\"The inner mechanisms of my mind are an enigma...\"",
    author: "Patrick Star"
  },
  {
    quote: "\"Guys look i'm SICK\"",
    author: "Greg Chieco"
  }
];

$(document).ready(function(){
  //Get a random number between 0 and the number of quotes
  function getRandIndex(){
  var max = Object.keys(quotes).length;
  return Math.floor(Math.random() * (max+1));
  }
  //Need a random number between 0 and # of objects in JSON-1
  var randQuoteIndex = getRandIndex();
  //Use the random number to select a random quote and display it
  $(".quote").html(quotes[randQuoteIndex].quote);
  $(".author").html(quotes[randQuoteIndex].author);
  //Set twitter link
  var tweet = "https://twitter.com/intent/tweet?text=" + quotes[randQuoteIndex].quote + " - " + quotes[randQuoteIndex].author + "... A quote from @mcorbae17 's random quote generator: https://codepen.io/mcorby17/full/JKdoMN/";
  $("#tweet").attr('href', tweet);
  //Click function
  $("#getQuote").on("click", function(){
    var prevIndex = randQuoteIndex; //Keep track of what the last quote was so we don't display it twice in a row
    var newIndex = getRandIndex();
    randQuoteIndex = newIndex;
    //If the new quote is the same as the old quote get another random index
    if(newIndex === prevIndex)
      newIndex = getRandIndex();
    //Display the new quote
    $(".quote").html(quotes[newIndex].quote);
    $(".author").html(quotes[newIndex].author);
    tweet = "https://twitter.com/intent/tweet?text=" + quotes[newIndex].quote + " - " + quotes[newIndex].author + "... A quote from @mcorbae17 's random quote generator: https://codepen.io/mcorby17/full/JKdoMN/";
    $("#tweet").attr('href', tweet);
  });
});
              
            
!
999px

Console