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.

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

                  <div id="quote-box">
        <section class="hero is-success is-bold">
            <div class="hero-body">
                <div class="container">
                    <h1 class="title">
                        Random Quote Generator
                    <h2 class="subtitle">
                        Quotes provided by quotesondesign.com
        <div class="card">
            <div id="text" class="card-content quote">Design creates culture. Culture shapes values. Values determine the future.</div>
            <p class="subtitle author">
                <span id="author" class="quote-author">ROBERT L. PETERS</span>
                <span id="source" class="quote-source">							</span>
            <div class="card-footer">
                <p class="card-footer-item">
                    <a class="button" id="tweet-quote" title="Tweet this quote!" target="_blank" href="https://twitter.com/intent/tweet/?text=Design%20creates%20culture.%20Culture%20shapes%20values.%20Values%20determine%20the%20future.%20https://quotesondesign.com/robert-l-peters/">
                    <span class="fa fa-twitter"></span> Click to tweet</a>
        <div class="new-quote-button-wrapper">
            <button id="new-quote" class="get-new-quote-button">Click here to show a new quote</button>

              #quote-box {
    margin: 0 auto;
    text-align: center;

h1 {
    text-align: center;

.quote {
    font-size: 36px;
    margin: 0 auto 10px;

.card {
    width: 60%;
    margin: 50px auto 0;
    background: #f1f1f1;

.quote-author {
    display: block;
    font-size: 26px;
    text-transform: uppercase;
    font-weight: bold;
    margin: 0 auto;
    text-align: center;

.quote-source {
    display: block;
    line-height: 26px;
    font-size: 18px;
    font-weight: bold;
    text-align: center;

.quote-source a {
    color: blue;

#twitter {
    display: block;
    margin-top: 8px;
    margin-left: 29px;
    text-align: center;
    font-size: 24px;

.fa-twitter {
    color: #55ACEE;
    font-size: 34px;

.new-quote-button-wrapper {
    position: relative;
    width: 90%;
    z-index: 1;
    margin: 20px auto 0;

.new-quote-button-wrapper .get-new-quote-button {
    display: block;
    text-align: center;
    box-shadow: 0 0 10px 10px white;
    font-size: 18px;

.get-new-quote-button {
    text-decoration: none;
    color: red;
    border: 3px solid #ff0000;
    border-radius: 5px;
    padding: 15px;
    font-weight: bold;
    background: #fff;
    margin: 10px;
    display: block;
    width: 30%;
    font-size: 24px;
    text-align: center;
    margin: 0 auto;

              /* global axios */

var apiUrl =
    newQuote = document.getElementById('new-quote'),
    quoteAuthor = document.getElementById('author'),
    quoteText = document.getElementById('text'),
    quoteSource = document.getElementById('source'),
    tweetQuote = document.getElementById('tweet-quote'),
    twitterUrl = 'http://twitter.com/intent/tweet/?text=',

newQuote.addEventListener('click', function(event) {
    axios.get(apiUrl + Date.now()).then(function(response) {
        content = response.data[0];

        quoteAuthor.innerHTML = content.title;
        quoteText.innerHTML = content.content;
        typeof content.custom_meta !== 'undefined' &&
            typeof content.custom_meta.Source !== 'undefined'
            ? (quoteSource.innerHTML = 'Source: ' + content.custom_meta.Source)
            : (quoteSource.innerHTML = null);

        twitterMessage = content.content
            .replace(/(<([^>]+)>)/gi, '')
            .replace(/'/gi, '´');
        twitterMessageShortened = twitterMessage.substring(0, 108);

        tweet = twitterUrl + twitterMessageShortened + '... ' + content.link;
        tweetQuote.setAttribute('href', tweet);

var width = function () {
var centeredElement = document.getElementById('quote-box'); 
console.log('window.innerWidth: ' + window.innerWidth);

var actualSideGap = centeredElement.offsetLeft;
console.log('actualSideGap: ' + actualSideGap);

var centeredElementWidth = centeredElement.scrollWidth;
console.log('centeredElementWidth: ' + centeredElementWidth);
var gapExpectedWidth = (window.innerWidth - centeredElementWidth) / 2;
console.log('gapExpectedWidth: ' + gapExpectedWidth);
var delta = gapExpectedWidth - actualSideGap;
console.log('delta: ' + delta);
if (delta < 9 && delta > -3) {
  return true;
} else {
  console.log('Oh no...');

var hasScrollbar = function() {
  if (typeof window.innerWidth === 'number') {
    return window.innerWidth > document.documentElement.clientWidth;
console.log('Browser window has a scroll bar: ' + hasScrollbar()); 
🕑 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 ..................