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

              
                <script src='https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js'></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<script
  src="https://code.jquery.com/jquery-3.3.1.js"
  integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
  crossorigin="anonymous"></script>
<div id="quote-box">
  <h1>Random 'Quotes' Machine</h1>
  <div id="text"></div>
  <div id="author"></div>
  <button id="new-quote" onclick="newQuote()"><i class="fas fa-quote-left"></i> New "Quote"</button>
  <a id="tweet-quote" 
     onClick="tweet()"
      title="tweet the current quote"><button><i class="fab fa-twitter"></i> Tweet</button></a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8">
        </script>
</div>
<footer>created by ahmed derbel</footer>
              
            
!

CSS

              
                $tweeter: #38A1F3;
$main-fonts: Arial, sans-serif;
body {
  margin-bottom:0px;
  font-family: $main-fonts;
  text-align: center;
  background-color: $tweeter;
  }
#quote-box {
  background-color: white;
  margin: 80px auto;
  width: 50%;
  border: 1px solid black;
  padding: 10px;
  border-radius: 20px;
  h1 {
  }
  button {
    color: white;
    margin: 10px;
    border-radius: 10px;
    border: none;
    padding: 10px;
    outline: none !important;

  }
}
#tweet-quote button{
background-color: $tweeter;
  .fa-twitter{
    color: white;
  }
}
#new-quote{
  background-color:$tweeter;
}
#text {
  font-size:25px;
  padding: 10px;
}
#author {
  
  font-size: 20px;
}
footer {
  left: 0;
  bottom :0;
  width: 100%;
  color: white;
  position: fixed;
  background-color: #111;
}

              
            
!

JS

              
                colors = ["#38A1F3","#7FFFD4",'#342224', "#472E32", "#BDBB99", "#77B1A9", "#73A857",'#16a085', '#27ae60', '#2c3e50', '#f39c12', '#e74c3c', '#9b59b6', '#FB6964']
quotes = [{quote: "Don't cry because it's over, smile because it happened.",author:"Dr. Seuss"},{quote:"Live as if you were to die tomorrow. Learn as if you were to live forever.", author: "Mahatma Gandhi"},{quote:"Be yourself; everyone else is already taken.", author: "Oscar Wilde"},{quote:"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.", author: "Albert Einstein"},{quote:"Be who you are and say what you feel, because those who mind don't matter, and those who matter don't mind.", author: "Bernard M. Baruch"},{quote:"You only live once, but if you do it right, once is enough.", author: "Mae West"},{quote:"I am so clever that sometimes I don't understand a single word of what I am saying.", author: "Oscar Wilde"},{quote:"To be yourself in a world that is constantly trying to make you something else is the greatest accomplishment.", author: "Ralph Waldo Emerson"},{quote:"If you are not willing to risk the usual, you will have to settle for the ordinary.", author: " Jim Rohn"},{quote:"Do one thing every day that scares you.", author: "Eleanor Roosevelt"}];

let currentState = newQuote();

function newQuote() {
  random = Math.floor(Math.random() * quotes.length);  
backup = random+1;
  thisQuote = document.getElementById("text").innerHTML;
  
  document.getElementById("text").innerHTML = quotes[random].quote;
  document.getElementById("author").innerHTML = "_".concat(quotes[random].author);

  if ( quotes[random].quote === thisQuote){
     document.getElementById("text").innerHTML = quotes[backup].quote;
    document.getElementById("author").innerHTML = "_".concat(quotes[backup].author);
  }
  
   $("body,button").css("background-color",colors[ Math.floor(Math.random()* colors.length)]);
   $("body,button").css("transition","all 0.5s ease-in");
} 

function tweet() {
   $('#tweet-quote').attr('href', 'https://twitter.com/intent/tweet?text=' + encodeURIComponent('"' + document.getElementById("text").innerHTML + '" ' + document.getElementById("author").innerHTML  ));
}



              
            
!
999px

Console