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-fluid">
  <div class = "row center-block text-center">
    <h2>random quote generator</h2>
  </div>
  <div class = "row center-block">
   
       
      <div class = "col-md-6 col-md-offset-3 quote text-center" id = "quotebox">
        <div id ="quotetext">
        </div>
        <div id ="source">
        </div>
        
    </div>
    
  </div>
  <div class = "row">
    
    <div class = "col-md-6 col-md-offset-3 text-center">
      <button id = "getQuote" class = "button-class">
        Get Quote
      </button>
      <a href="#" id="tweet-this-post" class="tweet-post-class">Tweet it!</a>
    </div>
    </div>
  </div>
</div>

            
          
!
            
              body {
  background-color: #96ccc7;
  font-family: 'Oswald', sans-serif;
  font-size: 36px;
}
h1 {
  font-family: 'Lobster', cursive;
  font-size: 100px;
}
h2 {
  font-family: 'Lobster', cursive;
  font-size: 40px;
}

blockquote {
  border-left: white;
  background: #fff;
  margin: 1.5em 10px;
  padding: 0.5em 10px;
  quotes: "\201C""\201D""\2018""\2019";
}

blockquote:before {
  color: #ccc;
  content: open-quote;
  font-size: 4em;
  line-height: 0.1em;
  margin-right: 0.25em;
  vertical-align: -0.4em;
}
.row {
  padding: 30px 20px 20px 30px;
}

.quote {
  padding: 30px 30px 30px 30px;
  background-color: white;
}
.button-class {
  height: auto;
  width: auto;
  display: block;
  margin: 10px auto 0;
  padding: 10px;
  border: 0px;
  border-radius: 10px;
  font-family: 'Oswald', sans-serif;
  font-size: 24px;
  color: #fff;
  background-color: #55acee;
  text-align: center;
  cursor: pointer;
}

.button-class:active,
.button-class:hover {
  background-color: #ED327F;
  text-decoration: none;
}

.button-class:visited {
  color: #fff
}

.button-class {
  color: #fff;
  text-decoration: none
}

.tweet-post-class {
  display: inline;
  padding: 10px;
  border-radius: 5px;
  font-family: 'Oswald', sans-serif;
  font-size: 18px;
  background-color: #ED327F;
  text-align: center;
  cursor: pointer;
}

a.tweet-post-class {
  color: #fff;
  text-decoration: none
}

a.tweet-post-class:visited {
  color: #fff
}

a.tweet-post-class:active,
a.tweet-post-class:hover {
  color: #fff;
  background-color: #55acee;
}

#source {
  margin: -40px 0 0 0;
  font-family: 'Oswald', sans-serif;
  font-size: 16px;
}
            
          
!
            
              function getRandomNum(x){
  return Math.floor((Math.random() * x.length));
}

function displayQuote(quoteLocation, sourceLocation, data, x){
  
var display = quoteLocation.html( "<blockquote>" + data[x].content + "&nbsp" + "- " + data[x].title + "<br><br></blockquote>");
var source =  sourceLocation.html("<a href = '" + data[x].link + "' " + "alt='" + data[x].ID + "'>"+ "Source" + "</a>");
return display, source;
}

$(document).ready(function() {
  //Grabs JSON
  $.getJSON('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=40', function(data) {
  //Gets a random number with length of data as a parameter
var x = getRandomNum(data);
 //sets quote and source link div locations
var quoteLocation = $('#quotetext');
var sourceLocation = $('#source');
 //calls function to display quote
displayQuote(quoteLocation, sourceLocation, data, x);

});
 //Array of background colors
  var colors = ['#e0d6ff', '#c3d8ff', '#95ffd8', '#abf7ff', '#aabdff', '#ffb7fb',
'#ea9eff',
'#d292ff',
'#ac91ff', '#ceffa6',
'#e2ffac',
'#a0c997',
'#7ddfb4',
'#56ddc6'],
    color;
 //Clicking "Get Quote" button
  $('#getQuote').click(function() {
//Get a random background color
    var randColor;
    do {
      randColor = colors[Math.floor(Math.random() * colors.length)];
    } while (color == randColor);
    $('body').css('background-color', randColor);
      color = randColor;
 //Get JSON info after clicking Get Quote by calling displayQuote again
   $.getJSON('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=40', function(data) {
  
var x = getRandomNum(data);
var quoteLocation = $('#quotetext');
var sourceLocation = $('#source');
displayQuote(quoteLocation, sourceLocation, data, x);
  
  });
  
//Dynamically update Twitter button with new content on click

   var linkElement = document.getElementById("tweet-this-post");
    
$(linkElement).click(function(event){
var getQuote = document.getElementById("quotetext").children[0].innerText;
  event.preventDefault();

  var tweetedLink = window.location.origin + window.location.pathname;

  window.open("https://www.twitter.com/intent/tweet?url=&text=" + getQuote + "&via=kaitlinjane&", "twitterwindow", "height=450, width=550, toolbar=0, location=0, menubar=0, directories=0, scrollbars=0");
  
  
    });
  
});
  
  });
            
          
!
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