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

Details

Privacy

Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO

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.

Template

Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:

Screenshot

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO

HTML

              
                
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>

	
	<div id="overlay"></div>
	<div class="container text-center mb-4">
		<h1>Front End Libraries Projects</h1>
		<h3>Build a Random Quote Machine</h3>
	</div>
	<div class="container">
		<div id="quote-box" class="card border border-info rounded ">
			<div class="card-header text-center">
				<h4>"Quote" Machine</h4>
			</div>
			<div id="quote-body">
			</div>
		</div>
	</div>
              
            
!

CSS

              
                #overlay {
	background-image: linear-gradient(to bottom right, LightSkyBlue, LightCyan 30% 75%, LightSkyBlue);
	background-size: cover;	
	z-index: -1;
	position: fixed;
	top: 0;
	bottom: 0;
	right: 0;
	left: 0;
}



              
            
!

JS

              
                /* array with quotes*/
const quoteArr = [
	["Many people wait throughout their whole lives for the chance to be good in their own fashion.", "Friedrich Nietzsche"],
	
	["Render therefore to all their dues.", "Anonymous", "Bible, Romans xiii. 7."],
	
	["A friend is one before whom I may think aloud." , "Ralph Waldo Emerson"],
	
	["The defects and faults in the mind are like wounds in the body. After all imaginable care has been taken to heal them up, still there will be a scar left behind.", "Francois de La Rochefoucauld"],
	
	["Disinterested intellectual curiosity is the life blood of real civilization.", "G. M. Trevelyan in English Social History"],
	
	["The truth is cruel, but it can be loved and it makes free those who love it.", "George Santayana"],
	
	["The history of the Victorian Age will never be written: we know too much about it. For ignorance is the first requisite of the historian - ignorance, which simplifies and clarifies, which selects and omits, with a placid perfection unattainable by the highest art.", "Lytton Strachey", "Eminent Victorians"],
	
	["Do not cut down the tree that gives you shade." , "Persian Proverb"],
	
	["For the truth of the conclusions of physical science, observation is the supreme Court of Appeal. (...) Clearly a statement cannot be tested by observation unless it is an assertion about the results of observation. Every item of physical knowledge must therefore be an assertion of what has been or would be the result of carrying out a specified observational procedure.", "Sir Arthur Eddington", "The Philosophy of Physical Science"],
	
	["I think the mark of a great ruler, is not his ability to make war but to achieve peace.", "Monica Fairview in Darcy Cousins"],
	
	["Behold, the nations are as a drop of a bucket, and are counted as the small dust of the balance.", "Anonymous", "Bible, Isaiah xl. 15."],
	
	["The most radical revolutionary will become a conservative the day after the revolution.", "Hannah Arendt", "The New Yorker, September 12, 1970"],
	
	["Laughter is the sensation of feeling good all over, and showing it principally in one place.", "Josh Billings"],
	
	["Fortuna kołem się toczy = Fortune's wheel is ever turning.", "Polish Proverb"],
	
	["Beware the fury of a patient man.", "John Dryden", "Absalom and Achitophel"],
	
	["Commandment Number One of any truly civilized society is this: Let people be different.", "David Grayson"],
	
	["All men by nature desire knowledge.", "Aristotle", "Metaphysics"],
	
	["Everything comes to him who hustles while he waits.", "Thomas A. Edison"],
	
	["I violated the Noah rule: Predicting rain doesn't count; building arks does.", "Warren Buffett"],
	
	["Errors to be dangerous must have a great deal of truth mingled with them. It is only from this alliance that they can ever obtain an extensive circulation.", "Sydney Smith"]
	
];



function randomQuoteIndex() {
	return Math.floor(Math.random() * quoteArr.length);
}


class App extends React.Component {
	constructor(props) {
		  super(props);
		  this.state = { quoteIndex: randomQuoteIndex(), source: quoteArr};
		  this.handleChange = this.handleChange.bind(this)
	}
	
	handleChange () {
		this.setState({
      quoteIndex: randomQuoteIndex(),
    });
	}
	
	render() {
		return (
				<div>
				<div className="card-body" >
					<blockquote id="text" className="blockquote mb-0">
						<p>{this.state.source[this.state.quoteIndex][0]}</p>
						<footer id="author" className="blockquote-footer text-right">
							<span>{this.state.source[this.state.quoteIndex][1]}</span>
						</footer>
					</blockquote>
				</div>
				
			  <div className="card-body" >
					<a id="tweet-quote" href="twitter.com/intent/tweet"><i className="fab fa-twitter"></i></a>
					<button id="new-quote" className="btn btn-primary rounded float-right" onClick={this.handleChange}>New random quote</button>
				</div>
				</div>
		);
	}
}

ReactDOM.render(<App />, document.getElementById('quote-body'));


              
            
!
999px
If you get tired, be like an AJAX request and REST.

Console