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 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

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

              
                <head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>
  <div class="container">
    <div id="quoteBox">
      <h1 id="quote"><i class="fa fa-refresh fa-lg fa-spin"></i></h1>
      <h4 class="text-right" id="author"></h4>
    </div>
    <div id="linksRow">
      <div class="row">
        <div class="col-sm-6" id="button">
          <div class="btn btn-block btn-secondary twitter" title="Twat this!">
            <i class="fa fa-twitter fa-lg"></i></div>
        </div>
        <div class="col-sm-6" id="button">
          <div class="btn btn-block btn-secondary generate" title="Get new quote!">
            <i class="fa fa-refresh fa-lg "></i></div>
        </div>
      </div>
    </div>
  </div>

  <p class="bottom text-center">Designed by Merryl using <a href="https://forismatic.com/en/api/" target="_blank">Forismatic</a></p>
</body>
              
            
!

CSS

              
                body {
  overflow: scroll;
  background-image: url("https://www.lifeofpix.com/wp-content/uploads/2015/11/Life-of-Pix-free-stock-photos-trees-frozen-snow-grzegorzmleczev.jpeg");
}


/*Quote Box Container*/

.container {
  /*position: fixed;*/
  background-color: white;
  width: 50%;
  left: 0;
  right: 0;
  margin: 150px auto auto auto;
  border: 8px solid black;
  padding: 3% 5% 3% 5%;
}


/*Quote*/

#quote {
  font-family: Bad Script;
  margin-bottom: 4%;
}


/*Author*/

#author {
  font-family: Lato;
  margin-bottom: 8%;
  font-weight: Bold;
  text-transform: uppercase;
}

#quoteBox {
  position: relative;
}

.twitter {
  color: white;
  background-color: #0084b4;
  border: solid #0084b4 3px;
}


/*Refresh Button*/

.generate {
  font-family: Montserrat;
  border: solid black 3px;
}

.highlighted {
  background-color: #B4B8B9;
}

/*Media Queries go here*/

@media (min-width:320px) and (max-width:374px) {
  /* smartphones, iPhone, portrait 480x320 phones */
  body{
      background-image:none
  }
 .container {
  /*position: fixed;*/
   width: 100%;
   margin: 0 auto auto auto;
  left: 0;
  right: 0;
}
  
 h1{
    font-size: 1.8em;
  }
  h4{font-size:1em;}
  
  .twitter{
    margin-bottom:10px;
  }
}
@media (min-width:375px) and (max-width:480px) {
  /* smartphones, iPhone, portrait 480x320 phones */
  body{
      background-image:none
  }
 .container {
  /*position: fixed;*/
   width: 100%;
   margin: 0 auto auto auto;
  left: 0;
  right: 0;
}
  
 h1{
    font-size: 2.1em;
  }
  h4{font-size:1.2em;}
  
  .twitter{
    margin-bottom:10px;
  }
}
@media (min-width:481px) and (max-width:640px) {
  /* portrait e-readers (Nook/Kindle), smaller tablets @ 600 or @ 640 wide. */
  .container {
   
  /*position: fixed;*/
   width: 100%;
   margin: 0 auto auto auto;
  left: 0;
  right: 0;
}
  
 h1{
    font-size: 2.8em;
  }
  h4{font-size:1.5em;}
  
  .twitter{
    margin-bottom:10px;
  }
}

.bottom{
  margin-top: 10px;
  bottom:0;
  left:0;
  right:0;
  font-family: Lato;
  
}
              
            
!

JS

              
                $(function() {

  var quoteTexts;
  var quoteNoPunctuation;
  var authorName;
  var twitterExport;

  newQuote(); //runs function on page load

  //Function runs on clicking refresh
  $(".generate").on("click", function(event) {
    event.preventDefault();
    newQuote();
  });

  //Function calling API and assigning data
  function newQuote() {
    $.ajax({
      url: "https://api.forismatic.com/api/1.0/",
      //add jsonp on Access Control Allow Origin error
      jsonp: "jsonp",
      dataType: "jsonp",
      data: {
        method: "getQuote",
        format: "jsonp",
        lang: "en"
      }, //upon success, execute below
      success: function(quote) {
          //removes the fullstop
          quoteTexts = quote.quoteText;

          for (i = quoteTexts.length - 1; i > 0; i--) {
            if (quoteTexts.charAt(i) == ".") {
              quoteNoPunctuation = quoteTexts.substring(0, i);
              break;
            }
          }       
             

          $("#quote").text(quoteNoPunctuation);

          if (quote.quoteAuthor) {
            authorName = quote.quoteAuthor;
          } else {
            authorName = "Unknown";
          }
          $("#author").text(authorName);
          twitterExport = quoteNoPunctuation + " - " + authorName;

        } //success callback ends
    }); //ajax ends
  } //newQuote ends

  $(".twitter").on("click", function() {
if(twitterExport.length<=140){
  window.open('https://twitter.com/intent/tweet?text=' + twitterExport);
}else{
  window.open('https://twitter.com/intent/tweet?text=' + twitterExport.substring(0,137) + "...");
}
  })

  $(".generate").hover(function() {
    $(this).toggleClass('highlighted');
  });

});
              
            
!
999px

Console