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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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

Console