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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="container">

  <div id="quote-box">
    <div id="quote">
      Hold on tight...
    </div>
    <div class="pull-right" id="author">
      Who said that?
    </div>
    
    <div class="col-xs-12" id="options">
      <div id="social">
          <a id="twitter" title="Tweet this quote!" target="_blank" class='btn'>
           <i class="fa fa-twitter"></i>
           </a>
          <a id="facebook" title="Share on Facebook" target="_blank" class='btn'>
             <i class="fa fa-facebook"></i>
        </a>
      </div>
      <button id="newQuote" class="pull-right btn btn-primary">New Quote</button>
    </div>
  </div>
</div>
<footer class="text-center small">
  made by <a href='/kode29' target="_blank">Kyle M. Perkins
  </footer>
              
            
!

CSS

              
                body, .btn{
  -webkit-transition: all .5s ease-in-out;
    -moz-transition: all .5s ease-in-out;
    -ms-transition: all .5s ease-in-out;
    -o-transition: all .5s ease-in-out;
    transition: all .5s ease-in-out;
  line-height: 1.5em;
}
#quote-box{
  margin: 8% auto auto auto;
  width: 700px;
  border: 20px transparent solid;
  padding: 20px;
  border-radius: 5px;
  box-shadow: 0 0 5px rgba(0,0,0,.5);
  background-color: #fff;
  overflow: auto;
}
#quote{
  padding: 15px;
  font-size: 200%;
  line-height: 2em;
}
.btn a{
  display: block;
  height: 100%;
  width: 100%;
  line-height: 50px;
}
#social .btn{
  
  float: left;
  margin-right: 5px;
}
.btn{
  border: 0;
  cursor: pointer;
  opacity: 1;
  color: #fff;
}
.btn:hover{
  opacity: 0.9;
}
#options{
  margin-top: 15px;
}
footer{
  color: #000 !important;
  margin: 20px;
}
              
            
!

JS

              
                function rand255(){
  var newColor = Math.floor(Math.random() * 256);
  //console.log("New: "+newColor);
  return newColor;
}
   
function newRGB(){
  var r = rand255();
  var g = rand255();
  var b = rand255();
  var newColor = "rgb("+r+","+g+","+b+")";
  
  $('body').css('background-color', newColor);
  $('body').css('color', newColor);
  $('.btn').css('background-color', newColor);
}

var allQuotes;
  function getNewQuote(aQ=null){
    // Store our intial data in a global variable
    if (aQ != null){
      if (aQ.length > 0)
        allQuotes = aQ;
     }
        
    var randNum = Math.floor(Math.random() * allQuotes.length) + 1;

    var quote = allQuotes[randNum].quote;
    var author = allQuotes[randNum].author;
    
    
    
    // Update the fields
    $('#quote').html(quote);
    $('#author').html("- "+author);

    // Get new color
    newRGB();
    
    var thisURL = encodeURIComponent("https://codepen.io/kode29/pen/GyyvgG");
    var webSafeQuote = encodeURIComponent('"'+quote+'"');
    
    var twitterLink = "https://twitter.com/share?url="+thisURL+"&related=freecodecamp%2Ctwitter&hashtags=quotes%2Cfreecodecamp&text="+webSafeQuote+" - "+author;
    var facebookLink = "https://www.facebook.com/sharer/sharer.php?u="+thisURL+"&quote="+webSafeQuote+" - "+author;
    
    $('#twitter').attr('href', twitterLink);
    $('#facebook').attr('href', facebookLink);
    
  }

$(function(){
  var quotes;
  $.getJSON("https://random-quote-generator.herokuapp.com/api/quotes/", function(json){
    getNewQuote(json);
  });
  

  $('#newQuote').click(function(){
    event.preventDefault;
    getNewQuote();
  });  
});

              
            
!
999px

Console