css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              
<div class="container" id="jumbotron">
<div class = "row text-center" >
<div class="col-sm-3"></div>
     <div class="col-sm-6"><h2>Random Quotes on Design</h2>
</div><div class="col-sm-3"></div></div>

  <div class = "row text-center">
<div class="col-sm-3"></div>
 <div class="col-sm-6 well message">

     <div class="quote js-quoteContainer">
    <div class="quoteContentWrapper"><span class="quoteSymbol quoteSymbol--left"><p><i class="fa fa-quote-left"></i></span><span class="quoteContent js-quote"></span><i class="fa fa-quote-right"></i></p> <p class="quoteAuthor js-quoteAuthor"></p>
    </div>
<p><a href="#" class="quoteBtn quoteBtn--new js-getQuoteBtn btn btn-primary">Give me a new quote</a>
     
       <a href="#" class="quoteBtn quoteBtn--share js-twitterBtn btn btn-info" target="_blank"><i class="quote-twitterIcon fab fa-twitter"></i> Tweet this quote</a></p>
  </div></p>
    </div>
  
    
 </div>
   <div class="col-sm-3"></div>
      </div></div> 
<div class="footer">
  <p class="text-center">Made by Liane Chan, 2018</p>
</div>


            
          
!
            
              h2 {
  font-family: 'Dancing Script',cursive;
}

.quoteContentWrapper {
  margin-left: 10px;
  width: 100%;
  height: 100%;
    padding: 40px;
}
.quoteContent {
  font-size: 24px;
  font-family: 'Cormorant Upright', serif;
  border: none;
  font-style: italic;
}
.quoteAuthor {
  font-size: 18px;
  font-family: 'Cormorant Upright', serif;
  border: none;
  float: right;
}

.fa-quote-left { 
  float: left; }
.fa-quote-right { 
  float: right; }

.footer { 
  text-align: center;
 font-family: 'Dancing Script',cursive;
  font-size: 18px;
  margin-top: 40px;}

            
          
!
            
              /*
 * Using the wonderful Quotes On Design v4.0 API
 * See more information here: https://quotesondesign.com/api-v4-0/
 */

(function() {
  'use strict';
  
  var apiUrlBase = "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1";
  var quoteContainerElem = document.querySelector('.js-quoteContainer');
  var quoteBtnElem = document.querySelector('.js-getQuoteBtn');
  var quoteElem = document.querySelector('.js-quote');
  var quoteAuthorElem = document.querySelector('.js-quoteAuthor');
  var shareBtnElem = document.querySelector('.js-twitterBtn');
  var backupQuotes = [
    {
    content: "I'd rather attempt to do something great and fail than to attempt to do nothing and succeed.",
    title: "Robert H. Schuller"
  }, {
    content: "Thousands of geniuses live and die undiscovered - either by themselves or by others.",
    title: "Mark Twain"
  }, {
    content: "We may give without loving, but we cannot love without giving.",
    title: "Bernard Meltzer"
  }, {
    content: "Every great inspiration is but an experiment - though every experiment we know, is not a great inspiration.",
    title: "Charles Ives"
  }, {
    content: "The secret of getting ahead is getting started.",
    title: "Mark Twain"
  }];
  var randomQuote;
  var errorMsg;

  // Load quote into view
  function loadQuote(quote) {
    quoteElem.innerHTML = quote.content;
    quoteAuthorElem.textContent = quote.title;
    updateShareBtn(quote);
  }

  function updateShareBtn(quote) {
    shareBtnElem.href = "https://twitter.com/intent/tweet?text=" + quote.href;
  }

  // Take out HTML and ASCII => Decode => Encode
  function scrubQuote(data) {
    data.content = data.content.replace(/(<([^>]+)>)/ig, "");
    data.href = data.content.replace(/&#(\d+);/g, function(m, n) { 
      return String.fromCharCode(n);
    });
    data.href = encodeURI(data.href + ' –' + data.title + ' #quotes #design');
    return data;
  }

  function loadError() {
    if (errorMsg === undefined && window.location.protocol === "https:") {
      errorMsg = document.createElement('div');
      errorMsg.classList += 'quoteError';
      errorMsg.textContent = 'Unfortunately the API we are using is on an http protocol. We\'re serving up backup quotes, but if you want new ones, please change from "https://" to "http://" in your URL.';
      quoteContainerElem.appendChild(errorMsg);
    }
  }
  
  // Setup request to API
  function requestQuote() {
    
    var apiUrl = apiUrlBase + '?' + Math.round(new Date().getTime() / 1000);
    var request = new XMLHttpRequest();
    var data;
    
    request.open('GET', apiUrl, true);
    request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');

    request.onreadystatechange = function() {
      if (request.readyState === 4 && request.status === 200) {
        data = JSON.parse(request.response)[0];
        loadQuote(scrubQuote(data));
      }
    };

    request.onerror = function() {
      console.log(request);
      randomQuote = backupQuotes[Math.floor(Math.random() * backupQuotes.length)];
      loadQuote(scrubQuote(randomQuote));
      loadError();
    };

    request.send();
  }

  function init() {
    requestQuote();
    // Add event listener to button
    quoteBtnElem.addEventListener('click', requestQuote, false);
    // emoji support
    twemoji.size = '36x36';
    twemoji.parse(document.body);
  }

  init();

}());


            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console