cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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 lang="en">
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->

	<title>Random Quote Machine</title>

	<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
	<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
	<link href="css/style.css" rel="stylesheet">

	<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>


<div class="flexbox-container">
	<div id="quotes">
		<div id="text">
			<i class="fa fa-quote-left fa-3x" aria-hidden="true"></i>
			<p id="quote-text"></p><br />
			<p id="quote-author"></p>
			<i class="fa fa-quote-right fa-3x" aria-hidden="true"></i><br />

		<div id="buttons">
			<button class="button" id="new-quote-button" onclick="getQuote()">New Quote</button>
			<button class="button" id="tweet-button" onclick="shareTweet()"><i class="fa fa-twitter" aria-hidden="true"></i> Share on Twitter</button>

<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="js/index.js"></script>


              /********** GLOBAL STYLES **********/

/* Testing purposes */
* {
	border: 0px solid red;

html, body {
	height: 100%;
	margin: 0;

body {
	transition:background 1s;

	-webkit-font-smoothing: antialiased;
	text-rendering: optimizelegibility;

/********** QUOTES BOX **********/

.flexbox-container {
	height: 100%;

	display: flex;
	display: -ms-flexbox;
	display: -webkit-flex;

	justify-content: center;
	align-items: center;
	-ms-flex-align: center;
	-webkit-align-items: center;
	-webkit-box-align: center;

#quotes {
	width: 500px;
	height: 300px;
	padding: 20px;
	border: 1px solid black;
	border-radius: 8px;
	transition:background 1s;
	font-family: 'Raleway', sans-serif;
	font-size: 25px;

.fa, p {
	display: inline;

p {
	padding: 20px;

.button {
    border: none;
    color: white;
    padding: 15px 32px;
    width: 246px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    border-radius: 8px;
    -webkit-transition-duration: 0.4s; /* Safari */
    transition-duration: 0.4s;
    cursor: pointer;

#text {
	height: 250px;
              // Colors: [Background, Quote box Background, Text, Buttons, Buttons Hover]
// Color Combinations from: https://designschool.canva.com/blog/100-color-combinations/
// http://www.hexcolortool.com - Used to generate 10% lighter color for button hover
var colors = [
	["#444C5C","#CE5A57","#78A5A3","#E1B16A", "#FBCB84"],
	["#90AFC5","#336B87","#2A3132","#763626", "#905040"], // Subdued & Professional
	["#46211A","#693D3D","#BA5536","#A43820", "#BE523A"], // Dark & Earthy
	["#505160","#68829E","#AEBD38","#598234", "#739C4E"], // Crisp & Dramatic
	["#2E4600","#486B00","#A2C523","#7D4427", "#975E41"], // Outdoorsy & Natural
	["#375E97","#FB6542","#FFBB00","#3F681C", "#598236"], // Primary Colors With a Vibrant Twist
	["#F4CC70","#DE7A22","#20948B","#6AB187", "#84CBA1"], // Surf & Turf
	["#8D230F","#1E434C","#9B4F0F","#C99E10", "#E3B82A"], // Autumn in Vermont
	["#011A27","#063852","#F0810F","#E6DF44", "#FFF95E"], // Day & Night
	["#0F1B07","#ffffff","#5C821A","#C6D166", "#E0EB80"]  // Modern & Crisp

var colorIndex = 0;

window.onload = function WindowLoad(event) {

function getQuote() {
	// Get a quote from Famous Quotes API on MashApe
	    url: 'https://andruxnet-random-famous-quotes.p.mashape.com/?cat=famous', // The URL to the API. You can get this by clicking on "Show CURL example" from an API profile
	    type: 'GET', // The HTTP Method, can be GET POST PUT DELETE etc
	    data: {}, // Additional parameters here
	    dataType: 'json',
	    success: function(data) {
	       	document.getElementById("quote-text").innerHTML = data.quote; 
	       	document.getElementById("quote-author").innerHTML = data.author; 
	    error: function(err) { 
	    	alert("Error: " + err.status + ". " + err.responseText);	
	    beforeSend: function(xhr) {
	    xhr.setRequestHeader("X-Mashape-Authorization", "e1wdzgHAD2mshnZlaKpZkmJF33lNp1AonJFjsnfA0zY6PiYl3E"); // Enter here your Mashape key


function changeColors() {
	// Pick a random color group
	colorIndex = Math.floor(Math.random() * colors.length);

	// Set the colors
	document.body.style.backgroundColor = colors[colorIndex][0];
	document.getElementById("quotes").style.backgroundColor = colors[colorIndex][1];
	document.getElementById("quote-text").style.color = colors[colorIndex][2];
	document.getElementById("quote-author").style.color = colors[colorIndex][2];
	document.getElementById("new-quote-button").style.background = colors[colorIndex][3];
	document.getElementById("tweet-button").style.background = colors[colorIndex][3];

    $(this).css("background-color", colors[colorIndex][4]);
    }, function(){
    $(this).css("background-color", colors[colorIndex][3]);

function shareTweet() {
	window.open('https://twitter.com/share?text=' + '"' + document.getElementById("quote-text").innerHTML + '"' + ' - ' + document.getElementById("quote-author").innerHTML,'','scrollbars=no,menubar=no,height=300,width=650,resizable=yes,toolbar=no,location=no,status=no');
	// + '&url='+ window.location.href
🕑 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.
Loading ..................