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

              
                <body id="bg">
	
    <div class="container">
    <div id="color" class="containerInner1">
       <div id="textContainer">

       	 <div>
       		<h1>"<span id="quote"><!-- Quotes will display here --></span>"</h1>
         </div>

      	<div>
            <h3><em>- <span id="author"></span></em></h3>
        </div>

		<div class="containerInner2">
        <div class="twitter" id="twitter">
        	<a href="#" target="_blank"><i class="fa fa-twitter"></i></a>
        </div>

		  <div class="btnQuote">
			  <a class=btn href="#" id="generator">New Quote</a>
		  </div> 
		</div> <!-- End containerInner2 -->

        </div> <!-- End textContainer -->
        
    </div> <!-- End container inner-->   
    </div> <!-- End container -->
	
	<footer>
		<p>By Reza</p>
	</footer>

</body>



              
            
!

CSS

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

body {
	font-family: 'Roboto', arial, helvetica, sans-serif;
	font-size: 16px;
	font-weight: 300;
	color: white;
	margin: 0;
	padding: 0;
}

.container {
	margin: 0 auto;
	max-width: 600px;
	position: relative;
}

#color {
  background-color: #60B494;
}

.containerInner1 {
	margin-top: 5em;
	padding: 2.5em 2.5em;
	border-radius: 5px;
}

#textContainer {
	min-height: 11em;
	position: relative;
}

h1, h3 {
	padding: 0;
}

h1 {
	font-size: 1.9em;
	font-weight: 300;
	text-align: center;
	line-height: 1.3em;
}

h3 {
	margin-top: 1.5em;
	font-size: 1.05em;
	text-align: right;
	font-weight: 300;
}

.containerInner2 {
	margin-top: 2em;
	margin-bottom: .5em;
}

.containerInner2::after {
	content: '';
	display: block;
	clear: both;
} 

.twitter {
	text-align: center;
	float: left;
	border-radius: 3px;
	padding: 5px 10px;
	border: 1px solid white;
	display: inline-block;
}

i.fa {
	color: white;
	font-size: 1.8em;
}

.btnQuote {
	float: right;
}

a {
	font-family: 'Roboto', arial, helvetica, sans-serif;
	text-decoration: none;
	font-size: .8em;
	color: white;
}

.btn {
	padding: 9px 14px;
	border: 1px solid white;
	border-radius: 3px;
	display: inline-block;
}

footer {
	text-align: center;
	font-size: .9em;
	color: #333;
}
              
            
!

JS

              
                var quotes = [
    {
        quote: 'Whether you think you can or whether you think you can\'t, you\'re right!',
        author: "Henry Ford"
    },
    {
        quote: 'Don\'t wait for your ship to come in, swim out to it',
        author: "Unknown",
        unknown: true
    },
    {   
        quote: "The world has the habit of making room for the man whose actions show that he knows where he is going",
        author: "Napoleon Hill"
    },

    {
        quote: "Innovation distinguishes between a leader and a follower",
        author: "Steve Jobs"
    },

    {
        quote: "The future is now. It's time to grow up and be strong. Tomorrow may well be too late",
        author: "Neil LaBute"
    },

    {
        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: "Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover.",
        author: "H. Jackson Brown Jr."
    },

    {
        quote: "You only live once, but if you do it right, once is enough",
        author: "Mae West"
    },

    {
        quote: "In three words I can sum up everything I've learned about life: it goes on",
        author: "Robert Frost"
    }                 

    ];    

var displayedQuote;
var currentIdx;

function updateQuote() {
    do {
      var idx = Math.floor(Math.random() * quotes.length);
    } while(currentIdx === idx);
    
    displayedQuote = quotes[idx];
    
    currentIdx = idx;
    $('#quote').html(quotes[idx].quote);
    $('#author').html(quotes[idx].author);
}

// Share quote to Twitter
function shareTweet() {
    var quoteToTweet = quotes[currentIdx].quote; 
    // encodeURI = untuk encode hasil query, contoh: Hello World = Hello%20World
    if(quoteToTweet.length > 100) {  //Untuk membatasi tweet <= 100 char
        quoteToTweet = quoteToTweet.substr(0, 100).match(/(^.+)\s/)[1] + "...";
    }

    quoteToTweet = encodeURI("\"" +quoteToTweet+ "\"");
    window.open("https://twitter.com/intent/tweet?text=" + quoteToTweet + "&hashtags=FreeCodeCamp");
}

$(function(){
    updateQuote();
    $('#twitter').click(shareTweet);
    $('#generator').click(updateQuote);
});

var colors = ["#60B494", "#60AAB4", "#6080B4", "#6A60B4", "#9460B4", "#B460AA"];

var changeColor;
var currentIdc;

document.getElementById('generator').addEventListener('click', updateColor);

function updateColor() {
    do {
        var idc=Math.floor(Math.random() * colors.length);
    } while (currentIdc === idc);

    changeColor = colors[idc];

    currentIdc = idc;
    document.getElementById('color').style.backgroundColor = colors[idc];
}
              
            
!
999px

Console