Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


		<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>

		<div class="wrap">
				<div class="header">
						<h1 class='text-primary text-center'>Random Quote Generator</h1>
						<div class="button-cntr">
								<button class="btn btn-large btn-primary getquote">
										Get New Quote

				<div class="jumbotron quote-container">
								<p id="quote" class="quote"></p>
								<cite id="author" class="author"> </cite>

				<div class="twitter-container">

						<button class="btn btn-primary btn-twitter" target="_blank"><i class="fa fa-twitter"></i> Tweet this quote</button>

		<!-- end wrap div -->
		<div class="footer">
				<p>Quotes provided by <a href="https://quotesondesign.com">https://quotesondesign.com</a></p>
				<p>This Codepen created as an example for <a href="https://www.freecodecamp.com" target="_blank">
			 www.freecodecamp.com <img src="https://pbs.twimg.com/profile_images/562385977390272512/AK29YaTf.png" class="fcc-logo img-circle"></a> by <a href="https://www.freecodecamp.com/kurzninja" target="_blank">kurzninja</a>
		<!-- footer end -->

              h1 {
  font-family: Roboto, sans-serif;

.header {
	background-color: black;
	padding: 30px 0 0 0;
	margin: 0px;
	height: 200px;
body {
  background: url("http://cdn.wonderfulengineering.com/wp-content/uploads/2014/04/code-wallpaper-4.png");
  background-size: stretch;
	background-repeat: none;
	font-family: Roboto;
	height: 100%;
	margin-top: 0px !important;
		padding-top: 0px !imporant;

.quotes {
  display: block;
  font-size: 20px;
  color: #C00;
  margin-left: auto;
  margin-right: auto;
  text-align: center;

.getquote {
  display: block;
  margin-left: auto;
  margin-right: auto;  
  background-color: rgb(200,255,255);
  color: #000;
	border-top: 2px solid rgb(240,255,255);
	border-bottom: 2px solid rgb(150,205,205);
	border-left: none;
	border-right: none;
	border-radius: 20px;
	outline-style: none !important;

.getquote:active {
  background-color: rgb(100,155,155) !important;
  color: #000 !important;
	border-bottom: 2px solid rgb(240,255,255);
	border-top: 2px solid rgb(150,205,205);
	outline-style: none !important;

.getquote:focus {
  background-color: rgb(200,255,255);
  color: #000 !important;
	outline-style: none !important;
	border-bottom: 2px solid rgb(240,255,255);
	border-top: 2px solid rgb(150,205,205);

.getquote:hover {
  background-color: rgb(150,205,205);
  color: #000;
	border-top: 2px solid #ddd;
	border-bottom: 2px solid #333;
	outline-style: none !important;

.quote-container {
  height: 300px;
  background-color: rgba(20,24,41,.9);
  margin-left: auto;
  margin-right: auto;
  color: #eee;
  padding: 30px;
  text-align: justify;
  border-top: solid 5px #555;
	border-bottom: solid 5px #555;

.button-cntr {
  background-color: #CCC;
  margin-left: auto;
  margin-right: auto;
  margin-top: 10px;
  margin-bottom: 10px;
  width: 300px;
  height: 50px;
  border-radius: 5px;
  padding: 10px;

.footer {
  height: 100px;
  padding: 20px;
  width: 100%;
  background-color: #000;
  color: #666;  

.author {
  width: 100%;
  text-align: center !important;  
  font-size: 1.5em;
  font-style: italic;

.smaller-text {
  font-size: .8em;

.regular-text {
  font-size: 1.2em;

.larger-text {
  font-size: 2em;

.twitter-container {
  padding-top: 20px;
  text-align: center

.wrap {
        min-height: 100%;
        height: auto !important;
        height: 100%;
        /* Negative indent footer by it's height */
        margin: 0 auto -100px;

html {
	height: 100%;
		margin-top: 0px;
	padding-top: 0px;

.fcc-logo {
	height: 30px;
	width: 30px;
              $('document').ready(function() {

		var quotesArray = [];

		var currentURL = "https://quotesondesign.com/wp-json/posts?callback=&filter[orderby]=rand&filter[posts_per_page]=20";

		var twitterEndpoint = "https://twitter.com/intent/tweet";

		var currentQuote = "";

		//parseData takes the JSON array and parses it into a useable {body, author} object
		function parseData(dataArray) {
						//testing that dataArray was passed properly
						//console.log("dataArray: " + dataArray);
						return dataArray.map(function(elem) {
								var content = elem['content'].replace(/(\<\/?p\>)|\n/g, "").trim();
								return {
										body: content,
										author: elem.title
								}; //return statement
						}); //map's anon function
				} //parsedata()

		//fillQuotesArray() takes the parsed JSON data objects and puts them into the array
		function fillQuotesArray(data) {
				//console.log("About to fill: " + JSON.stringify(data,null,2));
				quotesArray = parseData(data);

		//getQuotes fetches the JSON data with an API call
		function getQuotes(url) {
				return $.getJSON(url).then(fillQuotesArray);
				//testing that data was fetched
				//console.log("Got Data: " + JSON.stringify(data,null,2));

		function renderQuote(quote) {
				if (quote['body'].length > 450) {
				} else if (quote['body'].length < 100) {
				} else {

				$('#quote').html("&quot;" + quote.body + "&quot;");
				$('#author').html("&ndash; " + quote.author);


		function createTwitterURL(quoteText) {
				if (quoteText.length > 86) {
						quoteText = quoteText.slice(0, 83);
						while (quoteText[quoteText.length - 1] === " ") {
								quoteText = quoteText.slice(0, -1);
						quoteText = quoteText + "...";
				quoteText = '"' + quoteText + '"';
				var appendURL = encodeURIComponent(quoteText);
				var completeURL = twitterEndpoint + "?text=" + appendURL + "&hashtags=freecodecamp&url=https://codepen.io/kurzninja/full/qdLYwX&via=kurzninja";
				return completeURL;

		function setNextQuote() {
				currentQuote = quotesArray.shift();
				$('.btn-twitter').click(function() {
						var windowopts = "height=550,width=420,menubar=no,toolbar=no,personalbar=no,status=yes";
						window.open(createTwitterURL(currentQuote['body']), windowopts);

		function newQuote() {
				quotesArray.length ? setNextQuote() : getQuotes(currentURL).then(setNextQuote);

		function updateQuote() {
				$('#quote').fadeOut(200, newQuote);

		$('.getquote').click(updateQuote); // .getquote .click  


}); // document.ready
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.