Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <html>
  <head>
    <meta charset="utf-8">  
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<script
			  src="https://code.jquery.com/jquery-3.3.1.js"
			  integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
			  crossorigin="anonymous"></script>
  </head>
<body><div class="everything">
  <h1><i class = "fa fa-quote-left"></i>&nbsp;Random Quote Generator&nbsp;<i class = "fa fa-quote-right"></i></h1>
  <div id = "quoteDisplay">
  <div id = "quote">You cannot buy the revolution. You cannot make the revolution. You can only be the revolution. It is in your spirit, or it is nowhere.</div>
    <div id = "author">- Ursula K. Le Guin (from The Dispossessed)</div>
    <div class="sharing"><i class = "fab fa-twitter" id = "tweetThis" title = "Tweet this quote"></i><i class = "fa fa-bullhorn" id = "tootThis" title = "Toot this quote on your favorite Mastodon instance!"></i></div>
  </div>
  <div>
    <button id="quoteButton" title="new quote?"><i class = "fa fa-quote-left"></i>&nbsp;new quote?&nbsp;<i class = "fa fa-quote-right"></i></button>
    </div>
  <footer>created by <a href="https://jmf.codes" target="_blank">jmf.codes</a></footer>   
  </div>
</body>
  
<!-- 
based on Free Code Camp project: https://www.freecodecamp.org/challenges/build-a-random-quote-machine
created by: https://www.freecodecamp.org/jennifermf
-->
              
            
!

CSS

              
                body {
  font-family: monospace;
  padding: 3%;
  margin: auto 0;
}
#quoteDisplay {
  width: 95%;
  background-color: rgba(116,119,159,0.6);
  margin-bottom: 1%;
  border: none;
}
#quote {
  padding: 5%;
  font-size: 1.5em;
  text-align: center;
}
#author {
  padding: 5%;
  font-size: 1.2em;
  text-align: right;
}
.sharing {
  font-size: 1.5em;
  text-align: right;
  margin-right: 0.5%;
  bottom: 0;
}
button {
  font-family: monospace;
  font-size: 1em;
  padding: 0.3em;
  border: dotted;
  background-color: rgba(116,119,159,0.2);
}
footer {
  text-align: center;
  font-size: 0.7em;
  margin-top: 2%;
  opacity: 0.7;
}
.everything {
  max-width: 700px;
  border: 1px black solid;
  border-radius: 1%;
  padding: 5%;
  background-color: /* gradient */ 
background: -moz-linear-gradient(-45deg, rgba(104,159,149,1) 0%, rgba(104,159,149,0) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(-45deg, rgba(104,159,149,1) 0%,rgba(104,159,149,0) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(135deg, rgba(104,159,149,1) 0%,rgba(104,159,149,0) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#689f95', endColorstr='#00689f95',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}

/* gradient code: http://colorzilla.com/gradient-editor
color pallette: http://www.color-hex.com/color-palette/54303 */
              
            
!

JS

              
                $(document).ready(function() {
  var quote = 'You cannot buy the revolution. You cannot make the revolution. You can only be the revolution. It is in your spirit, or it is nowhere.';
  var author = 'Ursula K. Le Guin (from The Dispossessed)';
  function NewQuote() {
    $.ajax({ 
    url: "https://quotes.p.mashape.com/?category=good",
    type: "GET",
    headers: {
        "X-Mashape-Key": "QIlhPCe483msh0TO6cWOP41jFxXDp1wdjKRjsnM8JfajlxVhJ1",
        "Accept": "application/json", },
    success: function(response) {
        quote = response.quote;
        author = response.author;
        $('#quote').text(quote);
        if (author) {
          $('#author').text('- ' + author);
        } else {
          $('#author').text('- Unknown');
        }
    // close success function:
    }
    // close ajax:
    }); 
    
  // close NewQuote function: 
  }; 
$('#quoteButton').on('click', function(event) { 
    NewQuote();
  });
$('#tweetThis').on('click', function(event) {
    window.open("https://twitter.com/intent/tweet?text=" + quote + " - " + author);
  });

$('#tootThis').on('click', function(event) {
  window.open("web+mastodon://share?text=" + quote + " - " + author);
});
// close document.ready:
});
    
    
    
/* based on Free Code Camp project: https://www.freecodecamp.org/challenges/build-a-random-quote-machine
created by: https://www.freecodecamp.org/jmfcodes

free random quote API: https://market.mashape.com/ishanjain28/random-quotes#

thanks to Mark Snow for a youtube video based on this codepen: https://codepen.io/MrSnowNB/pen/egLmLp?editors=0010 

thanks also to Stephen Mayeux for this video: https://www.youtube.com/watch?v=5xeDQ1-ZfcQ
*/ 
              
            
!
999px

Console