Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                .container
	.row
		header.col-xs-12.text-center
			h1 Random Quote Generator
		.col-xs-10.col-xs-offset-1#main
			#quoteBox
				p#quoteText Nothing is original. Steal from anywhere that resonates with inspiration or fuels your imagination. Devour old films, new films, music, books, paintings, photographs, poems, dreams, random conversations, architecture, bridges, street signs, trees, clouds, bodies of water, light and shadows. Select only things to steal from that speak directly to your soul. If you do this, your work (and theft) will be authentic. Authenticity is invaluable; originality is nonexistent. And don’t bother concealing your thievery – celebrate it if you feel like it.
				p#author - Jim Jarmusch
				p#buttons
					a.btn.button#tweet(title='Tweet this Quote' target='_blank')
						i.fa.fa-twitter-square
					button.btn.button#newQuote New Quote
		.col-xs-12.text-center
			p#footer
				| by 
				a#myLink(href='https://codepen.io/Marijunjnja/#' title="My Codepen Portfolio") Bannon Tanner


//quote box
//footer
              
            
!

CSS

              
                

body {
	font-size: 14px;
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

h1 {
	color: #eee;
}

#quoteBox {
	border: none;
	border-radius: 40px;
	margin-top: 20px;
}

#main {
	background-color: #eee;
}

#quoteText {
	padding-left: 15px;
	padding-right: 15px;
}

#author {
	margin-left: 60%;
}

#buttons {
	margin-bottom: 20px;
	padding-bottom: 20px;
}

#tweet {
	float: left;
	font-size: 35px;
	height: 30px;
	max-height: 30px;
	padding-top: 0 auto;
	margin-top: 0 auto;
	padding-bottom: 20px;
	margin-bottom: 20px;
}

#newQuote {
	float: right;
	border: none;
	box-shadow: 0 2px 2px 1px rgba(0, 0, 0, 0.3);
	color: #eee;
	max-height: 30px;
	height: 30px;
	width: 100px;
	font-weight: bold;
	margin-bottom: 20px;
	padding-bottom: 20px;
	margin-top: 15px;
	padding-top: 4px;
	text-align: center;
}

#footer {
	margin-top: 20px;
	color: #eee;
	font-size:16px;
}

#myLink {
	color: #eee;
}

              
            
!

JS

              
                $(document).ready(function() {

  var quote = "How you play, is how you'll be remembered. Go Hard, follow your heart or be forgotten.";
  var author = "-Keshia Chante";
  var tweet = "";
	
  function quoteReady(newQuote) {
    console.log(newQuote);
    quote = newQuote.quote.replace(/<(?:.|\n)*?>/gm, '');
    author = newQuote.titles.replace(/<(?:.|\n)*?>/gm, '');
    tweet = quote.length + author.length <= 136 ? encodeURIComponent('"' + quote + '" -' + author) : encodeURIComponent('"' + quote.substring(0, 133-author.length)+'..." -'+author);
    if (quote && author) {
       $('#quoteText').replaceWith('<p id="quoteText" class="left-align">"' + quote + '"</p>');
       $('#author').replaceWith('<p id="author" class="right-align">-' + author + "</p>");
       $('#tweet').attr("href", "https://twitter.com/intent/tweet?text=" + tweet);
			 setRandomColor();
    }
  }
	
	setRandomColor();
  
  $("#newQuote").click(function() {
    WikiquoteApi.queryRandomTitle(
      function(title) {
      WikiquoteApi.getRandomQuote(title, function(newQuote) {
        quoteReady(newQuote);
      }
    );},
    function(msg) {
      console.log(msg);
    });
  });
});


//
// WikiquoteApi thanks to Nate Tyler. https://github.com/natetyler/wikiquotes-api
//

var WikiquoteApi = (function() {

  var wqa = {};

  var API_URL = "https://en.wikiquote.org/w/api.php";

  wqa.queryTitles = function(titles, success, error) {
    $.ajax({
      url: API_URL,
      dataType: "jsonp",
      data: {
        format: "json",
        action: "query",
        redirects: "",
        titles: titles
      },

      success: function(result, status) {
        var pages = result.query.pages;
        var pageId = -1;
        for(var p in pages) {
          var page = pages[p];
          if(!("missing" in page)) {
            pageId = page.pageid;
            break;
          }
        }
        if(pageId > 0) {
          success(pageId);
        } else {
          error("No results");
        }
      },

      error: function(xhr, result, status){
        error("Error processing your query");
      }
    });
  };

  wqa.queryRandomTitle = function(success, error) {
    $.ajax({
      url: API_URL,
      dataType: "jsonp",
      data: {
        format: "json",
        action: "query",
        redirects: "",
        list: "random",
        rnnamespace: "0"
      },

      success: function(result, status) {
        var title = result.query.random[0].title;
        if(title !== undefined) {
          success(title);
        } else {
          error("No results");
        }
      },

      error: function(xhr, result, status){
        error("Error processing your query");
      }
    });
  };

  wqa.getSectionsForPage = function(pageId, success, error) {
    $.ajax({
      url: API_URL,
      dataType: "jsonp",
      data: {
        format: "json",
        action: "parse",
        prop: "sections",
        pageid: pageId
      },

      success: function(result, status){
        var sectionArray = [];
        var sections = result.parse.sections;
        for(var s in sections) {
          var splitNum = sections[s].number.split('.');
          if(splitNum.length > 1 && splitNum[0] === "1") {
            sectionArray.push(sections[s].index);
          }
        }
        if(sectionArray.length === 0) {
          sectionArray.push("1");
        }
        success({ titles: result.parse.title, sections: sectionArray });
      },
      error: function(xhr, result, status){
        error("Error getting sections");
      }
    });
  };

  wqa.getQuotesForSection = function(pageId, sectionIndex, success, error) {
    $.ajax({
      url: API_URL,
      dataType: "jsonp",
      data: {
        format: "json",
        action: "parse",
        noimages: "",
        pageid: pageId,
        section: sectionIndex
      },

      success: function(result, status){
        var quotes = result.parse.text["*"];
        var quoteArray = [];

        var $lis = $(quotes).find('li:not(li li)');
        $lis.each(function() {
          $(this).children().remove(':not(b)');
          var $bolds = $(this).find('b');

          if($bolds.length > 0) {
            quoteArray.push($bolds.html());
          } else {
            quoteArray.push($(this).html());
          }
        });
        success({ titles: result.parse.title, quotes: quoteArray });
      },
      error: function(xhr, result, status){
        error("Error getting quotes");
      }
    });
  };

  wqa.openSearch = function(titles, success, error) {
    $.ajax({
      url: API_URL,
      dataType: "jsonp",
      data: {
        format: "json",
        action: "opensearch",
        namespace: 0,
        suggest: "",
        search: titles
      },

      success: function(result, status){
        success(result[1]);
      },
      error: function(xhr, result, status){
        error("Error with opensearch for " + titles);
      }
    });
  };

  wqa.getRandomQuote = function(titles, success, error) {

    var errorFunction = function(msg) {
      error(msg);
    };

    var chooseQuote = function(quotes) {
      var randomNum = Math.floor(Math.random()*quotes.quotes.length);
      success(
         { titles: quotes.titles, quote: quotes.quotes[randomNum] }
      );
			
    };

    var getQuotes = function(pageId, sections) {
      var randomNum = Math.floor(Math.random()*sections.sections.length);
      wqa.getQuotesForSection(pageId, sections.sections[randomNum], chooseQuote, errorFunction);
    };

    var getSections = function(pageId) {
      wqa.getSectionsForPage(pageId, function(sections) { getQuotes(pageId, sections); }, errorFunction);
    };

    wqa.queryTitles(titles, getSections, errorFunction);
  };

  wqa.getCompletelyRandomQuote = function(success, error) {
      wqa.queryRandomTitle(function(title) {
          wqa.getRandomQuote(title, success, error);
      }, error);
  };

  wqa.capitalizeString = function(input) {
    var inputArray = input.split(' ');
    var output = [];
    for(s in inputArray) {
      output.push(inputArray[s].charAt(0).toUpperCase() + inputArray[s].slice(1));
    }
    return output.join(' ');
  };

  return wqa;
}());

function getRandomColor() {
	var letters = '0123456789ABCDEF';
	var color = '#';
	for (var i = 0; i < 6; i++) {
		color += letters[Math.floor(Math.random() * 16)];
	}
	return color;
}

function setRandomColor() {
	var randomColor = getRandomColor();
	
	$('#tweet').css('color', randomColor);
	$('#newQuote').css('background-color', randomColor);
	$('body').css('background-color', randomColor);
	$('#quoteText').css('color', randomColor);
	$('#author').css('color', randomColor);
}


              
            
!
999px

Console