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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Raleway" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">

<div class="container">
  <div id="quoteDisplay">
  </div>
  <div id="authorDisplay">
  </div>
  <div id="bottomNav">
  <button id="newQuote">New Quote</button>
  </div>
</div>
<div id="credit">
  <p>coded by David Schmid</p>
  <a href="https://codepen.io/EddieDavids/" target="_blank" class="fab fa-codepen"></a>
  <a href="https://www.linkedin.com/in/david-schmid-425b15137/" target="_blank" id="linkedinIcon" class="fab fa-linkedin"></a>
</div>
              
            
!

CSS

              
                body {
  background: rgba(116,235,213,1);
background: -moz-linear-gradient(left, rgba(116,235,213,1) 0%, rgba(116,235,213,1) 0%, rgba(172,183,229,1) 100%);
background: -webkit-gradient(left top, right top, color-stop(0%, rgba(116,235,213,1)), color-stop(0%, rgba(116,235,213,1)), color-stop(100%, rgba(172,183,229,1)));
background: -webkit-linear-gradient(left, rgba(116,235,213,1) 0%, rgba(116,235,213,1) 0%, rgba(172,183,229,1) 100%);
background: -o-linear-gradient(left, rgba(116,235,213,1) 0%, rgba(116,235,213,1) 0%, rgba(172,183,229,1) 100%);
background: -ms-linear-gradient(left, rgba(116,235,213,1) 0%, rgba(116,235,213,1) 0%, rgba(172,183,229,1) 100%);
background: linear-gradient(to right, rgba(116,235,213,1) 0%, rgba(116,235,213,1) 0%, rgba(172,183,229,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#74ebd5', endColorstr='#acb7e5', GradientType=1 );
}
.container {
  position: relative;
  border-radius: 25px;
  height: 300px;
  width: 50%;
  padding: 30px 10px;
  margin: 0 auto;
  margin-top: 150px;
  
  -webkit-box-shadow: 0px 6px 20px 0px rgba(0,0,0,0.5);
  -moz-box-shadow: 0px 6px 20px 0px rgba(0,0,0,0.5);
  box-shadow: 0px 6px 20px 0px rgba(0,0,0,0.5);
}
#quoteDisplay, #authorDisplay {
  font-family: Raleway, Times new Roman, serif;
  font-size: 19px;
  font-weight: bold;
}
#quoteDisplay {
  height: 60%;
  width: 80%;
  margin: 0 auto;
  text-align: center;
}
#authorDisplay {
  height: 15%;
  width: 80%;
  margin: 0 auto;
  text-align: center;
}
#bottomNav {
  position: relative;
  width: 60%;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
#newQuote {
  color: rgb(166, 166, 166);
  
  background: rgba(46,46,46,1);
background: -moz-linear-gradient(top, rgba(46,46,46,1) 0%, rgba(16,90,110,1) 50%, rgba(16,90,110,1) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(46,46,46,1)), color-stop(50%, rgba(16,90,110,1)), color-stop(100%, rgba(16,90,110,1)));
background: -webkit-linear-gradient(top, rgba(46,46,46,1) 0%, rgba(16,90,110,1) 50%, rgba(16,90,110,1) 100%);
background: -o-linear-gradient(top, rgba(46,46,46,1) 0%, rgba(16,90,110,1) 50%, rgba(16,90,110,1) 100%);
background: -ms-linear-gradient(top, rgba(46,46,46,1) 0%, rgba(16,90,110,1) 50%, rgba(16,90,110,1) 100%);
background: linear-gradient(to bottom, rgba(46,46,46,1) 0%, rgba(16,90,110,1) 50%, rgba(16,90,110,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2e2e2e', endColorstr='#105a6e', GradientType=0 );
  padding: 2%;
  width: 50%;
  border-radius: 5px;
  margin: 0 10px;
  font-family: Raleway, Times new Roman, serif;
  font-size: 17px;
  font-weight: bold;
  border: 0;
  letter-spacing: 1px;
  word-spacing: 2px;
  transition: width 0.3s, color 0.3s;
  
  -webkit-box-shadow: 0px 6px 10px 0px rgba(0,0,0,0.5);
  -moz-box-shadow: 0px 6px 20px 0px rgba(0,0,0,0.5);
  box-shadow: 0px 2px 7px 0px rgba(0,0,0,0.5);
}
button:focus {
  outline:0;
}
#newQuote:hover {
  width: 52%;
  color: rgb(191, 191, 191);
}
#credit {
  height: 50px;
  width: 50%;
  margin: 0 auto;
  margin-top: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#credit p {
  font-family: Raleway, Times new Roman, serif;
  font-size: 13px;
}
#credit p, #credit a {
  text-decoration: none;
  margin: 6px;
}
.fa-linkedin {
  color: rgb(0, 68, 102);
}
.fa-codepen {
  color: black;
}
.fab:hover {
  font-size: 17px;
}
              
            
!

JS

              
                const quoteClick = document.getElementById('newQuote');
quoteClick.addEventListener('click', generateQuote);

function getRndInteger(min, max) {
        let currentNum = Math.floor(Math.random() * (max - min) ) + min;
            return currentNum;
  };
window.onload = () => {
  generateQuote();
}

function generateQuote(){
      //assign the random number to the variable x
   var randomNum = getRndInteger(0, 10);
  // create a array with quotes
  var quoteText = ["The word 'happiness' would lose it's meaning if it were not balanced by sadness.", 
                   "The creation of something new is not accomplished by the intellect but by the play instinct acting of inner necessity. The creative mind plays with the objects it loves.",
                   "Listen, real poetry doesn't say anything; it just ticks off the possibilities. Opens all doors. You can walk through anyone that suits you.",
                  "The creative man is motivated by the desire to achieve, not by the desire to beat others.",
                  "Above all, don't lie to yourself. The man who lies to himself and listens to his own lie comes to a point that he cannot distinguish the truth within him, or around him, and so loses all respect for himself and for others. And having no respect he ceases to love.",
                  "Ultimately, a man should not ask what the meaning of his life is, but rather he must recognize that it is he who is asked.",
                  "There is only one corner in the universe you can be certain of improving, and that's your own self.",
                  "Most people do not really want freedom, because freedom involves responsibility, and most people are frightened of responsibility.",
                  "The computer scientist Donald Knuth was struck that “AI has by now succeeded in doing essentially everything that requires ‘thinking’ but has failed to do most of what people and animals do ‘without thinking’—that, somehow, is much harder!", 
                   "There are no norms. All people are exceptions to a rule that doesn't exist."];
    // create an array with authors
  var quoteName = ["Carl Gustav Jung", "Carl Gustav Jung", "Jim Morrison", "Ayn Rand", "Fyodor Dostoyevsky", "Viktor E. Frankl", "Aldous Huxley", "Sigmund Freud", "Nick Bostrom", "Fernando Pessoa"]
  
    //Array with background colors of html body and text color
    var backCol = ["#2d8659", "#008080", "#997a00", "#b32d00", "#990000", "#446600", "#26734d", "#558000", "#805500", "#55552b"];
    
  document.getElementById("quoteDisplay").innerHTML = "\"" + quoteText[randomNum] + "\"";
  document.getElementById("authorDisplay").innerHTML = quoteName[randomNum];  document.getElementById("quoteDisplay").style.color = backCol[randomNum];  document.getElementById("authorDisplay").style.color = backCol[randomNum];
  
};



              
            
!
999px

Console