Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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>
  <div class="row vertical-center">
    <div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
    <div id="quote-box" class="col-xs-6 col-sm-6 col-md-6 col-lg-6 row rounded-border">

      <!-- Quote -->
      <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
          <h2 id="quote-text" style="text-align:center">"Quotes go here"</h2></div>

      </div>
      <!-- Author -->
      <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
          <h4 id="quote-author" style="text-align:center">-Author</h4></div>
      </div>
      <!-- Row for buttons 
Use Font Awesome for social media icons -->
      <div class="row"></div>
      <!-- twitter icon -->
      <div id="twitter-icon" class="col-xs-2 col-sm-2 col-md-2 col-lg-2 rounded-border"><i class="fa fa-twitter-square fa-5x" aria-hidden="true"><a></a></i></div>
      <!-- Spacer div -->
      <div class="col-xs-7 col-sm-7 col-md-7 col-lg-7"></div>
      <!--     refresh icon -->
      <div id="new-quote-icon" class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><i class="fa fa-refresh fa-5x" aria-hidden="true" style="float:right"></i></div>
    </div>
    <div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
  </div>
  <!-- end of row containing entire quote-box-->
</div>

<h6 id="signature">By Derek Dotson</h6>
              
            
!

CSS

              
                body {
  background-color: black;
}

#quote-box {
  background-color: white;
  padding: 30px;
}

#quote-box button {
  color: white;
  height: 50px;
  width: 50px;
}

.rounded-border {
  border-radius: 10px;
}

.vertical-center {
  min-height: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
}

#signature {
  color: white;
  text-align: center;
}
              
            
!

JS

              
                var quoteArray = [
  ["Be the change that you wish to see in the world.", "-Mahatma Gandhi"],
  ["People who think they know everything are a great annoyance to those of us who do.", "-Isaac Asimov"],
  ["The fool doth think he is wise, but the wise man knows himself to be a fool.", "-William Shakespeare"],
  ["If you don't stand for something you will fall for anything.", "Gordon A. Eadie"],
  ["I solemnly swear that I am up to no good.", "J.K. Rowling"]
];

var colorArray = [
  "#FF99FF", // pinkish-purple
  "#9999FF", // blue
  "#00CC00", // green
  "#FF6633", // orange
  "#FFCC00", // yellow
  "#999999", // gray
];

var numQuotes = quoteArray.length;
var numColors = colorArray.length;

var randomNum;

var randomColor;
var newRandomColor;

var randomColorNumber = 0;

// arrays each containing
// text at index 0
// and author at index 1
var quote;
var newQuote;

var twitterQuote = "";

$(document).ready(function() {
  // initialize quote to a random one
  randomNum = newRandomNumber();
  randomColor = newRandomColor();

  quote = newQuote(randomNum);
  twitterQuote = quote[0] + " " + quote[1];

  $("#quote-text").text(
    quote[0]);
  $("#quote-author").text(
    quote[1]);

  $("body").css("background-color", randomColor);
  $("#quote-text").css("color", randomColor);
  $("#quote-author").css("color", randomColor);
  $("#quote-box button").css("background-color", randomColor);
  $("i").css("color", randomColor);

  // whenever #new-quote-icon is clicked
  $("#new-quote-icon").on("click", function() {

    randomNum = newRandomNumber();
    randomColor = newRandomColor();

    quote = newQuote(randomNum);
    twitterQuote = quote[0] + " " + quote[1];

    $("#quote-text").text(
      quote[0]);
    $("#quote-author").text(
      quote[1]);

    $("body").css("background-color", randomColor);
    $("#quote-text").css("color", randomColor);
    $("#quote-author").css("color", randomColor);
    $("#quote-box button").css("background-color", randomColor);
    $("i").css("color", randomColor);

  }); // end of new quote function

  // when twitter icon is clicked
  $("#twitter-icon").on("click", function() {
    window.open("https://twitter.com/intent/tweet?text=" + twitterQuote);
  }); // end of twitter click function

}); // end of document ready function

// returns quote with index randomNum
function newQuote(randomNum) {
  return quoteArray[randomNum];
}

// returns number corresponding to
// quoteArray indices
function newRandomNumber() {
  var num = Math.floor(Math.random() * (numQuotes - 1));
  if (num >= randomNum) {
    num++;
  }
  return num;
}

// returns a new random color
// that is different than
// the current one
function newRandomColor() {
  var num = Math.floor(Math.random() * (numColors - 1));

  if (num >= randomColorNumber) {
    num++;
  }

  randomColorNumber = num;
  return colorArray[num];
}
              
            
!
999px

Console