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

              
                
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>RandomQuote_CodeCampProject</title>
  <script
  src="https://code.jquery.com/jquery-3.1.1.min.js"
  integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
  crossorigin="anonymous"></script>
</head>
<body class='randomBgColor'>
  <div id='quote-box'>
    <div id='text'>
      <i class="fa fa-quote-left randomTxtColor" aria-hidden="true"></i>
      <span id='quoteText'class='randomTxtColor'></span>
      <br>
      <span id='author' class='randomTxtColor'></span>
    </div>

    <div id='buttonBox'>
      <a  class="twitter-share-button" id="tweet-quote" target="blank" href="https://twitter.com/share" data-text="custom share text"><i class="fa fa-twitter randomBgColor" aria-hidden="true"></i></a>
      <button id='new-quote' class="randomBgColor">New Quote </button>
    </div>

  </div> <!--quotebox end -->
  <span id='credit'>by <a target='blank' href='https://codepen.io/AlbertoMontalesi/'>Alberto Montalesi </a></span>


</body>
</html>

              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Lato:400,700');

body {
  font-family: 'Lato', sans-serif;
  background-color: #3498db;

}
* {
  margin: 0;
  padding: 0;
}
.randomBgColor {
    transition: background-color 1s ease;

}
.randomTxtColor {
  transition: color 1s ease;
}
#quote-box {
  width: 400px;
  min-height: 200px;
  height: auto;
  margin: 10% auto 0 auto;
  background-color: white;
  padding: 10px;
  border-radius: 5%;
}
#text {
  padding: 25px;

}
.fa-quote-left {
  font-size: 55px;
  padding-right: 15px;
  display: inline-block;
  width: auto;
}
#quoteText {
  font-size: 25px;
  text-align: center;
  width: 70%;

}
#author {
  font-size: 16px;
  text-align: right;
  display: block;
  width: 100%;
}
#buttonBox {
  height:50px;
  padding: 15px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-content: center;
}
.fa-twitter {
  font-size: 40px;
  padding:5px 5px 0 5px;
  color: white;

}
#new-quote {
  padding:0 10px;
  cursor: pointer;
  color: white;
  font-weight: bold;

}
#new-quote:hover {
  opacity: 0.5;
}
.fa-twitter, #new-quote {
  border-radius: 20%;
  border: none;
}

#credit {
  display: block;
  margin: 0 auto;
  width: 150px;
  height: 15px;
  color: white;
}
#credit a, #credit a:hover {
  color: inherit;
  text-decoration: none;
}

              
            
!

JS

              
                // DOES NOT WORK WITH HTTPS//

$(document).ready(function(){

  getQuote(); /*to already have a quote when i load the page*/
  colorRandomizer(); //to create a random color as soon as i load
  function getQuote(){
      var url="https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?";

      $.getJSON(url,function(data){
        //store the quote and the author in var
        var currentQuote = data.quoteText;
        var currentAuthor = data.quoteAuthor;
        //add them to my html
        $("#quoteText").html(currentQuote);
        $("#author").html("- " + currentAuthor);

        //prepopulate my twitter
        $('#twitter').attr('href', 'https://twitter.com/intent/tweet?hashtags=quotes,Fcc&related=freecodecamp&text=' + encodeURIComponent('"' + currentQuote + '" ' + currentAuthor));
      });/*end get json*/


  }; /*get quote end */

  $("#new-quote").on("click",function(){
    //run my color randomizer and my get quote
    colorRandomizer();
    getQuote(); /* to generate a quote */
  });

  function colorRandomizer(){
    var myColors=["#3498db","#2ecc71","#9b59b6","#e74c3c","#f1c40f"]; //array of colors
    var randomNum= Math.floor((Math.random()*myColors.length)); //generate random number


    var randomColor= myColors[randomNum]; //store my random color
    //modify bg and txt color with my random color
    $(".randomBgColor").css("background-color",randomColor);
    $(".randomTxtColor").css("color", randomColor);
  };


});/* end jquery*/

              
            
!
999px

Console