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

              
                <html>

<body>
  <div class='container-fluid'>
    <div class='col-md-6 col-md-offset-3 text-center'>
      <h1>Random Quotes</h1>
      <p>Click the button below to generate random quotes.</p>
      <hr />
      <div id='the-quote'>
        <em>
        <strong>
          <span>Oops...I guess we have nothing to say.</span>
        </strong>
      </em>
        <footer>
          <span>
          - by this guy. 
         <span>
       </footer>
      <br />
  </div>
    <button class='btn btn-default quote'> Next Quote </button>
 
  <div class='source'>
    Quote Provided By: <a href='https://www.google.com'>QuotesAndDesign.com</a>
  </div>
 <hr />
 <a class='btn btn-default btn-info' href="#">Tweet This!</a>
 </div>
</div>
</body>
</html>
              
            
!

CSS

              
                .fa-quote-left {
  position: absolute;
  float: left;
  font-size: 5em;
  font-style: italic;
  margin-left: -65%;
}

.fa-quote-right{
  position: absolute;
  float: right;
  font-size: 5em;
  font-style: italic;
  margin-left: 45%;
}

.source{
  padding: 5%;
}

strong span{
  font-size: 2em;
}

footer span{
  font-size: 1.5em;
}

h1{
  font-size: 4em;
}

.btn-info a {
  color: #FFF;
}

              
            
!

JS

              
                $(document).ready(function() {
  //Adds first quote to DOM.
  newQuote();

  //Grabs quote from API. Sends quote JSON to displayQuote() function. Sends quote JSON to tweetURL function.
  function newQuote() {

    $.ajax({
        url: "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&jsonp=?",
        success: function(quote){
          displayQuote(quote);
          tweetURL(quote);
        },
        cache: false
    });
}

  //Populates the DOM with the quote, author, and link.
  function displayQuote(quote) {
    $('strong span').html(quote[0].content).fadeIn('slow');
    $('footer span').html('- ' + quote[0].title).fadeIn('slow');
    $('.source a').attr('href', quote[0].link).fadeIn('slow');
  }

  //Fades out the previous quote and author.
  function fadeQuote() {
    $('strong span').fadeOut('slow');
    $('footer span').fadeOut('slow');
  }

  //Creates Twitter URL from qoute JSON.
  function tweetURL(quote) {
    var tweetContent = quote[0].content.replace(/(<([^>]+)>)/ig, "");
    var url;

    if (quote[0].content.length >= 140) {
      tweetContent = tweetContent.slice(0, 135) + "(...)";
    } else {
      tweetContent;
    }
    url = "https://twitter.com/intent/tweet?text=" + tweetContent;
    addURL(url);
  }

  //add quote URL to Tweet button
  function addURL(newURL) {
    $('.btn-info').attr('href', newURL);
  }

  //set link window size and functionality
  $('.btn-info').click(function(event) {
    var width = 575,
      height = 400,
      left = ($(window).width() - width) / 2,
      top = ($(window).height() - height) / 2,
      url = this.href,
      opts = 'status=1' +
      ',width=' + width +
      ',height=' + height +
      ',top=' + top +
      ',left=' + left;
    window.open(url, 'twitter', opts);
    return false;
  })

  //replace quote on click
  $('.quote').click(function() {
    fadeQuote();
    newQuote();
  });

});

              
            
!
999px

Console