cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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 lang="en">
<head>
 <meta charset="UTF-8">
<script src="https://use.fontawesome.com/59b5333aa0.js"></script>
<link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Tangerine">
  <body>
  <h1>Random Quote Machine</h1>
<div class = "container">
  <div class = "row">
  <div class = "quote-box">
    <p id = "quote-text">
    </p>
  <p id  ="quote-author"> --
    <span id="author"></span></p>
    </div>
  </div>
  <div class = "text-center">
      <a href ="#"class = "btn btn-lg btn-primary" id="tweet-quote" title ="Tweet this quote!" target="_blank"><i class ="fa fa-twitter fa-con"></i></a>
    <button class = "buttons btn-lg btn-primary" id = "new-quotes">New Quotes</button>
  </div>
</div>
  </body>
  </head>
</html>


      
            
          
!
            
              body {
  background-color: #247291;
}
h1 {
  margin-top: 50px;
  text-align : center;
  font-weight : bold;
  font-size : 60px;
  color: white;
  text-shadow: 3px 3px 5px #000;
}
p {
  text-align :center;
  font-family: Tangerine, serif;
  font-size : 50px;
  text-shadow: 
}
.fa-con {
  color : white;
}
#tweet-quote {
  float:
}
#new-quotes {
  margin: 20px;
}
i {
  font-size:1.0em;
  margin-right: 0.4em;
}
.fa fa-quote-left {
  float: left;
}
.quote-box {
  border-radius:3px;
  position:relative;
  margin: 40px auto auto auto;
  width:450px;
  text-align: center;
  padding: 20px;
  display:table;
  background-color:pink;
}
#quote-author {
    width:450px;
    height:auto;
    clear:both;
    padding-top:20px;
    font-size:4em; 
    text-align:right;
  }
            
          
!
            
              $(document).ready(function() {
  var author;
  var quote;
  // This variable are declare globally so as not to return undefined when declare locally within the function.
  function generateQuote() {
    $.ajax({
      url: "https://cors-anywhere.herokuapp.com/https://api.forismatic.com/api/1.0/?",
      jsonp: "json",
      dataType: "json",
      //In case you encountered an error trying to access an API server. you use JSONP (JSON with Padding) is a method commonly used to bypass the cross-domain policies in web browsers. (You are not allowed to make AJAX requests to a web page perceived to be on a different server by the browser.) JSON and JSONP behave differently on the client and the server.\\
 
      data: {
      method: "getQuote",
      format: "json",
      lang: "en"
    },
      success: function(response) {
        quote = response.quoteText;
        author = response.quoteAuthor;
        $("#quote-text").text(quote);
        if(author) {
          $("#author").text(author);
        } else {
          $("#author").text("--Unknown");
        }
      }
    })
  }
  generateQuote();
  $(".buttons").on("click", function(e) {
    e.preventDefault();
    generateQuote();
  })
  $("#tweet-quote").on("click", function(e) {
    e.preventDefault();
   // Sharing your quotes on twitter.
    window.open("https://twitter.com/intent/tweet?text=" + encodeURIComponent(quote + " — " + author));
  })
  
})

            
          
!
999px
Loading ..................

Console