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

              
                <section id="main-container">
  <div id="text-and-button">
    <div id="headers-only">
      <h1>Random Quotes Rewritten</h1>
    <p id="intro">These are some quotes from the forismatic api. You can keep clicking for new quotes.   I hope you enjoy them!</p>
    </div>
    <button id="quote-button">New Quote</button>
  </div>
  <div id="quote-container">
    <p id="quote-container-quote">Hello</p>
    <p id="quote-container-author">Franklin</p>
    <a id="twitter-link" href="#"><button id="twitter-button">Share on Twitter  <i class="fa fa-twitter"></i></button></a>
  </div>
</section>
              
            
!

CSS

              
                body {
  /*background-image: url("http://jordanholt.me/images/airport.jpg"); */
  font-size: 18px;
  background-color: #27ae60;
}

a {
  text-decoration: none;
}

#text-and-button {
  background-color: rgba(255,255,255,.8);
  border: 2px solid #49b9de;
  border-radius: 60px;
  padding-left: 10px;
  padding-right: 10px;
  max-width: 50%;
  margin-left: auto;
  margin-right: auto;
}

#main-container {
  
}

#quote-button {
  margin-top: 40px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 40px;
  display: block;
  min-width: 250px;
  min-height: 65px;
  border-radius: 45px;
  box-shadow: -5px 4px 2px rgba(25,25,25,.5);
  font-family: serif;
  font-size: 25px;
  background-color: rgb(225,225,225);
}

#quote-button:hover {
  box-shadow: -5px 4px 2px rgba(0,0,0,.8);
  border: 2px solid rgb(225,225,225,.9); 
}

#twitter-button {
  margin-top: 30px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 30px;
  display: block;
  min-width: 150px;
  min-height: 50px;
  border-radius: 45px;
  box-shadow: -5px 4px 2px rgba(25,25,25,.5);
  font-family: serif;
  font-size: 20px;
  background-color: rgb(225,225,225);
}

#twitter-button:hover {
  box-shadow: -5px 4px 2px rgba(0,0,0,.8);
  border: 2px solid rgb(225,225,225,.9); 
}

#intro {
  text-align: center;
}

h1 {
  text-align: center;
}

#quote-container {
  max-width: 65%;
  border: 2px solid rgba(222,110,73,.8);
  border-radius: 45px;
  background-color: rgba(255,255,255,.8);
  padding-left: 10px;
  padding-right: 10px;
  margin-left: auto;
  margin-right: auto;
  margin-top: 40px;
  display: none;
  font-family: sans-serif;
  text-align: center;
}

.quote-container-quote {
  font-size: 30px;
}

@media screen and (max-width: 700px) {
  #text-and-button {
    max-width: 80%;
  }
  
  #quote-button {
    max-width: 250px;
  }
}
              
            
!

JS

              
                function addQuote(data){              //Callback function from the script
  var quote = "";                     //Appends the JSONP data to the page
  quote += '<p class="quote-string" id="quote-container-quote">"';
  quote += data["quoteText"];
  quote += '"</p>';
  
  var author = "";
  if (data["quoteAuthor"] != "") {          //Some of the quotes don't have authors.
    author += '<p class="quote-author" id="quote-container-author">"';  //This block prevents empty quotes showing.
    author += data["quoteAuthor"];
    author += '"</p>';
  } else {
    author = '<p class="quote-author" id="quote-container-author"></p>';
  }
  $("#quote-container-quote").replaceWith(quote);
  $("#quote-container-author").replaceWith(author);
  var plainQuote = data["quoteText"];
  var convertQuote = encodeURIComponent(plainQuote);
  var convertAuthor = encodeURIComponent(data["quoteAuthor"]);
  var tweet = "https://twitter.com/intent/tweet/?text=" + convertQuote + "&via=" + convertAuthor; 
  $("#twitter-link").attr("href", tweet);
  $("#twitter-link").attr("target", "_blank")
}

function requestJSONP(url) {
  var script = document.createElement('script');
  script.src = url;
  document.getElementsByTagName('head')[0].appendChild(script);
  script.onload = function() {
    this.remove();
  }
}

$("#quote-button").click(function() {
  $("#quote-container").hide("slow");
  var url = "https://api.forismatic.com/api/1.0/?method=getQuote&key=&format=jsonp&lang=en&jsonp=addQuote&nocache=" + (new Date()).getTime();
  requestJSONP(url);
  $("#quote-container").show("slow");
  
  //alert (url);
}); 

/*$("#quote-button").click(function() {
  $.ajax({
    url: "https://api.forismatic.com/api/1.0/",
    jsonp: "jsonp",
    dataType: "jsonp",
    data: {
      method: "getQuote",
      lang: "en",
      format: "jsonp"
    },
    success: addQuote(data);
  });
});
  */

              
            
!
999px

Console