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

              
                <html>

<head>
  <title>FCC Random Quote Project</title>
</head>

<body>
  <div class="wrapall">
    <div class="quotewrap">
      <div class="quote"></div>
      <div class="author"></div>
    </div>
    <div class="buttonwrap">
      <button id="tweet"><img src="https://c866088.ssl.cf3.rackcdn.com/assets/twitter30x30.png"></button>
      <button id="newquote">Quote Me</button>  
    </div>
  </div>
</body>

</html>
              
            
!

CSS

              
                body {
  padding: 0px;
  margin: 0px; }

.wrapall{
  padding: 50px;
  margin: 50px;
  max-width: 500px;
  background-color: #999;
  border-radius: 10px; }

.quote{
  color: white;
  padding: 0px 0px 25px 0px;
  font-family: fantasy;
  font-size: 15pt;
  max-width: 500px; 
  text-align: center; }

.author{
  color: white;
  padding: 0px 0px 50px 0px;
  font-family: fantasy;
  text-align: right;
  max-width: 500px; }

#tweet{
  margin: 1px 0px 0px 0px;
  padding: 1px 0px 0px 0px;
  border-radius: 5px; }

#tweet:hover {
  cursor: pointer; }

#newquote{
  padding: 10px;
  float: right;
  border-radius: 5px; }

#newquote:hover {
  cursor: pointer; }
              
            
!

JS

              
                $(document).ready(function() {
  var quote, author;
  
  function getQuote () {
    $.ajax({
      url: "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1",
      cache: false,
      success: function(json) {
        
        //the json has html embedded in it so this is to remove that markup
        var endquote = json[0].content.lastIndexOf("<");
        var quote = json[0].content.slice(3,endquote);
        
        $(".quote").html("\"" + quote + "\"");
        $(".author").html("-" + json[0].title);
      }
    });
  }
  
  getQuote();
  //$("#newquote").on("click", getQuote());
  $("#newquote").click((e) => getQuote());  
  
  $("#tweet").on("click", function() {
      window.open("https://twitter.com/intent/tweet/?text=" + $(".quote").text() + " " + $(".author").text());             
  }); 
});
              
            
!
999px

Console